Java Code Examples for org.eclipse.jdt.core.IJavaElementDelta#getAffectedChildren()
The following examples show how to use
org.eclipse.jdt.core.IJavaElementDelta#getAffectedChildren() .
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: SWTTemplateCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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 2
Source File: JFaceCompletionProposalComputer.java From saneclipse with Eclipse Public License 1.0 | 6 votes |
/** * 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: ChangeCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 4
Source File: SearchResultUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void collectRemoved(Set<IAdaptable> potentiallyRemovedSet, Set<IAdaptable> removedElements, IJavaElementDelta delta) { if (delta.getKind() == IJavaElementDelta.REMOVED) removedElements.add(delta.getElement()); else if (delta.getKind() == IJavaElementDelta.CHANGED) { int flags= delta.getFlags(); if ((flags & REMOVED_FLAGS) != 0) { potentiallyRemovedSet.add(delta.getElement()); } else { IJavaElementDelta[] childDeltas= delta.getAffectedChildren(); for (int i= 0; i < childDeltas.length; i++) { collectRemoved(potentiallyRemovedSet, removedElements, childDeltas[i]); } } } IResourceDelta[] resourceDeltas= delta.getResourceDeltas(); if (resourceDeltas != null) { for (int i= 0; i < resourceDeltas.length; i++) { collectRemovals(removedElements, resourceDeltas[i]); } } }
Example 5
Source File: ResourceChangedManager.java From ContentAssist with MIT License | 6 votes |
/** * 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 6
Source File: DefaultJavaFoldingStructureProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 7
Source File: PackagesViewHierarchicalContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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 8
Source File: JavaStructureDiffViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected IJavaElementDelta findJavaElementDelta(IJavaElement unit, IJavaElementDelta delta) { if (delta == null || unit == null) return null; IJavaElement element= delta.getElement(); if (canIgnore(unit, delta.getAffectedChildren())) return null; if (unit.equals(element)) { if (isContentChange(delta)) { return delta; } return null; } if (element.getElementType() > IJavaElement.CLASS_FILE) return null; IJavaElementDelta[] children= delta.getAffectedChildren(); if (children == null || children.length == 0) return null; for (int i= 0; i < children.length; i++) { IJavaElementDelta d= findJavaElementDelta(unit, children[i]); if (d != null) return d; } return null; }
Example 9
Source File: ElementChangedListener.java From JDeodorant with MIT License | 5 votes |
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 10
Source File: JavaEditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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 11
Source File: JavaOutlinePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected IJavaElementDelta findElement(IJavaElement unit, IJavaElementDelta delta) { if (delta == null || unit == null) return null; IJavaElement element= delta.getElement(); if (unit.equals(element)) { if (isPossibleStructuralChange(delta)) { return delta; } return null; } if (element.getElementType() > IJavaElement.CLASS_FILE) return null; IJavaElementDelta[] children= delta.getAffectedChildren(); if (children == null || children.length == 0) return null; for (int i= 0; i < children.length; i++) { IJavaElementDelta d= findElement(unit, children[i]); if (d != null) return d; } return null; }
Example 12
Source File: AbstractJavaElementLabelDecorator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected boolean processChildrenDelta(IJavaElementDelta delta, List<IJavaElement> result) { IJavaElementDelta[] children= delta.getAffectedChildren(); for (int i= 0; i < children.length; i++) { processDelta(children[i], result); } return false; }
Example 13
Source File: JavaModelSearch.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public static void visitJavaElementDelta(IJavaElementDelta delta, IJavaElementDeltaVisitor visitor) { if (!visitor.visit(delta)) { return; } for (IJavaElementDelta childDelta : delta.getAffectedChildren()) { visitJavaElementDelta(childDelta, visitor); } }
Example 14
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void convertCompilationUnits(IJavaElementDelta delta, List<IResourceDescription.Delta> result) { IJavaElement element = delta.getElement(); if (element.getElementType() == IJavaElement.COMPILATION_UNIT) { convertCompilationUnit(delta, result); } if (element.getElementType() < IJavaElement.COMPILATION_UNIT) { for (IJavaElementDelta child : delta.getAffectedChildren()) { convertCompilationUnits(child, result); } if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { convertPackageFragment(delta, result); } } }
Example 15
Source File: OthersWorkingSetUpdater.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void processJavaDelta(List<IAdaptable> elements, IJavaElementDelta delta) { IJavaElement jElement= delta.getElement(); int type= jElement.getElementType(); if (type == IJavaElement.JAVA_PROJECT) { int index= elements.indexOf(jElement); int kind= delta.getKind(); int flags= delta.getFlags(); if (kind == IJavaElementDelta.CHANGED) { if (index != -1 && (flags & IJavaElementDelta.F_CLOSED) != 0) { elements.set(index, ((IJavaProject)jElement).getProject()); fWorkingSet.setElements(elements.toArray(new IAdaptable[elements.size()])); } else if ((flags & IJavaElementDelta.F_OPENED) != 0) { index= elements.indexOf(((IJavaProject)jElement).getProject()); if (index != -1) { elements.set(index, jElement); fWorkingSet.setElements(elements.toArray(new IAdaptable[elements.size()])); } } } // don't visit below projects return; } IJavaElementDelta[] children= delta.getAffectedChildren(); for (int i= 0; i < children.length; i++) { processJavaDelta(elements, children[i]); } }
Example 16
Source File: JavaSearchScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void processDelta(IJavaElementDelta delta, int eventType) { switch (delta.getKind()) { case IJavaElementDelta.CHANGED: IJavaElementDelta[] children = delta.getAffectedChildren(); for (int i = 0, length = children.length; i < length; i++) { IJavaElementDelta child = children[i]; processDelta(child, eventType); } break; case IJavaElementDelta.REMOVED: IJavaElement element = delta.getElement(); if (this.encloses(element)) { if (this.elements != null) { this.elements.remove(element); } String path = null; switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: path = ((IJavaProject)element).getProject().getFullPath().toString(); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: path = ((IPackageFragmentRoot)element).getPath().toString(); break; default: return; } for (int i = 0; i < this.pathsCount; i++) { if (this.relativePaths[i].equals(path)) { this.relativePaths[i] = null; rehash(); break; } } } break; } }
Example 17
Source File: ClasspathChangeListener.java From scava with Eclipse Public License 2.0 | 5 votes |
private void visit(IJavaElementDelta delta) { IJavaElement el = delta.getElement(); switch (el.getElementType()) { case IJavaElement.JAVA_MODEL: visitChildren(delta); break; case IJavaElement.JAVA_PROJECT: if (isClasspathChanged(delta.getFlags())) { System.out.println(); IJavaElementDelta[] affectedChildren = delta.getAffectedChildren(); for (IJavaElementDelta iJavaElementDelta : affectedChildren) { if (iJavaElementDelta.getKind() == IJavaElementDelta.CHANGED || iJavaElementDelta.getKind() == IJavaElementDelta.ADDED) { int flags = iJavaElementDelta.getFlags(); if (isRemove(flags)) { Activator.getDefault().getEventBus().post(new ClasspathChangeEvent( iJavaElementDelta.getElement().getElementName(), ClasspathChangeEventType.DELETED)); } if (isAdd(flags)) { Activator.getDefault().getEventBus().post(new ClasspathChangeEvent( iJavaElementDelta.getElement().getElementName(), ClasspathChangeEventType.ADDED)); } } } } break; default: break; } }
Example 18
Source File: ClasspathUpdateHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private Set<String> processDeltaChildren(IJavaElementDelta delta, Set<String> uris) { for (IJavaElementDelta c : delta.getAffectedChildren()) { uris = processDelta(c, uris); } return uris; }
Example 19
Source File: ClassFileDocumentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Recursively check whether the class file has been deleted. * * @param input the package fragment root * @param delta the Java element delta * @return <code>true</code> if delta processing can be stopped */ protected boolean check(IPackageFragmentRoot input, IJavaElementDelta delta) { IJavaElement element= delta.getElement(); if ((delta.getKind() & IJavaElementDelta.REMOVED) != 0 || (delta.getFlags() & IJavaElementDelta.F_CLOSED) != 0) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=19023 if (element.equals(input.getJavaProject()) || element.equals(input)) { handleDeleted(fInput); return true; } } if (((delta.getFlags() & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) && input.equals(element)) { handleDeleted(fInput); return true; } if (((delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) && input.equals(element)) { handleDeleted(fInput); return true; } IJavaElementDelta[] subdeltas= delta.getAffectedChildren(); for (int i= 0; i < subdeltas.length; i++) { if (check(input, subdeltas[i])) return true; } if ((delta.getFlags() & IJavaElementDelta.F_SOURCEDETACHED) != 0 || (delta.getFlags() & IJavaElementDelta.F_SOURCEATTACHED) != 0) { IClassFile file= fInput != null ? fInput.getClassFile() : null; IJavaProject project= input != null ? input.getJavaProject() : null; boolean isOnClasspath= false; if (file != null && project != null) isOnClasspath= project.isOnClasspath(file); if (isOnClasspath) { fireInputChanged(fInput); return false; } else { handleDeleted(fInput); return true; } } return false; }
Example 20
Source File: InterfaceIndicatorLabelDecorator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected void processDelta(IJavaElementDelta delta, List<IJavaElement> result) { IJavaElement elem= delta.getElement(); boolean isChanged= delta.getKind() == IJavaElementDelta.CHANGED; boolean isRemoved= delta.getKind() == IJavaElementDelta.REMOVED; int flags= delta.getFlags(); switch (elem.getElementType()) { case IJavaElement.JAVA_PROJECT: if (isRemoved || (isChanged && (flags & IJavaElementDelta.F_CLOSED) != 0)) { return; } processChildrenDelta(delta, result); return; case IJavaElement.PACKAGE_FRAGMENT_ROOT: if (isRemoved || (isChanged && ( (flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 || (flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0))) { return; } processChildrenDelta(delta, result); return; case IJavaElement.PACKAGE_FRAGMENT: if (isRemoved) return; processChildrenDelta(delta, result); return; case IJavaElement.TYPE: case IJavaElement.CLASS_FILE: return; case IJavaElement.JAVA_MODEL: processChildrenDelta(delta, result); return; case IJavaElement.COMPILATION_UNIT: // Not the primary compilation unit. Ignore it if (!JavaModelUtil.isPrimary((ICompilationUnit) elem)) { return; } if (isChanged && ((flags & IJavaElementDelta.F_CONTENT) != 0 || (flags & IJavaElementDelta.F_FINE_GRAINED) != 0)) { if (delta.getAffectedChildren().length == 0) return; result.add(elem); } return; default: // fields, methods, imports ect return; } }