### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.92 diff -u -r1.92 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 11 Feb 2010 17:09:18 -0000 1.92 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 29 Apr 2010 06:53:48 -0000 @@ -502,7 +502,11 @@ fixSupertypeBindings(); int objectIndex = -1; + IProgressMonitor progressMonitor = this.builder.hierarchy.progressMonitor; for (int current = this.typeIndex; current >= 0; current--) { + if (progressMonitor != null && progressMonitor.isCanceled()) + throw new OperationCanceledException(); + ReferenceBinding typeBinding = this.typeBindings[current]; // java.lang.Object treated at the end @@ -756,8 +760,11 @@ CompilationUnitDeclaration parsedUnit = parsedUnits[i]; if (parsedUnit != null) { try { - if (hasLocalType[i]) // NB: no-op if method bodies have been already parsed + if (hasLocalType[i]) { // NB: no-op if method bodies have been already parsed + if (monitor != null && monitor.isCanceled()) + throw new OperationCanceledException(); parser.getMethodBodies(parsedUnit); + } } catch (AbortCompilation e) { // classpath problem for this type: don't try to resolve (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49809) hasLocalType[i] = false; @@ -780,6 +787,8 @@ if (parsedUnit != null) { boolean containsLocalType = hasLocalType[i]; if (containsLocalType) { + if (monitor != null && monitor.isCanceled()) + throw new OperationCanceledException(); parsedUnit.scope.faultInTypes(); parsedUnit.resolve(); } Index: search/org/eclipse/jdt/core/search/SearchPattern.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java,v retrieving revision 1.83 diff -u -r1.83 SearchPattern.java --- search/org/eclipse/jdt/core/search/SearchPattern.java 1 Apr 2010 09:28:21 -0000 1.83 +++ search/org/eclipse/jdt/core/search/SearchPattern.java 29 Apr 2010 06:54:07 -0000 @@ -24,6 +24,7 @@ import org.eclipse.jdt.internal.core.LocalVariable; import org.eclipse.jdt.internal.core.index.EntryResult; import org.eclipse.jdt.internal.core.index.Index; +import org.eclipse.jdt.internal.core.search.HierarchyScope; import org.eclipse.jdt.internal.core.search.IndexQueryRequestor; import org.eclipse.jdt.internal.core.search.JavaSearchScope; import org.eclipse.jdt.internal.core.search.StringOperation; @@ -275,6 +276,13 @@ * @nooverride This method is not intended to be re-implemented or extended by clients. */ public void acceptMatch(String relativePath, String containerPath, char separator, SearchPattern pattern, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope) { + acceptMatch(relativePath, containerPath, separator, pattern, requestor, participant, scope, null); +} +/** + * @noreference This method is not intended to be referenced by clients. + * @nooverride This method is not intended to be re-implemented or extended by clients. + */ +public void acceptMatch(String relativePath, String containerPath, char separator, SearchPattern pattern, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor monitor) { if (scope instanceof JavaSearchScope) { JavaSearchScope javaSearchScope = (JavaSearchScope) scope; @@ -295,7 +303,9 @@ buffer.append(separator); buffer.append(relativePath); String documentPath = buffer.toString(); - if (scope.encloses(documentPath)) + boolean encloses = (scope instanceof HierarchyScope) ? ((HierarchyScope)scope).encloses(documentPath, monitor) + : scope.encloses(documentPath); + if (encloses) if (!requestor.acceptIndexMatch(documentPath, pattern, participant, null)) throw new OperationCanceledException(); @@ -2304,7 +2314,7 @@ // TODO (kent) some clients may not need the document names String[] names = entry.getDocumentNames(index); for (int j = 0, n = names.length; j < n; j++) - acceptMatch(names[j], containerPath, separator, decodedResult, requestor, participant, scope); + acceptMatch(names[j], containerPath, separator, decodedResult, requestor, participant, scope, monitor); } } } finally { Index: search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java,v retrieving revision 1.64 diff -u -r1.64 BasicSearchEngine.java --- search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 16 Mar 2010 13:39:54 -0000 1.64 +++ search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 29 Apr 2010 06:54:17 -0000 @@ -651,7 +651,12 @@ if (copies != null) { for (int i = 0; i < copiesLength; i++) { final ICompilationUnit workingCopy = copies[i]; - if (!scope.encloses(workingCopy)) continue; + if (scope instanceof HierarchyScope) { + if (!((HierarchyScope)scope).encloses(workingCopy, progressMonitor)) continue; + } else { + if (!scope.encloses(workingCopy)) continue; + } + final String path = workingCopy.getPath().toString(); if (workingCopy.isConsistent()) { IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations(); @@ -1140,7 +1145,11 @@ if (copies != null) { for (int i = 0; i < copiesLength; i++) { final ICompilationUnit workingCopy = copies[i]; - if (!scope.encloses(workingCopy)) continue; + if (scope instanceof HierarchyScope) { + if (!((HierarchyScope)scope).encloses(workingCopy, progressMonitor)) continue; + } else { + if (!scope.encloses(workingCopy)) continue; + } final String path = workingCopy.getPath().toString(); if (workingCopy.isConsistent()) { IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations(); Index: search/org/eclipse/jdt/internal/core/search/HierarchyScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java,v retrieving revision 1.49 diff -u -r1.49 HierarchyScope.java --- search/org/eclipse/jdt/internal/core/search/HierarchyScope.java 14 Jan 2010 14:24:02 -0000 1.49 +++ search/org/eclipse/jdt/internal/core/search/HierarchyScope.java 29 Apr 2010 06:54:19 -0000 @@ -18,6 +18,7 @@ import org.eclipse.core.resources.*; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.*; import org.eclipse.jdt.internal.compiler.util.SuffixConstants; import org.eclipse.jdt.internal.core.*; @@ -259,13 +260,16 @@ * @see IJavaSearchScope#encloses(String) */ public boolean encloses(String resourcePath) { + return encloses(resourcePath, null); + } + public boolean encloses(String resourcePath, IProgressMonitor progressMonitor) { if (this.hierarchy == null) { if (resourcePath.equals(this.focusPath)) { return true; } else { if (this.needsRefresh) { try { - initialize(); + initialize(progressMonitor); } catch (JavaModelException e) { return false; } @@ -278,7 +282,7 @@ } if (this.needsRefresh) { try { - refresh(); + refresh(progressMonitor); } catch(JavaModelException e) { return false; } @@ -305,19 +309,22 @@ public boolean enclosesFineGrained(IJavaElement element) { if ((this.subTypes == null) && this.allowMemberAndEnclosingTypes) return true; // no fine grained checking requested - return encloses(element); + return encloses(element, null); } /* (non-Javadoc) * @see IJavaSearchScope#encloses(IJavaElement) */ public boolean encloses(IJavaElement element) { + return encloses(element, null); + } + public boolean encloses(IJavaElement element, IProgressMonitor progressMonitor) { if (this.hierarchy == null) { if (this.includeFocusType && this.focusType.equals(element.getAncestor(IJavaElement.TYPE))) { return true; } else { if (this.needsRefresh) { try { - initialize(); + initialize(progressMonitor); } catch (JavaModelException e) { return false; } @@ -330,7 +337,7 @@ } if (this.needsRefresh) { try { - refresh(); + refresh(progressMonitor); } catch(JavaModelException e) { return false; } @@ -409,7 +416,7 @@ public IPath[] enclosingProjectsAndJars() { if (this.needsRefresh) { try { - refresh(); + refresh(null); } catch(JavaModelException e) { return new IPath[0]; } @@ -417,18 +424,21 @@ return this.enclosingProjectsAndJars; } protected void initialize() throws JavaModelException { + initialize(null); + } + protected void initialize(IProgressMonitor progressMonitor) throws JavaModelException { this.resourcePaths = new HashSet(); this.elements = new IResource[5]; this.elementCount = 0; this.needsRefresh = false; if (this.hierarchy == null) { if (this.javaProject != null) { - this.hierarchy = this.focusType.newTypeHierarchy(this.javaProject, this.owner, null); + this.hierarchy = this.focusType.newTypeHierarchy(this.javaProject, this.owner, progressMonitor); } else { - this.hierarchy = this.focusType.newTypeHierarchy(this.owner, null); + this.hierarchy = this.focusType.newTypeHierarchy(this.owner, progressMonitor); } } else { - this.hierarchy.refresh(null); + this.hierarchy.refresh(progressMonitor); } buildResourceVector(); } @@ -440,8 +450,11 @@ this.needsRefresh = this.hierarchy == null ? false : ((TypeHierarchy)this.hierarchy).isAffected(delta, eventType); } protected void refresh() throws JavaModelException { + refresh(null); + } + protected void refresh(IProgressMonitor progressMonitor) throws JavaModelException { if (this.hierarchy != null) { - initialize(); + initialize(progressMonitor); } } public String toString() { Index: search/org/eclipse/jdt/internal/core/search/matching/IntersectingPattern.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/IntersectingPattern.java,v retrieving revision 1.5 diff -u -r1.5 IntersectingPattern.java --- search/org/eclipse/jdt/internal/core/search/matching/IntersectingPattern.java 18 Sep 2008 15:24:57 -0000 1.5 +++ search/org/eclipse/jdt/internal/core/search/matching/IntersectingPattern.java 29 Apr 2010 06:54:19 -0000 @@ -71,7 +71,7 @@ Object[] names = intersectedNames.values; for (int i = 0, l = names.length; i < l; i++) if (names[i] != null) - acceptMatch((String) names[i], containerPath, separator, null/*no pattern*/, requestor, participant, scope); // AndPatterns cannot provide the decoded result + acceptMatch((String) names[i], containerPath, separator, null/*no pattern*/, requestor, participant, scope, progressMonitor); // AndPatterns cannot provide the decoded result } /** * Returns whether another query must be done. Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v retrieving revision 1.330 diff -u -r1.330 MatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 25 Mar 2010 14:31:12 -0000 1.330 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 29 Apr 2010 06:54:33 -0000 @@ -725,7 +725,13 @@ return classFile.getType(); } protected boolean encloses(IJavaElement element) { - return element != null && this.scope.encloses(element); + if (element != null) { + if (this.scope instanceof HierarchyScope) + return ((HierarchyScope)this.scope).encloses(element, this.progressMonitor); + else + return this.scope.encloses(element); + } + return false; } /* (non-Javadoc) * Return info about last type argument of a parameterized type reference. #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.95 diff -u -r1.95 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 17 Sep 2009 17:52:12 -0000 1.95 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 29 Apr 2010 06:55:10 -0000 @@ -666,7 +666,7 @@ } ProgressCounter counter = new ProgressCounter(); type.newTypeHierarchy(counter); - assertEquals("Unexpected work count", 76, counter.count); + assertEquals("Unexpected work count", 85, counter.count); } finally { deleteProjects(new String[] {"P1", "P2", "P3"}); }