org.eclipse.jdt.core.IJavaElementDelta Java Examples

The following examples show how to use org.eclipse.jdt.core.IJavaElementDelta. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JFaceCompletionProposalComputer.java    From saneclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void elementChanged(ElementChangedEvent event) {
	final IJavaProject javaProject = getCachedJavaProject();
	if (javaProject == null) {
		return;
	}

	final IJavaElementDelta[] children = event.getDelta().getChangedChildren();
	for (int i = 0; i < children.length; i++) {
		final IJavaElementDelta child = children[i];
		if (javaProject.equals(child.getElement())) {
			if (isClasspathChange(child)) {
				setCachedJavaProject(null);
			}
		}
	}
}
 
Example #2
Source File: JFaceCompletionProposalComputer.java    From saneclipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Does the delta indicate a classpath change?
 *
 * @param delta the delta to inspect
 * @return true if classpath has changed
 */
private boolean isClasspathChange(IJavaElementDelta delta) {
	final int flags = delta.getFlags();
	if (isClasspathChangeFlag(flags)) {
		return true;
	}

	if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
		final IJavaElementDelta[] children = delta.getAffectedChildren();
		for (int i = 0; i < children.length; i++) {
			if (isClasspathChangeFlag(children[i].getFlags())) {
				return true;
			}
		}
	}

	return false;
}
 
Example #3
Source File: SimpleDelta.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void toDebugString(StringBuffer buffer) {
	buffer.append("["); //$NON-NLS-1$
	switch (getKind()) {
		case IJavaElementDelta.ADDED :
			buffer.append('+');
			break;
		case IJavaElementDelta.REMOVED :
			buffer.append('-');
			break;
		case IJavaElementDelta.CHANGED :
			buffer.append('*');
			break;
		default :
			buffer.append('?');
			break;
	}
	buffer.append("]: {"); //$NON-NLS-1$
	toDebugString(buffer, getFlags());
	buffer.append("}"); //$NON-NLS-1$
}
 
Example #4
Source File: ResourceChangedManager.java    From ContentAssist with MIT License 6 votes vote down vote up
/**
 * Collects all the deltas of the changes.
 * @param delta the root delta of the change
 * @param deltas the collection of the deltas to be collected
 */
private void collectDeltas(IJavaElementDelta delta) {
    if (delta.getKind() == IJavaElementDelta.ADDED ||
        delta.getKind() == IJavaElementDelta.REMOVED) {
        if (!contain(delta)) {
            deltas.add(delta);
        }
    } else if (delta.getKind() == IJavaElementDelta.CHANGED &&
            ((delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0)) {
        if (!contain(delta)) {
            deltas.add(delta);
        }
    }
    
    for (IJavaElementDelta d : delta.getAffectedChildren()) {
        collectDeltas(d);
    }
}
 
Example #5
Source File: Storage2UriMapperJavaImpl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private Set<IJavaElementDelta> getProjectDeltas(IJavaElementDelta delta) {
	IJavaElement element = delta.getElement();
	if(delta.getElement().getElementType() == IJavaElement.JAVA_PROJECT) {
		return Collections.singleton(delta);
	}
	Set<IJavaElementDelta> result = null;
	if(element instanceof IJavaModel) {
		for(IJavaElementDelta child: delta.getAffectedChildren()) {
			Set<IJavaElementDelta> projectDeltas = getProjectDeltas(child);
			if(!projectDeltas.isEmpty()) {
				if(result == null)
					result = newLinkedHashSet(); 
				result.addAll(projectDeltas);
			}
		}
	}
	return result == null ? Collections.<IJavaElementDelta>emptySet() : result;
}
 
Example #6
Source File: AbstractJavaProjectsState.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private boolean isAffectingPackageFragmentRoots(IJavaElementDelta delta) {
	IJavaElement element = delta.getElement();
	if (element instanceof IPackageFragmentRoot) {
		if (javaProjectClasspathChangeAnalyzer.isRelevantPackageFragmentRootChange(delta)) {
			return true;
		}
	} else if (element instanceof IJavaModel) {
		return isAffectingPackageFragmentRoots(delta.getAffectedChildren());
	} else if (element instanceof IJavaProject) {
		if (javaProjectClasspathChangeAnalyzer.isClasspathChangeOnProject(delta)) {
			// filter out IJavaElementDelta.F_SOURCEATTACHED | IJavaElementDelta.F_SOURCEDETACHED only
			if (javaProjectClasspathChangeAnalyzer.isAttachmentChangeOnly(delta)) {
				return  false;
			}
			return true;
		}
		return isAffectingPackageFragmentRoots(delta.getAffectedChildren());
	}
	return false;
}
 
Example #7
Source File: JavaProjectClasspathChangeAnalyzer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * determines if the delta is a relevant change on a IPackageFragmentRoot
 * 
 * @param delta
 *            the IJavaElementDelta to analyze. the deltas element must be an instance of IPackageFragmentRoot
 */
public boolean isRelevantPackageFragmentRootChange(IJavaElementDelta delta) {
	IJavaElement element = delta.getElement();
	assert (element instanceof IPackageFragmentRoot);
	return delta.getKind() == IJavaElementDelta.REMOVED 
			|| delta.getKind() == IJavaElementDelta.ADDED
			|| (delta.getFlags() & IJavaElementDelta.F_REORDER) != 0
			|| (delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0
			|| (delta.getFlags() & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0
			|| (
					(
						((IPackageFragmentRoot) element).isExternal() 
						|| ((IPackageFragmentRoot) element).isArchive()
					) && 
					(
						delta.getFlags() & // external folders change
						(IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED)
					) == delta.getFlags()
			);
}
 
Example #8
Source File: ChangeCollector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addAffectedChildren(IJavaElementDelta delta) throws JavaModelException {
	IJavaElementDelta[] children = delta.getAffectedChildren();
	for (int i = 0, length = children.length; i < length; i++) {
		IJavaElementDelta child = children[i];
		IJavaElement childElement = child.getElement();
		switch (childElement.getElementType()) {
			case IJavaElement.IMPORT_CONTAINER:
				addChange((IImportContainer)childElement, child);
				break;
			case IJavaElement.IMPORT_DECLARATION:
				addChange((IImportDeclaration)childElement, child);
				break;
			case IJavaElement.TYPE:
				addChange((IType)childElement, child);
				break;
			case IJavaElement.INITIALIZER:
			case IJavaElement.FIELD:
			case IJavaElement.METHOD:
				addChange((IMember)childElement, child);
				break;
		}
	}
}
 
Example #9
Source File: ChangeCollector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addTypeRemoval(IType type, SimpleDelta existingDelta) {
	if (existingDelta != null) {
		switch (existingDelta.getKind()) {
			case IJavaElementDelta.ADDED:
				// ADDED then REMOVED
				this.changes.remove(type);
				break;
			case IJavaElementDelta.CHANGED:
				// CHANGED then REMOVED
				existingDelta.removed();
				break;
				// REMOVED then REMOVED: should not happen
		}
	} else {
		// check whether the type removal affects the hierarchy
		if (this.hierarchy.contains(type)) {
			SimpleDelta typeDelta = new SimpleDelta();
			typeDelta.removed();
			this.changes.put(type, typeDelta);
		}
	}
}
 
Example #10
Source File: DefaultJavaFoldingStructureProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IJavaElementDelta findElement(IJavaElement target, IJavaElementDelta delta) {

			if (delta == null || target == null)
				return null;

			IJavaElement element= delta.getElement();

			if (element.getElementType() > IJavaElement.CLASS_FILE)
				return null;

			if (target.equals(element))
				return delta;

			IJavaElementDelta[] children= delta.getAffectedChildren();

			for (int i= 0; i < children.length; i++) {
				IJavaElementDelta d= findElement(target, children[i]);
				if (d != null)
					return d;
			}

			return null;
		}
 
Example #11
Source File: JFaceCompletionProposalComputer.java    From saneclipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Do the flags indicate a classpath change?
 *
 * @param flags the flags to inspect
 * @return true if the flag flags a classpath change
 */
private boolean isClasspathChangeFlag(int flags) {
	if ((flags & IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0) {
		return true;
	}

	if ((flags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0) {
		return true;
	}

	if ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) {
		return true;
	}

	if ((flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) {
		return true;
	}

	return false;
}
 
Example #12
Source File: JavaStructureDiffViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Check whether the given delta has been sent when saving this reconciler's editor.
 * 
 * @param cu the compilation unit
 * @param delta the deltas
 * @return <code>true</code> if the given delta
 * @since 3.5
 */
private boolean canIgnore(IJavaElement cu, IJavaElementDelta[] delta) {
	if (delta.length != 1)
		return false;

	int flags= delta[0].getFlags();

	// become working copy
	if (flags == IJavaElementDelta.F_PRIMARY_WORKING_COPY)
		return true;

	// save
	if (flags == IJavaElementDelta.F_PRIMARY_RESOURCE && delta[0].getElement().equals(cu))
		return true;

	return canIgnore(cu, delta[0].getAffectedChildren());
}
 
Example #13
Source File: SWTTemplateCompletionProposalComputer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Does the delta indicate a classpath change?
 * @param delta the delta to inspect
 * @return true if classpath has changed
 */
private boolean isClasspathChange(IJavaElementDelta delta) {
	int flags= delta.getFlags();
	if (isClasspathChangeFlag(flags))
		return true;

	if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
		IJavaElementDelta[] children= delta.getAffectedChildren();
		for (int i= 0; i < children.length; i++) {
			if (isClasspathChangeFlag(children[i].getFlags()))
				return true;
		}
	}

	return false;
}
 
Example #14
Source File: ClasspathUpdateHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private Set<String> processDelta(IJavaElementDelta delta, Set<String> uris) {
	IJavaElement element = delta.getElement();
	switch (element.getElementType()) {
	case IJavaElement.JAVA_MODEL:
		uris = processDeltaChildren(delta, uris);
		break;
	case IJavaElement.JAVA_PROJECT:
		if (isClasspathChanged(delta.getFlags())) {
			if (uris == null) {
				uris = new HashSet<String>();
			}
			IJavaProject javaProject = (IJavaProject) element;
			uris.add(ProjectUtils.getProjectRealFolder(javaProject.getProject()).toFile().toURI().toString());
		}
		break;
	default:
		break;
	}
	return uris;
}
 
Example #15
Source File: SearchResultUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void elementChanged(ElementChangedEvent event) {
	//long t0= System.currentTimeMillis();
	IJavaElementDelta delta= event.getDelta();
	Set<IAdaptable> removedElements= new HashSet<IAdaptable>();
	Set<IAdaptable> potentiallyRemovedElements= new HashSet<IAdaptable>();
	collectRemoved(potentiallyRemovedElements, removedElements, delta);
	if (removedElements.size() > 0)
		handleRemoved(removedElements);
	if (potentiallyRemovedElements.size() > 0)
		handleRemoved(potentiallyRemovedElements);
	//System.out.println(this+"handled delta in: "+(System.currentTimeMillis()-t0));
}
 
Example #16
Source File: ElementChangeListener.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public void elementChanged(ElementChangedEvent event) {
  final Map<IJavaElement, IJavaElementDelta> changedElements = new HashMap<IJavaElement, IJavaElementDelta>();

  JavaModelSearch.visitJavaElementDelta(event.getDelta(),
      new IJavaElementDeltaVisitor() {
        public boolean visit(IJavaElementDelta delta) {
          IJavaElement element = delta.getElement();

          /*
           * We care about packages being only added or removed because if we
           * called the change listeners on a change to a package, any change
           * to any file in that package will cause all ui.xml files that
           * reference that package (say with xmlns urn imports) to be
           * revalidated. Some projects end up having hundreds of ui.xml files
           * referencing a package, and then saving any change in that package
           * ends up taking tens of seconds.
           */
          int type = element.getElementType();
          if (type == IJavaElement.PACKAGE_FRAGMENT
              && delta.getKind() == IJavaElementDelta.CHANGED) {
            return true;
          }

          Set<IReference> references = referenceManager.getReferencesWithMatchingJavaElement(
              element, EnumSet.of(ReferenceLocationType.TARGET));
          if (references != null && references.size() > 0) {
            changedElements.put(element, delta);
          }
          return true;
        }
      });

  if (changedElements.size() > 0) {
    callReferenceChangeListeners(changedElements);
  }
}
 
Example #17
Source File: ElementChangedListener.java    From JDeodorant with MIT License 5 votes vote down vote up
private void processDelta(IJavaElementDelta delta) {
	IJavaElement javaElement = delta.getElement();
	switch(javaElement.getElementType()) {
	case IJavaElement.JAVA_MODEL:
	case IJavaElement.JAVA_PROJECT:
	case IJavaElement.PACKAGE_FRAGMENT_ROOT:
	case IJavaElement.PACKAGE_FRAGMENT:
		IJavaElementDelta[] affectedChildren = delta.getAffectedChildren();
		for(IJavaElementDelta affectedChild : affectedChildren) {
			processDelta(affectedChild);
		}
		break;
	case IJavaElement.COMPILATION_UNIT:
		ICompilationUnit compilationUnit = (ICompilationUnit)javaElement;
		if(delta.getKind() == IJavaElementDelta.ADDED) {
			CompilationUnitCache.getInstance().compilationUnitAdded(compilationUnit);
		}
		else if(delta.getKind() == IJavaElementDelta.REMOVED) {
			CompilationUnitCache.getInstance().compilationUnitRemoved(compilationUnit);
		}
		else if(delta.getKind() == IJavaElementDelta.CHANGED) {
			if((delta.getFlags() & IJavaElementDelta.F_FINE_GRAINED) != 0) {
				CompilationUnitCache.getInstance().compilationUnitChanged(compilationUnit);
			}
		}
	}
}
 
Example #18
Source File: OpenTypeHistory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean processChildrenDelta(IJavaElementDelta delta) {
	IJavaElementDelta[] children= delta.getAffectedChildren();
	for (int i= 0; i < children.length; i++) {
		if (processDelta(children[i])) {
			return true;
		}
	}
	return false;
}
 
Example #19
Source File: StandardJavaElementContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests if the a Java element delta contains a class path change
 *
 * @param delta the Java element delta
 * @return returns <code>true</code> if the delta contains a class path change
 */
protected boolean isClassPathChange(IJavaElementDelta delta) {

	// need to test the flags only for package fragment roots
	if (delta.getElement().getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT)
		return false;

	int flags= delta.getFlags();
	return (delta.getKind() == IJavaElementDelta.CHANGED &&
		((flags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0) ||
		 ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) ||
		 ((flags & IJavaElementDelta.F_REORDER) != 0));
}
 
Example #20
Source File: DefaultJavaFoldingStructureProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void elementChanged(ElementChangedEvent e) {
	IJavaElementDelta delta= findElement(fInput, e.getDelta());
	if (delta != null && (delta.getFlags() & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_CHILDREN)) != 0) {

		if (shouldIgnoreDelta(e.getDelta().getCompilationUnitAST(), delta))
			return;

		fUpdatingCount++;
		try {
			update(createContext(false));
		} finally {
			fUpdatingCount--;
		}
	}
}
 
Example #21
Source File: ClasspathChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addClasspathDeltas(JavaElementDelta delta, IPackageFragmentRoot[] roots, int flag) {
	for (int i = 0; i < roots.length; i++) {
		IPackageFragmentRoot root = roots[i];
		delta.changed(root, flag);
		if ((flag & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0
				|| (flag & IJavaElementDelta.F_SOURCEATTACHED) != 0
				|| (flag & IJavaElementDelta.F_SOURCEDETACHED) != 0){
			try {
				root.close();
			} catch (JavaModelException e) {
				// ignore
			}
		}
	}
}
 
Example #22
Source File: JavaModelSearch.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void visitJavaElementDelta(IJavaElementDelta delta,
    IJavaElementDeltaVisitor visitor) {
  if (!visitor.visit(delta)) {
    return;
  }

  for (IJavaElementDelta childDelta : delta.getAffectedChildren()) {
    visitJavaElementDelta(childDelta, visitor);
  }
}
 
Example #23
Source File: JavaElementDelta.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the new element to a new array that contains all of the elements of the old array.
 * Returns the new array.
 */
protected IJavaElementDelta[] growAndAddToArray(IJavaElementDelta[] array, IJavaElementDelta addition) {
	IJavaElementDelta[] old = array;
	array = new IJavaElementDelta[old.length + 1];
	System.arraycopy(old, 0, array, 0, old.length);
	array[old.length] = addition;
	return array;
}
 
Example #24
Source File: PackagesViewHierarchicalContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void processAffectedChildren(IJavaElementDelta delta) throws JavaModelException {
	IJavaElementDelta[] affectedChildren = delta.getAffectedChildren();
	for (int i = 0; i < affectedChildren.length; i++) {
		if (!(affectedChildren[i] instanceof ICompilationUnit)) {
			processDelta(affectedChildren[i]);
		}
	}
}
 
Example #25
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void elementChanged(final ElementChangedEvent e) {

					if (getControl() == null)
						return;

					Display d= getControl().getDisplay();
					if (d != null) {
						d.asyncExec(new Runnable() {
							public void run() {
								ICompilationUnit cu= (ICompilationUnit) fInput;
								IJavaElement base= cu;
								if (fTopLevelTypeOnly) {
									base= cu.findPrimaryType();
									if (base == null) {
										if (fOutlineViewer != null)
											fOutlineViewer.refresh(true);
										return;
									}
								}
								IJavaElementDelta delta= findElement(base, e.getDelta());
								if (delta != null && fOutlineViewer != null) {
									fOutlineViewer.reconcile(delta);
								}
							}
						});
					}
				}
 
Example #26
Source File: ChangeCollector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addChange(IImportContainer importContainer, IJavaElementDelta newDelta) throws JavaModelException {
	int newKind = newDelta.getKind();
	if (newKind == IJavaElementDelta.CHANGED) {
		addAffectedChildren(newDelta);
		return;
	}
	SimpleDelta existingDelta = (SimpleDelta)this.changes.get(importContainer);
	if (existingDelta != null) {
		switch (newKind) {
			case IJavaElementDelta.ADDED:
				if (existingDelta.getKind() == IJavaElementDelta.REMOVED) {
					// REMOVED then ADDED
					this.changes.remove(importContainer);
				}
				break;
			case IJavaElementDelta.REMOVED:
				if (existingDelta.getKind() == IJavaElementDelta.ADDED) {
					// ADDED then REMOVED
					this.changes.remove(importContainer);
				}
				break;
				// CHANGED handled above
		}
	} else {
		SimpleDelta delta = new SimpleDelta();
		switch (newKind) {
			case IJavaElementDelta.ADDED:
				delta.added();
				break;
			case IJavaElementDelta.REMOVED:
				delta.removed();
				break;
		}
		this.changes.put(importContainer, delta);
	}
}
 
Example #27
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isPossibleStructuralChange(IJavaElementDelta cuDelta) {
	if (cuDelta.getKind() != IJavaElementDelta.CHANGED) {
		return true; // add or remove
	}
	int flags= cuDelta.getFlags();
	if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
		return true;
	}
	return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
}
 
Example #28
Source File: JavaEditorBreadcrumb.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the most generic ancestor of the given input which has a change, or <b>null</b>
 * if no such ancestor exists.
 *
 * @param input the input of which the result must be an ancestor
 * @param delta the delta describing the model change
 * @return the changed element or <code>null</code>
 */
private IJavaElement getChangedParentElement(IJavaElement input, IJavaElementDelta delta) {
	IJavaElement element= delta.getElement();

	if (!isAncestor(element, input))
		return null;

	if (element instanceof ICompilationUnit) {
		ICompilationUnit cu= (ICompilationUnit) element;
		if (!cu.getPrimary().equals(cu))
			return null;

		if (isStructuralChange(delta))
			return element;
	} else {
		if (!onlyChildrenChanged(delta))
			return element;
	}

	IJavaElementDelta[] affectedChildren= delta.getAffectedChildren();
	for (int i= 0; i < affectedChildren.length; i++) {
		IJavaElement res= getChangedParentElement(input, affectedChildren[i]);
		if (res != null)
			return res;
	}

	return null;
}
 
Example #29
Source File: DeltaConverter.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.5
 */
protected void convertAddedPackageFragment(IJavaElementDelta delta, List<IResourceDescription.Delta> result) {
	IPackageFragment fragment = (IPackageFragment) delta.getElement();
	try {
		for (ICompilationUnit cu : fragment.getCompilationUnits()) {
			convertNewTypes(cu, result);
		}
	} catch (JavaModelException e) {
		if (LOGGER.isDebugEnabled())
			LOGGER.debug(e, e);
	}
}
 
Example #30
Source File: JavaWorkingSetUpdater.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void processJavaDelta(WorkingSetDelta result, IJavaElementDelta delta) {
	IJavaElement jElement= delta.getElement();
	int index= result.indexOf(jElement);
	int type= jElement.getElementType();
	int kind= delta.getKind();
	int flags= delta.getFlags();
	if (type == IJavaElement.JAVA_PROJECT && kind == IJavaElementDelta.CHANGED) {
		if (index != -1 && (flags & IJavaElementDelta.F_CLOSED) != 0) {
			result.set(index, ((IJavaProject)jElement).getProject());
		} else if ((flags & IJavaElementDelta.F_OPENED) != 0) {
			index= result.indexOf(((IJavaProject)jElement).getProject());
			if (index != -1)
				result.set(index, jElement);
		}
	}
	if (index != -1) {
		if (kind == IJavaElementDelta.REMOVED) {
			if ((flags & IJavaElementDelta.F_MOVED_TO) != 0) {
				result.set(index, delta.getMovedToElement());
			} else {
				result.remove(index);
			}
		}
	}
	IResourceDelta[] resourceDeltas= delta.getResourceDeltas();
	if (resourceDeltas != null) {
		for (int i= 0; i < resourceDeltas.length; i++) {
			processResourceDelta(result, resourceDeltas[i]);
		}
	}
	IJavaElementDelta[] children= delta.getAffectedChildren();
	for (int i= 0; i < children.length; i++) {
		processJavaDelta(result, children[i]);
	}
}