コード例 #1
0
 public void apply(final IDocument document) {
   IProject p = marker.getResource().getProject();
   IFile f = BuildWrapperPlugin.getCabalFile(p);
   IDocumentProvider prov = new TextFileDocumentProvider();
   try {
     prov.connect(f);
     IDocument doc = prov.getDocument(f);
     PackageDescription pd = PackageDescriptionLoader.load(f);
     int length = pd.getStanzas().size();
     for (int a = 0; a < length; a++) {
       PackageDescriptionStanza pds = pd.getStanzas().get(a);
       CabalSyntax cs = pds.getType();
       if (CabalSyntax.SECTION_EXECUTABLE.equals(cs)
           || CabalSyntax.SECTION_LIBRARY.equals(cs)
           || CabalSyntax.SECTION_TESTSUITE.equals(cs)) {
         RealValuePosition rvp = pds.addToPropertyList(CabalSyntax.FIELD_BUILD_DEPENDS, pkg);
         if (rvp != null) {
           rvp.updateDocument(doc);
           pd = PackageDescriptionLoader.load(doc.get());
         }
       }
     }
     prov.saveDocument(new NullProgressMonitor(), f, doc, true);
   } catch (CoreException ce) {
     HaskellUIPlugin.log(ce);
   }
 }
コード例 #2
0
  @Override
  public Image getImage(final Object element) {
    /*Image result = super.getImage( element );

    if( element instanceof ExecutableStanza ) {
      result = HaskellUIImages.getImage( IImageNames.EXECUTABLE_STANZA );
    } else if( element instanceof LibraryStanza ) {
      result = HaskellUIImages.getImage( IImageNames.LIBRARY_STANZA );
    } else if( element instanceof GeneralStanza ) {
      result = HaskellUIImages.getImage( IImageNames.GENERAL_STANZA );
    }*/
    Image result = null;
    if (element instanceof PackageDescriptionStanza) {
      PackageDescriptionStanza pds = (PackageDescriptionStanza) element;
      if (CabalSyntax.SECTION_EXECUTABLE.equals(pds.getType())) {
        result = HaskellUIImages.getImage(IImageNames.EXECUTABLE_STANZA);
      } else if (CabalSyntax.SECTION_LIBRARY.equals(pds.getType())) {
        result = HaskellUIImages.getImage(IImageNames.LIBRARY_STANZA);
      } else if (pds.getType() == null) {
        result = HaskellUIImages.getImage(IImageNames.GENERAL_STANZA);
      }
    }
    if (result == null) {
      result = super.getImage(element);
    }

    return result;
  }
コード例 #3
0
  public void contributeOnNewProject(final PackageDescription pd) {
    IHsImplementation impl = CompilerManager.getInstance().getCurrentHsImplementation();
    if (impl != null && impl.getType().equals(HsImplementationType.GHC)) {
      List<String> ls = new CompilerParams().construct(impl.getVersion());
      StringBuilder sbOptions = new StringBuilder();
      StringBuilder sbExtensions = new StringBuilder();
      for (String s : ls) {
        if (s != null) {
          if (s.startsWith("-X")) { // $NON-NLS-1$
            if (sbExtensions.length() > 0) {
              sbExtensions.append(" "); // $NON-NLS-1$
            }
            sbExtensions.append(s.substring(2));
          } else {
            if (sbOptions.length() > 0) {
              sbOptions.append(" "); // $NON-NLS-1$
            }

            sbOptions.append(s);
          }
        }
      }
      String valOptions = sbOptions.toString();
      String valExtensions = sbExtensions.toString();
      for (PackageDescriptionStanza pds : pd.getStanzas()) {
        if (CabalSyntax.SECTION_EXECUTABLE.equals(pds.getType())
            || CabalSyntax.SECTION_LIBRARY.equals(pds.getType())
            || CabalSyntax.SECTION_TESTSUITE.equals(pds.getType())) {
          if (valOptions.length() > 0) {
            pds.update(CabalSyntax.FIELD_GHC_OPTIONS, valOptions);
          }
          if (valExtensions.length() > 0) {
            pds.update(CabalSyntax.FIELD_EXTENSIONS, valExtensions);
          }
        }
      }
    }
  }