/** * Searches for element. * * @param unit Unit to search in. * @param delta Delta. * @return Found element. */ protected ICElementDelta findElement(ICElement unit, ICElementDelta delta) { if (delta == null || unit == null) { return null; } final ICElement element = delta.getElement(); if (unit.equals(element)) { if (isPossibleStructuralChange(delta)) { return delta; } return null; } if (element.getElementType() > ICElement.C_UNIT) { return null; } final ICElementDelta[] children = delta.getAffectedChildren(); if (children == null || children.length == 0) { return null; } for (ICElementDelta element2 : children) { final ICElementDelta d = findElement(unit, element2); if (d != null) { return d; } } return null; }
private void processDelta(ICElementDelta delta, Set<IResource> handled) throws CoreException { final int flags = delta.getFlags(); final boolean hasChildren = (flags & ICElementDelta.F_CHILDREN) != 0; if (hasChildren) { for (ICElementDelta child : delta.getAffectedChildren()) { processDelta(child, handled); } } final ICElement element = delta.getElement(); switch (element.getElementType()) { case ICElement.C_UNIT: ITranslationUnit tu = (ITranslationUnit) element; if (!tu.isWorkingCopy()) { handled.add(element.getResource()); switch (delta.getKind()) { case ICElementDelta.CHANGED: if ((flags & ICElementDelta.F_CONTENT) != 0) { fChanged.add(tu); } break; case ICElementDelta.ADDED: fChanged.add(tu); break; case ICElementDelta.REMOVED: fRemoved.add(tu); break; } } break; case ICElement.C_CCONTAINER: ICContainer folder = (ICContainer) element; if (delta.getKind() == ICElementDelta.ADDED) { handled.add(element.getResource()); collectSources(folder, fChanged); } break; } if (!sSuppressPotentialTUs) { // Always look at the children of the resource delta (bug 343538) final IResourceDelta[] rDeltas = delta.getResourceDeltas(); processResourceDelta(rDeltas, element, handled); } }