private SubscriberChangeEvent[] handleRemovedRoot(IResource removedRoot) {
    // Determine if any of the roots of the compare are affected
    List removals = new ArrayList(resources.length);
    for (int j = 0; j < resources.length; j++) {
      IResource root = resources[j];
      if (removedRoot.getFullPath().isPrefixOf(root.getFullPath())) {
        // The root is no longer managed by CVS
        removals.add(root);
        try {
          tree.flushVariants(root, IResource.DEPTH_INFINITE);
        } catch (TeamException e) {
          CVSProviderPlugin.log(e);
        }
      }
    }
    if (removals.isEmpty()) {
      return new SubscriberChangeEvent[0];
    }

    // Adjust the roots of the subscriber
    List newRoots = new ArrayList(resources.length);
    newRoots.addAll(Arrays.asList(resources));
    newRoots.removeAll(removals);
    resources = (IResource[]) newRoots.toArray(new IResource[newRoots.size()]);

    // Create the deltas for the removals
    SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[removals.size()];
    for (int i = 0; i < deltas.length; i++) {
      deltas[i] =
          new SubscriberChangeEvent(
              this, ISubscriberChangeEvent.ROOT_REMOVED, (IResource) removals.get(i));
    }
    return deltas;
  }
Exemplo n.º 2
0
  private void removeBuildPath(IResource resource, IProject project) {

    IScriptProject projrct = DLTKCore.create(project);
    IPath filePath = resource.getFullPath();

    oldBuildEntries = Arrays.asList(projrct.readRawBuildpath());

    newBuildEntries = new ArrayList<IBuildpathEntry>();

    newBuildEntries.addAll(oldBuildEntries);

    for (int i = 0; i < oldBuildEntries.size(); i++) {
      IBuildpathEntry fEntryToChange = oldBuildEntries.get(i);
      IPath entryPath = fEntryToChange.getPath();

      int mattchedPath = entryPath.matchingFirstSegments(filePath);

      if (mattchedPath == filePath.segmentCount()) {
        newBuildEntries.remove(fEntryToChange);
      } else {
        IBuildpathEntry newEntry =
            RefactoringUtility.createNewBuildpathEntry(
                fEntryToChange, fEntryToChange.getPath(), filePath, ""); // $NON-NLS-1$
        newBuildEntries.remove(fEntryToChange);
        newBuildEntries.add(newEntry);
      }
    }

    oldIncludePath = new ArrayList<IBuildpathEntry>();

    newIncludePathEntries = new ArrayList<IBuildpathEntry>();
    List<IncludePath> includePathEntries =
        Arrays.asList(IncludePathManager.getInstance().getIncludePaths(project));

    for (IncludePath entry : includePathEntries) {
      Object includePathEntry = entry.getEntry();
      IResource includeResource = null;
      if (!(includePathEntry instanceof IBuildpathEntry)) {
        includeResource = (IResource) includePathEntry;
        IPath entryPath = includeResource.getFullPath();

        IBuildpathEntry oldEntry =
            RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath);
        oldIncludePath.add((IBuildpathEntry) oldEntry);

        if (filePath.isPrefixOf(entryPath) || entryPath.equals(filePath)) {
        } else {
          IBuildpathEntry newEntry =
              RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath);
          newIncludePathEntries.add(newEntry);
        }
      } else {
        newIncludePathEntries.add((IBuildpathEntry) includePathEntry);
        oldIncludePath.add((IBuildpathEntry) includePathEntry);
      }
    }
  }
Exemplo n.º 3
0
 @Override
 public void transferListenersTo(
     IModelChangeProviderExtension target, IModelChangedListenerFilter filter) {
   ArrayList<IModelChangedListener> removed = new ArrayList<>();
   for (int i = 0; i < fListeners.size(); i++) {
     IModelChangedListener listener = fListeners.get(i);
     if (filter == null || filter.accept(listener)) {
       target.addModelChangedListener(listener);
       removed.add(listener);
     }
   }
   fListeners.removeAll(removed);
 }
 public IStatus asStatus() {
   if (errors.isEmpty()) {
     List result = new ArrayList();
     accumulateStatus(
         (IResource[]) addedRoots.toArray(new IResource[addedRoots.size()]), result, ADDED);
     accumulateStatus(
         (IResource[]) removedRoots.toArray(new IResource[removedRoots.size()]), result, REMOVED);
     accumulateStatus(
         (IResource[]) movedRoots.toArray(new IResource[movedRoots.size()]), result, MOVED);
     accumulateStatus(
         (IResource[]) copiedRoots.toArray(new IResource[copiedRoots.size()]), result, COPIED);
     accumulateStatus(
         (IResource[]) changedRoots.toArray(new IResource[changedRoots.size()]), result, CHANGED);
     accumulateStatus(
         (IResource[]) closedProjects.toArray(new IResource[closedProjects.size()]),
         result,
         CLOSED);
     if (!result.isEmpty()) {
       if (result.size() == 1) return (IStatus) result.get(0);
       return new MultiStatus(
           "org.eclipse.core.tests.resources",
           0,
           (IStatus[]) result.toArray(new IStatus[result.size()]),
           "Changes were validated",
           null);
     }
     return Status.OK_STATUS;
   } else if (errors.size() == 1) {
     return (IStatus) errors.get(0);
   }
   return new MultiStatus(
       "org.eclipse.core.tests.resources",
       0,
       (IStatus[]) errors.toArray(new IStatus[errors.size()]),
       "Errors occurred",
       null);
 }