public ToBeBuilt removeProject(IProject project, IProgressMonitor monitor) {
   SubMonitor progress =
       SubMonitor.convert(monitor, Iterables.size(builderState.getAllResourceDescriptions()));
   ToBeBuilt result = new ToBeBuilt();
   Iterable<IResourceDescription> allResourceDescriptions =
       builderState.getAllResourceDescriptions();
   for (IResourceDescription description : allResourceDescriptions) {
     Iterable<Pair<IStorage, IProject>> storages = mapper.getStorages(description.getURI());
     boolean onlyOnThisProject = true;
     Iterator<Pair<IStorage, IProject>> iterator = storages.iterator();
     while (iterator.hasNext() && onlyOnThisProject) {
       Pair<IStorage, IProject> storage2Project = iterator.next();
       onlyOnThisProject = project.equals(storage2Project.getSecond());
     }
     if (onlyOnThisProject) result.getToBeDeleted().add(description.getURI());
     progress.worked(1);
   }
   return result;
 }
 public ToBeBuilt updateProjectNewResourcesOnly(IProject project, IProgressMonitor monitor)
     throws CoreException {
   SubMonitor progress =
       SubMonitor.convert(monitor, Messages.ToBeBuiltComputer_CollectingReosurces, 1);
   progress.subTask(Messages.ToBeBuiltComputer_CollectingReosurces);
   ToBeBuilt toBeBuilt = updateProject(project, progress.newChild(1));
   Iterable<URI> existingURIs =
       Iterables.transform(
           builderState.getAllResourceDescriptions(),
           new Function<IResourceDescription, URI>() {
             public URI apply(IResourceDescription from) {
               return from.getURI();
             }
           });
   for (URI existingURI : existingURIs) {
     toBeBuilt.getToBeDeleted().remove(existingURI);
     toBeBuilt.getToBeUpdated().remove(existingURI);
   }
   return toBeBuilt;
 }
예제 #3
0
  /**
   * @param monitor the progress monitor to use for reporting progress to the user. It is the
   *     caller's responsibility to call done() on the given monitor. Accepts null, indicating that
   *     no progress should be reported and that the operation cannot be cancelled.
   */
  protected void doClean(ToBeBuilt toBeBuilt, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 2);
    ImmutableList<Delta> deltas =
        builderState.clean(toBeBuilt.getToBeDeleted(), progress.newChild(1));
    if (participant != null) {
      Set<URI> sourceURIs =
          new SourceLevelURICache()
              .getSourcesFrom(toBeBuilt.getToBeDeleted(), resourceServiceProvideRegistry);

      participant.build(
          new BuildContext(
              this,
              getResourceSetProvider().get(getProject()),
              deltas,
              sourceURIs,
              BuildType.CLEAN),
          progress.newChild(1));
    } else {
      progress.worked(1);
    }
  }
예제 #4
0
 /**
  * @param monitor the progress monitor to use for reporting progress to the user. It is the
  *     caller's responsibility to call done() on the given monitor. Accepts null, indicating that
  *     no progress should be reported and that the operation cannot be cancelled.
  */
 protected void doBuild(ToBeBuilt toBeBuilt, IProgressMonitor monitor, BuildType type)
     throws CoreException {
   buildLogger.log("Building " + getProject().getName());
   // return early if there's nothing to do.
   // we reuse the isEmpty() impl from BuildData assuming that it doesnT access the ResourceSet
   // which is still null
   // and would be expensive to create.
   boolean indexingOnly = type == BuildType.RECOVERY;
   if (new BuildData(getProject().getName(), null, toBeBuilt, queuedBuildData, indexingOnly)
       .isEmpty()) return;
   SubMonitor progress = SubMonitor.convert(monitor, 2);
   ResourceSet resourceSet = getResourceSetProvider().get(getProject());
   resourceSet
       .getLoadOptions()
       .put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
   BuildData buildData =
       new BuildData(
           getProject().getName(), resourceSet, toBeBuilt, queuedBuildData, indexingOnly);
   ImmutableList<Delta> deltas = builderState.update(buildData, progress.newChild(1));
   if (participant != null && !indexingOnly) {
     SourceLevelURICache sourceLevelURIs = buildData.getSourceLevelURICache();
     Set<URI> sources = sourceLevelURIs.getSources();
     participant.build(
         new BuildContext(this, resourceSet, deltas, sources, type), progress.newChild(1));
     try {
       getProject().getWorkspace().checkpoint(false);
     } catch (
         NoClassDefFoundError
             e) { // guard against broken Eclipse installations / bogus project configuration
       log.error(e.getMessage(), e);
     }
   } else {
     progress.worked(1);
   }
   resourceSet.eSetDeliver(false);
   resourceSet.getResources().clear();
   resourceSet.eAdapters().clear();
 }