View | Details | Raw Unified | Return to bug 307040 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java (-1 / +10 lines)
Lines 502-508 Link Here
502
	fixSupertypeBindings();
502
	fixSupertypeBindings();
503
503
504
	int objectIndex = -1;
504
	int objectIndex = -1;
505
	IProgressMonitor progressMonitor = this.builder.hierarchy.progressMonitor;
505
	for (int current = this.typeIndex; current >= 0; current--) {
506
	for (int current = this.typeIndex; current >= 0; current--) {
507
		if (progressMonitor != null && progressMonitor.isCanceled())
508
			throw new OperationCanceledException();
509
		
506
		ReferenceBinding typeBinding = this.typeBindings[current];
510
		ReferenceBinding typeBinding = this.typeBindings[current];
507
511
508
		// java.lang.Object treated at the end
512
		// java.lang.Object treated at the end
Lines 756-763 Link Here
756
			CompilationUnitDeclaration parsedUnit = parsedUnits[i];
760
			CompilationUnitDeclaration parsedUnit = parsedUnits[i];
757
			if (parsedUnit != null) {
761
			if (parsedUnit != null) {
758
				try {
762
				try {
759
					if (hasLocalType[i]) // NB: no-op if method bodies have been already parsed
763
					if (hasLocalType[i]) { // NB: no-op if method bodies have been already parsed
764
						if (monitor != null && monitor.isCanceled())
765
							throw new OperationCanceledException();
760
						parser.getMethodBodies(parsedUnit);
766
						parser.getMethodBodies(parsedUnit);
767
					}
761
				} catch (AbortCompilation e) {
768
				} catch (AbortCompilation e) {
762
					// classpath problem for this type: don't try to resolve (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49809)
769
					// classpath problem for this type: don't try to resolve (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49809)
763
					hasLocalType[i] = false;
770
					hasLocalType[i] = false;
Lines 780-785 Link Here
780
			if (parsedUnit != null) {
787
			if (parsedUnit != null) {
781
				boolean containsLocalType = hasLocalType[i];
788
				boolean containsLocalType = hasLocalType[i];
782
				if (containsLocalType) {
789
				if (containsLocalType) {
790
					if (monitor != null && monitor.isCanceled())
791
						throw new OperationCanceledException();
783
					parsedUnit.scope.faultInTypes();
792
					parsedUnit.scope.faultInTypes();
784
					parsedUnit.resolve();
793
					parsedUnit.resolve();
785
				}
794
				}
(-)search/org/eclipse/jdt/core/search/SearchPattern.java (-2 / +12 lines)
Lines 24-29 Link Here
24
import org.eclipse.jdt.internal.core.LocalVariable;
24
import org.eclipse.jdt.internal.core.LocalVariable;
25
import org.eclipse.jdt.internal.core.index.EntryResult;
25
import org.eclipse.jdt.internal.core.index.EntryResult;
26
import org.eclipse.jdt.internal.core.index.Index;
26
import org.eclipse.jdt.internal.core.index.Index;
27
import org.eclipse.jdt.internal.core.search.HierarchyScope;
27
import org.eclipse.jdt.internal.core.search.IndexQueryRequestor;
28
import org.eclipse.jdt.internal.core.search.IndexQueryRequestor;
28
import org.eclipse.jdt.internal.core.search.JavaSearchScope;
29
import org.eclipse.jdt.internal.core.search.JavaSearchScope;
29
import org.eclipse.jdt.internal.core.search.StringOperation;
30
import org.eclipse.jdt.internal.core.search.StringOperation;
Lines 275-280 Link Here
275
 * @nooverride This method is not intended to be re-implemented or extended by clients.
276
 * @nooverride This method is not intended to be re-implemented or extended by clients.
276
 */
277
 */
277
public void acceptMatch(String relativePath, String containerPath, char separator, SearchPattern pattern, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope) {
278
public void acceptMatch(String relativePath, String containerPath, char separator, SearchPattern pattern, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope) {
279
	acceptMatch(relativePath, containerPath, separator, pattern, requestor, participant, scope, null);
280
}
281
/**
282
 * @noreference This method is not intended to be referenced by clients.
283
 * @nooverride This method is not intended to be re-implemented or extended by clients.
284
 */
285
public void acceptMatch(String relativePath, String containerPath, char separator, SearchPattern pattern, IndexQueryRequestor requestor, SearchParticipant participant, IJavaSearchScope scope, IProgressMonitor monitor) {
278
286
279
	if (scope instanceof JavaSearchScope) {
287
	if (scope instanceof JavaSearchScope) {
280
		JavaSearchScope javaSearchScope = (JavaSearchScope) scope;
288
		JavaSearchScope javaSearchScope = (JavaSearchScope) scope;
Lines 295-301 Link Here
295
		buffer.append(separator);
303
		buffer.append(separator);
296
		buffer.append(relativePath);
304
		buffer.append(relativePath);
297
		String documentPath = buffer.toString();
305
		String documentPath = buffer.toString();
298
		if (scope.encloses(documentPath))
306
		boolean encloses = (scope instanceof HierarchyScope) ? ((HierarchyScope)scope).encloses(documentPath, monitor)
307
							: scope.encloses(documentPath);
308
		if (encloses) 
299
			if (!requestor.acceptIndexMatch(documentPath, pattern, participant, null))
309
			if (!requestor.acceptIndexMatch(documentPath, pattern, participant, null))
300
				throw new OperationCanceledException();
310
				throw new OperationCanceledException();
301
311
Lines 2304-2310 Link Here
2304
				// TODO (kent) some clients may not need the document names
2314
				// TODO (kent) some clients may not need the document names
2305
				String[] names = entry.getDocumentNames(index);
2315
				String[] names = entry.getDocumentNames(index);
2306
				for (int j = 0, n = names.length; j < n; j++)
2316
				for (int j = 0, n = names.length; j < n; j++)
2307
					acceptMatch(names[j], containerPath, separator, decodedResult, requestor, participant, scope);
2317
					acceptMatch(names[j], containerPath, separator, decodedResult, requestor, participant, scope, monitor);
2308
			}
2318
			}
2309
		}
2319
		}
2310
	} finally {
2320
	} finally {
(-)search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java (-2 / +11 lines)
Lines 651-657 Link Here
651
			if (copies != null) {
651
			if (copies != null) {
652
				for (int i = 0; i < copiesLength; i++) {
652
				for (int i = 0; i < copiesLength; i++) {
653
					final ICompilationUnit workingCopy = copies[i];
653
					final ICompilationUnit workingCopy = copies[i];
654
					if (!scope.encloses(workingCopy)) continue;
654
					if (scope instanceof HierarchyScope) {
655
						if (!((HierarchyScope)scope).encloses(workingCopy, progressMonitor)) continue;
656
					} else {
657
						if (!scope.encloses(workingCopy)) continue;
658
					}
659
					
655
					final String path = workingCopy.getPath().toString();
660
					final String path = workingCopy.getPath().toString();
656
					if (workingCopy.isConsistent()) {
661
					if (workingCopy.isConsistent()) {
657
						IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations();
662
						IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations();
Lines 1140-1146 Link Here
1140
			if (copies != null) {
1145
			if (copies != null) {
1141
				for (int i = 0; i < copiesLength; i++) {
1146
				for (int i = 0; i < copiesLength; i++) {
1142
					final ICompilationUnit workingCopy = copies[i];
1147
					final ICompilationUnit workingCopy = copies[i];
1143
					if (!scope.encloses(workingCopy)) continue;
1148
					if (scope instanceof HierarchyScope) {
1149
						if (!((HierarchyScope)scope).encloses(workingCopy, progressMonitor)) continue;
1150
					} else {
1151
						if (!scope.encloses(workingCopy)) continue;
1152
					}
1144
					final String path = workingCopy.getPath().toString();
1153
					final String path = workingCopy.getPath().toString();
1145
					if (workingCopy.isConsistent()) {
1154
					if (workingCopy.isConsistent()) {
1146
						IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations();
1155
						IPackageDeclaration[] packageDeclarations = workingCopy.getPackageDeclarations();
(-)search/org/eclipse/jdt/internal/core/search/HierarchyScope.java (-10 / +23 lines)
Lines 18-23 Link Here
18
18
19
import org.eclipse.core.resources.*;
19
import org.eclipse.core.resources.*;
20
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
23
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
23
import org.eclipse.jdt.internal.core.*;
24
import org.eclipse.jdt.internal.core.*;
Lines 259-271 Link Here
259
	 * @see IJavaSearchScope#encloses(String)
260
	 * @see IJavaSearchScope#encloses(String)
260
	 */
261
	 */
261
	public boolean encloses(String resourcePath) {
262
	public boolean encloses(String resourcePath) {
263
		return encloses(resourcePath, null);
264
	}
265
	public boolean encloses(String resourcePath, IProgressMonitor progressMonitor) {
262
		if (this.hierarchy == null) {
266
		if (this.hierarchy == null) {
263
			if (resourcePath.equals(this.focusPath)) {
267
			if (resourcePath.equals(this.focusPath)) {
264
				return true;
268
				return true;
265
			} else {
269
			} else {
266
				if (this.needsRefresh) {
270
				if (this.needsRefresh) {
267
					try {
271
					try {
268
						initialize();
272
						initialize(progressMonitor);
269
					} catch (JavaModelException e) {
273
					} catch (JavaModelException e) {
270
						return false;
274
						return false;
271
					}
275
					}
Lines 278-284 Link Here
278
		}
282
		}
279
		if (this.needsRefresh) {
283
		if (this.needsRefresh) {
280
			try {
284
			try {
281
				refresh();
285
				refresh(progressMonitor);
282
			} catch(JavaModelException e) {
286
			} catch(JavaModelException e) {
283
				return false;
287
				return false;
284
			}
288
			}
Lines 305-323 Link Here
305
	public boolean enclosesFineGrained(IJavaElement element) {
309
	public boolean enclosesFineGrained(IJavaElement element) {
306
		if ((this.subTypes == null) && this.allowMemberAndEnclosingTypes) 
310
		if ((this.subTypes == null) && this.allowMemberAndEnclosingTypes) 
307
			return true; // no fine grained checking requested
311
			return true; // no fine grained checking requested
308
		return encloses(element);
312
		return encloses(element, null);
309
	}
313
	}
310
	/* (non-Javadoc)
314
	/* (non-Javadoc)
311
	 * @see IJavaSearchScope#encloses(IJavaElement)
315
	 * @see IJavaSearchScope#encloses(IJavaElement)
312
	 */
316
	 */
313
	public boolean encloses(IJavaElement element) {
317
	public boolean encloses(IJavaElement element) {
318
		return encloses(element, null);
319
	}
320
	public boolean encloses(IJavaElement element, IProgressMonitor progressMonitor) {
314
		if (this.hierarchy == null) {
321
		if (this.hierarchy == null) {
315
			if (this.includeFocusType && this.focusType.equals(element.getAncestor(IJavaElement.TYPE))) {
322
			if (this.includeFocusType && this.focusType.equals(element.getAncestor(IJavaElement.TYPE))) {
316
				return true;
323
				return true;
317
			} else {
324
			} else {
318
				if (this.needsRefresh) {
325
				if (this.needsRefresh) {
319
					try {
326
					try {
320
						initialize();
327
						initialize(progressMonitor);
321
					} catch (JavaModelException e) {
328
					} catch (JavaModelException e) {
322
						return false;
329
						return false;
323
					}
330
					}
Lines 330-336 Link Here
330
		}
337
		}
331
		if (this.needsRefresh) {
338
		if (this.needsRefresh) {
332
			try {
339
			try {
333
				refresh();
340
				refresh(progressMonitor);
334
			} catch(JavaModelException e) {
341
			} catch(JavaModelException e) {
335
				return false;
342
				return false;
336
			}
343
			}
Lines 409-415 Link Here
409
	public IPath[] enclosingProjectsAndJars() {
416
	public IPath[] enclosingProjectsAndJars() {
410
		if (this.needsRefresh) {
417
		if (this.needsRefresh) {
411
			try {
418
			try {
412
				refresh();
419
				refresh(null);
413
			} catch(JavaModelException e) {
420
			} catch(JavaModelException e) {
414
				return new IPath[0];
421
				return new IPath[0];
415
			}
422
			}
Lines 417-434 Link Here
417
		return this.enclosingProjectsAndJars;
424
		return this.enclosingProjectsAndJars;
418
	}
425
	}
419
	protected void initialize() throws JavaModelException {
426
	protected void initialize() throws JavaModelException {
427
		initialize(null);
428
	}
429
	protected void initialize(IProgressMonitor progressMonitor) throws JavaModelException {
420
		this.resourcePaths = new HashSet();
430
		this.resourcePaths = new HashSet();
421
		this.elements = new IResource[5];
431
		this.elements = new IResource[5];
422
		this.elementCount = 0;
432
		this.elementCount = 0;
423
		this.needsRefresh = false;
433
		this.needsRefresh = false;
424
		if (this.hierarchy == null) {
434
		if (this.hierarchy == null) {
425
			if (this.javaProject != null) {
435
			if (this.javaProject != null) {
426
				this.hierarchy = this.focusType.newTypeHierarchy(this.javaProject, this.owner, null);
436
				this.hierarchy = this.focusType.newTypeHierarchy(this.javaProject, this.owner, progressMonitor);
427
			} else {
437
			} else {
428
				this.hierarchy = this.focusType.newTypeHierarchy(this.owner, null);
438
				this.hierarchy = this.focusType.newTypeHierarchy(this.owner, progressMonitor);
429
			}
439
			}
430
		} else {
440
		} else {
431
			this.hierarchy.refresh(null);
441
			this.hierarchy.refresh(progressMonitor);
432
		}
442
		}
433
		buildResourceVector();
443
		buildResourceVector();
434
	}
444
	}
Lines 440-447 Link Here
440
		this.needsRefresh = this.hierarchy == null ? false : ((TypeHierarchy)this.hierarchy).isAffected(delta, eventType);
450
		this.needsRefresh = this.hierarchy == null ? false : ((TypeHierarchy)this.hierarchy).isAffected(delta, eventType);
441
	}
451
	}
442
	protected void refresh() throws JavaModelException {
452
	protected void refresh() throws JavaModelException {
453
		refresh(null);
454
	}
455
	protected void refresh(IProgressMonitor progressMonitor) throws JavaModelException {
443
		if (this.hierarchy != null) {
456
		if (this.hierarchy != null) {
444
			initialize();
457
			initialize(progressMonitor);
445
		}
458
		}
446
	}
459
	}
447
	public String toString() {
460
	public String toString() {
(-)search/org/eclipse/jdt/internal/core/search/matching/IntersectingPattern.java (-1 / +1 lines)
Lines 71-77 Link Here
71
	Object[] names = intersectedNames.values;
71
	Object[] names = intersectedNames.values;
72
	for (int i = 0, l = names.length; i < l; i++)
72
	for (int i = 0, l = names.length; i < l; i++)
73
		if (names[i] != null)
73
		if (names[i] != null)
74
			acceptMatch((String) names[i], containerPath, separator, null/*no pattern*/, requestor, participant, scope); // AndPatterns cannot provide the decoded result
74
			acceptMatch((String) names[i], containerPath, separator, null/*no pattern*/, requestor, participant, scope, progressMonitor); // AndPatterns cannot provide the decoded result
75
}
75
}
76
/**
76
/**
77
 * Returns whether another query must be done.
77
 * Returns whether another query must be done.
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-1 / +7 lines)
Lines 725-731 Link Here
725
	return classFile.getType();
725
	return classFile.getType();
726
}
726
}
727
protected boolean encloses(IJavaElement element) {
727
protected boolean encloses(IJavaElement element) {
728
	return element != null && this.scope.encloses(element);
728
	if (element != null) {
729
		if (this.scope instanceof HierarchyScope)
730
			return ((HierarchyScope)this.scope).encloses(element, this.progressMonitor);
731
		else 
732
			return this.scope.encloses(element);
733
	}
734
	return false;
729
}
735
}
730
/* (non-Javadoc)
736
/* (non-Javadoc)
731
 * Return info about last type argument of a parameterized type reference.
737
 * Return info about last type argument of a parameterized type reference.
(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java (-1 / +1 lines)
Lines 666-672 Link Here
666
		}
666
		}
667
		ProgressCounter counter = new ProgressCounter();
667
		ProgressCounter counter = new ProgressCounter();
668
		type.newTypeHierarchy(counter);
668
		type.newTypeHierarchy(counter);
669
		assertEquals("Unexpected work count", 76, counter.count);
669
		assertEquals("Unexpected work count", 85, counter.count);
670
	} finally {
670
	} finally {
671
		deleteProjects(new String[] {"P1", "P2", "P3"});
671
		deleteProjects(new String[] {"P1", "P2", "P3"});
672
	}
672
	}

Return to bug 307040