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);
   }
 }
Example #2
0
 public Object[] getChildren(final Object parentElement) {
   List<IFolder> list = new ArrayList<IFolder>();
   /*if( parentElement instanceof IHaskellProject ) {
     IHaskellProject hsProject = ( IHaskellProject )parentElement;
     Set<IPath> sourcePaths = hsProject.getSourcePaths();
     for( IPath sourcePath: sourcePaths ) {
       IProject project = hsProject.getResource();
       if( !sourcePath.equals( project.getProjectRelativePath() ) ) {
         list.add( project.getFolder( sourcePath ) );
       }
     }
   }*/
   if (parentElement instanceof IProject) {
     IProject project = (IProject) parentElement;
     IFile f = BuildWrapperPlugin.getCabalFile(project);
     try {
       PackageDescription pd = PackageDescriptionLoader.load(f);
       for (String sourcePath : pd.getStanzasBySourceDir().keySet()) {
         if (sourcePath.length() > 0) {
           list.add(project.getFolder(sourcePath));
         }
       }
     } catch (CoreException ex) {
       HaskellUIPlugin.log(ex);
     }
   }
   return list.toArray();
 }
Example #3
0
  public List<GHCPackageConf> getChildren() {
    List<GHCPackageConf> result = new ArrayList<GHCPackageConf>();
    /*ICompilerManager man = CompilerManager.getInstance();
    if( man.getCurrentHsImplementation() != null ) {
      IPath binDir = new Path( man.getCurrentHsImplementation().getBinDir() );
      String exe =  binDir.append( GHCSyntax.GHC_PKG ).toOSString();
      String queryResult = QueryUtil.query( exe, "list" ); //$NON-NLS-1$
      parsePackageList( queryResult, result );

      ScionInstance si=HaskellUIPlugin.getDefault().getScionInstanceManager( project );
      if (si!=null && si.getCabalDescription()!=null){
        try {
          System.out.println(si.getCabalDescription().toString( 2 ));
        } catch (JSONException json){
          json.printStackTrace();
        }
      }

    }*/
    /*ScionInstance si=ScionPlugin.getScionInstance( project );
    if (si!=null && si.getPackagesByDB()!=null){
      for (String db:si.getPackagesByDB().keySet()){
        result.add( new GHCPackageConf( this, new Path(db), si.getPackagesByDB().get( db ) ) );
      }
    }*/
    BWFacade f = BuildWrapperPlugin.getFacade(project);
    if (f != null) {
      Map<String, CabalPackage[]> dbm = f.getPackagesByDB();
      if (dbm != null) {
        for (String db : dbm.keySet()) {
          result.add(new GHCPackageConf(this, new Path(db), dbm.get(db)));
        }
      }
    }
    return result;
  }