private boolean isClassFile(IResourceDelta delta) { return delta.getFullPath().toPortableString().endsWith(".class"); } }
private void traverseForDirectories(DirectoryNode directoryNode, IResourceDelta matchedDelta) { if (directoryNode.classFiles != null) { // annotation base reached, switch strategy: traverseForClassFiles(directoryNode.classFiles, matchedDelta, matchedDelta.getFullPath().segmentCount()); // ignore further children, if we already have classFiles (i.e., nested annotation bases are tolerated but ignored). } else if (directoryNode.children != null) { for (IResourceDelta child : matchedDelta.getAffectedChildren()) { DirectoryNode childDir = directoryNode.children.get(child.getFullPath()); if (childDir != null) { if (child.getKind() == IResourceDelta.REMOVED) directoryNode.children.remove(child.getFullPath()); else traverseForDirectories(childDir, child); } } } if (directoryNode.isEmpty()) directoryNode.parent.children.remove(matchedDelta.getFullPath()); }
private void traverseForDirectories(DirectoryNode directoryNode, IResourceDelta matchedDelta) { if (directoryNode.classFiles != null) { // annotation base reached, switch strategy: traverseForClassFiles(directoryNode.classFiles, matchedDelta, matchedDelta.getFullPath().segmentCount()); // ignore further children, if we already have classFiles (i.e., nested annotation bases are tolerated but ignored). } else if (directoryNode.children != null) { for (IResourceDelta child : matchedDelta.getAffectedChildren()) { DirectoryNode childDir = directoryNode.children.get(child.getFullPath()); if (childDir != null) { if (child.getKind() == IResourceDelta.REMOVED) directoryNode.children.remove(child.getFullPath()); else traverseForDirectories(childDir, child); } } } if (directoryNode.isEmpty()) directoryNode.parent.children.remove(matchedDelta.getFullPath()); }
private void traverseForDirectories(DirectoryNode directoryNode, IResourceDelta matchedDelta) { if (directoryNode.classFiles != null) { // annotation base reached, switch strategy: traverseForClassFiles(directoryNode.classFiles, matchedDelta, matchedDelta.getFullPath().segmentCount()); // ignore further children, if we already have classFiles (i.e., nested annotation bases are tolerated but ignored). } else if (directoryNode.children != null) { for (IResourceDelta child : matchedDelta.getAffectedChildren()) { DirectoryNode childDir = directoryNode.children.get(child.getFullPath()); if (childDir != null) { if (child.getKind() == IResourceDelta.REMOVED) directoryNode.children.remove(child.getFullPath()); else traverseForDirectories(childDir, child); } } } if (directoryNode.isEmpty()) directoryNode.parent.children.remove(matchedDelta.getFullPath()); }
/** * Listen to resource change events concerning external annotations, that potentially affect a cached ClassFile. */ @Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta != null && delta.getFullPath().isRoot() && this.tree.children != null) { for (IResourceDelta child : delta.getAffectedChildren()) { DirectoryNode directoryNode = this.tree.children.get(child.getFullPath()); if (directoryNode != null) traverseForDirectories(directoryNode, child); } } }
/** * Listen to resource change events concerning external annotations, that potentially affect a cached ClassFile. */ @Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta != null && delta.getFullPath().isRoot() && this.tree.children != null) { for (IResourceDelta child : delta.getAffectedChildren()) { DirectoryNode directoryNode = this.tree.children.get(child.getFullPath()); if (directoryNode != null) traverseForDirectories(directoryNode, child); } } }
/** * Listen to resource change events concerning external annotations, that potentially affect a cached ClassFile. */ @Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta != null && delta.getFullPath().isRoot() && this.tree.children != null) { for (IResourceDelta child : delta.getAffectedChildren()) { DirectoryNode directoryNode = this.tree.children.get(child.getFullPath()); if (directoryNode != null) traverseForDirectories(directoryNode, child); } } }
@Override public IResourceDelta findMember(IPath path) { int segmentCount = path.segmentCount(); if (segmentCount == 0) return this; //iterate over the path and find matching child delta ResourceDelta current = this; segments: for (int i = 0; i < segmentCount; i++) { IResourceDelta[] currentChildren = current.children; for (int j = 0, jmax = currentChildren.length; j < jmax; j++) { if (currentChildren[j].getFullPath().lastSegment().equals(path.segment(i))) { current = (ResourceDelta) currentChildren[j]; continue segments; } } //matching child not found, return return null; } return current; }
@Override public IResourceDelta findMember(IPath path) { int segmentCount = path.segmentCount(); if (segmentCount == 0) return this; //iterate over the path and find matching child delta ResourceDelta current = this; segments: for (int i = 0; i < segmentCount; i++) { IResourceDelta[] currentChildren = current.children; for (int j = 0, jmax = currentChildren.length; j < jmax; j++) { if (currentChildren[j].getFullPath().lastSegment().equals(path.segment(i))) { current = (ResourceDelta) currentChildren[j]; continue segments; } } //matching child not found, return return null; } return current; }
@Override public IResourceDelta findMember(IPath path) { int segmentCount = path.segmentCount(); if (segmentCount == 0) return this; //iterate over the path and find matching child delta ResourceDelta current = this; segments: for (int i = 0; i < segmentCount; i++) { IResourceDelta[] currentChildren = current.children; for (int j = 0, jmax = currentChildren.length; j < jmax; j++) { if (currentChildren[j].getFullPath().lastSegment().equals(path.segment(i))) { current = (ResourceDelta) currentChildren[j]; continue segments; } } //matching child not found, return return null; } return current; }
private void visitAdded(IResourceDelta delta) { // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3553 // quick check if it's even JSP related to improve // performance // checking name from the delta before getting // resource because it's lighter int numSegments = delta.getFullPath().segmentCount(); String filename = delta.getFullPath().segment(numSegments - 1); if (getJspContentType().isAssociatedWith(filename)) { IResource r = delta.getResource(); if (r != null && r.exists() && r.getType() == IResource.FILE) { this.jspFiles.put(r.getFullPath(), r); } } }
private void traverseForClassFiles(Map<IPath, ClassFile> classFiles, IResourceDelta matchedDelta, int baseDepth) { for (IResourceDelta delta : matchedDelta.getAffectedChildren()) { IPath deltaRelativePath = delta.getFullPath().removeFirstSegments(baseDepth); ClassFile classFile = classFiles.remove(deltaRelativePath); if (classFile != null) { try { // the payload: unload the class file corresponding to a changed external annotation file: classFile.closeAndRemoveFromJarTypeCache(); } catch (JavaModelException e) { Util.log(e, "Failed to close ClassFile "+classFile.name); //$NON-NLS-1$ } } else { traverseForClassFiles(classFiles, delta, baseDepth); } } } }
private void traverseForClassFiles(Map<IPath, ClassFile> classFiles, IResourceDelta matchedDelta, int baseDepth) { for (IResourceDelta delta : matchedDelta.getAffectedChildren()) { IPath deltaRelativePath = delta.getFullPath().removeFirstSegments(baseDepth); ClassFile classFile = classFiles.remove(deltaRelativePath); if (classFile != null) { try { // the payload: unload the class file corresponding to a changed external annotation file: classFile.closeAndRemoveFromJarTypeCache(); } catch (JavaModelException e) { Util.log(e, "Failed to close ClassFile "+classFile.name); //$NON-NLS-1$ } } else { traverseForClassFiles(classFiles, delta, baseDepth); } } } }
private void traverseForClassFiles(Map<IPath, ClassFile> classFiles, IResourceDelta matchedDelta, int baseDepth) { for (IResourceDelta delta : matchedDelta.getAffectedChildren()) { IPath deltaRelativePath = delta.getFullPath().removeFirstSegments(baseDepth); ClassFile classFile = classFiles.remove(deltaRelativePath); if (classFile != null) { try { // the payload: unload the class file corresponding to a changed external annotation file: classFile.closeAndRemoveFromJarTypeCache(); } catch (JavaModelException e) { Util.log(e, "Failed to close ClassFile "+classFile.name); //$NON-NLS-1$ } } else { traverseForClassFiles(classFiles, delta, baseDepth); } } } }
public boolean visit(IResourceDelta delta) { boolean visitChildren = false; initDefConfigPath(); if (defConfigPath != null) { IPath deltaPath = delta.getFullPath(); if (deltaPath != null) { if (defConfigPath.equals(deltaPath)) { locateProviders(); } else if (deltaPath.isPrefixOf(defConfigPath)) { visitChildren = true; } } } else { locateProviders(); } return visitChildren; }
return false; // added/removed binary folder should not make it here (classpath change), but handle anyways int segmentCount = binaryDelta.getFullPath().segmentCount();
return false; // added/removed binary folder should not make it here (classpath change), but handle anyways int segmentCount = binaryDelta.getFullPath().segmentCount();
return false; // added/removed binary folder should not make it here (classpath change), but handle anyways int segmentCount = binaryDelta.getFullPath().segmentCount();
return false; // added/removed binary folder should not make it here (classpath change), but handle anyways int segmentCount = binaryDelta.getFullPath().segmentCount();
return false; // added/removed binary folder should not make it here (classpath change), but handle anyways int segmentCount = binaryDelta.getFullPath().segmentCount();