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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java (-37 / +33 lines)
Lines 251-257 Link Here
251
 * (regression test for bug 23112 search: need a way to search for references to the implicit non-arg constructor)
251
 * (regression test for bug 23112 search: need a way to search for references to the implicit non-arg constructor)
252
 */
252
 */
253
public void testConstructorReference10() throws CoreException { // was testConstructorReferenceImplicitConstructorCall2
253
public void testConstructorReference10() throws CoreException { // was testConstructorReferenceImplicitConstructorCall2
254
	this.resultCollector.showSynthetic = true;
254
	this.resultCollector.showSynthetic();
255
	search(
255
	search(
256
		"c11.A()",
256
		"c11.A()",
257
		CONSTRUCTOR,
257
		CONSTRUCTOR,
Lines 814-820 Link Here
814
public void testFieldReference03() throws CoreException {
814
public void testFieldReference03() throws CoreException {
815
	IType type = getCompilationUnit("JavaSearch", "src", "q8", "EclipseTest.java").getType("EclipseTest");
815
	IType type = getCompilationUnit("JavaSearch", "src", "q8", "EclipseTest.java").getType("EclipseTest");
816
	IField field = type.getField("test");
816
	IField field = type.getField("test");
817
	this.resultCollector.showPotential = false;
817
	this.resultCollector.showPotential(false);
818
	search(field, REFERENCES, getJavaSearchScope());
818
	search(field, REFERENCES, getJavaSearchScope());
819
	assertSearchResults(
819
	assertSearchResults(
820
		"src/q8/EclipseTest.java void q8.EclipseTest.main(String[]) [test]"
820
		"src/q8/EclipseTest.java void q8.EclipseTest.main(String[]) [test]"
Lines 1124-1130 Link Here
1124
public void testFieldReference20() throws CoreException { // was testFieldReferenceInOutDocComment
1124
public void testFieldReference20() throws CoreException { // was testFieldReferenceInOutDocComment
1125
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
1125
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
1126
	IField field = type.getField("x");
1126
	IField field = type.getField("x");
1127
	this.resultCollector.showInsideDoc = true;
1127
	this.resultCollector.showInsideDoc();
1128
	search(field, REFERENCES, getJavaSearchScope(), this.resultCollector);
1128
	search(field, REFERENCES, getJavaSearchScope(), this.resultCollector);
1129
	assertSearchResults(
1129
	assertSearchResults(
1130
		"src/s4/X.java int s4.X.foo() [x] OUTSIDE_JAVADOC\n" +
1130
		"src/s4/X.java int s4.X.foo() [x] OUTSIDE_JAVADOC\n" +
Lines 1734-1740 Link Here
1734
public void testMethodReference15() throws CoreException { // was testMethodReferenceInOutDocComment
1734
public void testMethodReference15() throws CoreException { // was testMethodReferenceInOutDocComment
1735
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
1735
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
1736
	IMethod method = type.getMethod("foo", new String[] {});
1736
	IMethod method = type.getMethod("foo", new String[] {});
1737
	this.resultCollector.showInsideDoc = true;
1737
	this.resultCollector.showInsideDoc();
1738
	search(method, REFERENCES, getJavaSearchScope(), this.resultCollector);
1738
	search(method, REFERENCES, getJavaSearchScope(), this.resultCollector);
1739
	assertSearchResults(
1739
	assertSearchResults(
1740
		"src/s4/X.java void s4.X.bar() [foo()] INSIDE_JAVADOC\n" +
1740
		"src/s4/X.java void s4.X.bar() [foo()] INSIDE_JAVADOC\n" +
Lines 1759-1765 Link Here
1759
public void testMethodReference17() throws CoreException {
1759
public void testMethodReference17() throws CoreException {
1760
	IType type = getCompilationUnit("JavaSearch/src/b111416/X.java").getType("X");
1760
	IType type = getCompilationUnit("JavaSearch/src/b111416/X.java").getType("X");
1761
	IMethod method = type.getMethod("open", new String[] {"QString;"});
1761
	IMethod method = type.getMethod("open", new String[] {"QString;"});
1762
	this.resultCollector.showAccuracy = true;
1762
	this.resultCollector.showAccuracy(true);
1763
	search(method, REFERENCES, ERASURE_RULE, getJavaSearchScope(), this.resultCollector);
1763
	search(method, REFERENCES, ERASURE_RULE, getJavaSearchScope(), this.resultCollector);
1764
	assertSearchResults(
1764
	assertSearchResults(
1765
		"src/b111416/X.java void b111416.X.foo() [open(\"\")] EXACT_MATCH",
1765
		"src/b111416/X.java void b111416.X.foo() [open(\"\")] EXACT_MATCH",
Lines 1777-1783 Link Here
1777
		.getType("A1").getMethod("m", new String[] {});
1777
		.getType("A1").getMethod("m", new String[] {});
1778
	SearchPattern rightPattern = createPattern(rightMethod, ALL_OCCURRENCES);
1778
	SearchPattern rightPattern = createPattern(rightMethod, ALL_OCCURRENCES);
1779
	SearchPattern orPattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
1779
	SearchPattern orPattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
1780
	this.resultCollector.showAccuracy = true;
1780
	this.resultCollector.showAccuracy(true);
1781
	search(
1781
	search(
1782
		orPattern,
1782
		orPattern,
1783
		getJavaSearchScope(),
1783
		getJavaSearchScope(),
Lines 1868-1874 Link Here
1868
 */
1868
 */
1869
public void testPackageDeclarationBug73551() throws CoreException {
1869
public void testPackageDeclarationBug73551() throws CoreException {
1870
	JavaSearchResultCollector result = new JavaSearchResultCollector();
1870
	JavaSearchResultCollector result = new JavaSearchResultCollector();
1871
	result.showAccuracy = true;
1871
	result.showAccuracy(true);
1872
	IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267");
1872
	IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267");
1873
	search(packDecl, DECLARATIONS, getJavaSearchScope(),  result);
1873
	search(packDecl, DECLARATIONS, getJavaSearchScope(),  result);
1874
	assertSearchResults(
1874
	assertSearchResults(
Lines 1886-1892 Link Here
1886
	try {
1886
	try {
1887
		test = srcRoot.createPackageFragment("b117020", true, null);
1887
		test = srcRoot.createPackageFragment("b117020", true, null);
1888
		JavaSearchResultCollector result = new JavaSearchResultCollector();
1888
		JavaSearchResultCollector result = new JavaSearchResultCollector();
1889
		result.showAccuracy = true;
1889
		result.showAccuracy(true);
1890
		search(test, DECLARATIONS, getJavaSearchScope(),  result);
1890
		search(test, DECLARATIONS, getJavaSearchScope(),  result);
1891
		assertSearchResults(
1891
		assertSearchResults(
1892
			"src/b117020 b117020 EXACT_MATCH",
1892
			"src/b117020 b117020 EXACT_MATCH",
Lines 2145-2151 Link Here
2145
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2145
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2146
2146
2147
		// potential match for a field declaration
2147
		// potential match for a field declaration
2148
		this.resultCollector.showAccuracy = true;
2148
		this.resultCollector.showAccuracy(true);
2149
		search("MissingFieldType.*", FIELD, DECLARATIONS,  getJavaSearchScope());
2149
		search("MissingFieldType.*", FIELD, DECLARATIONS,  getJavaSearchScope());
2150
		assertSearchResults(
2150
		assertSearchResults(
2151
			"AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" +
2151
			"AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" +
Lines 2177-2183 Link Here
2177
	            }
2177
	            }
2178
            }
2178
            }
2179
		};
2179
		};
2180
		collector.showAccuracy = true;
2180
		collector.showAccuracy(true);
2181
		search("*", FIELD, DECLARATIONS,  getJavaSearchScope(), collector);
2181
		search("*", FIELD, DECLARATIONS,  getJavaSearchScope(), collector);
2182
		assertSearchResults(
2182
		assertSearchResults(
2183
			"AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" +
2183
			"AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" +
Lines 2206-2212 Link Here
2206
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2206
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2207
2207
2208
		// potential match for a method declaration
2208
		// potential match for a method declaration
2209
		this.resultCollector.showAccuracy = true;
2209
		this.resultCollector.showAccuracy(true);
2210
		search("MissingArgumentType.foo*", METHOD, DECLARATIONS, getJavaSearchScope());
2210
		search("MissingArgumentType.foo*", METHOD, DECLARATIONS, getJavaSearchScope());
2211
		assertSearchResults(
2211
		assertSearchResults(
2212
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" +
2212
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" +
Lines 2238-2244 Link Here
2238
	            }
2238
	            }
2239
            }
2239
            }
2240
		};
2240
		};
2241
		collector.showAccuracy = true;
2241
		collector.showAccuracy(true);
2242
		search("*", METHOD, DECLARATIONS,  getJavaSearchScope(), collector);
2242
		search("*", METHOD, DECLARATIONS,  getJavaSearchScope(), collector);
2243
		assertSearchResults(
2243
		assertSearchResults(
2244
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" +
2244
			"AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" +
Lines 2268-2274 Link Here
2268
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2268
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2269
2269
2270
		// exact match for a type declaration
2270
		// exact match for a type declaration
2271
		this.resultCollector.showAccuracy = true;
2271
		this.resultCollector.showAccuracy(true);
2272
		search("AbortCompilation.*Missing*", TYPE, DECLARATIONS,  getJavaSearchScope());
2272
		search("AbortCompilation.*Missing*", TYPE, DECLARATIONS,  getJavaSearchScope());
2273
		assertSearchResults(
2273
		assertSearchResults(
2274
			"AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
2274
			"AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
Lines 2291-2297 Link Here
2291
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2291
		JAVA_PROJECT.setRawClasspath(newClasspath, null);
2292
2292
2293
		// exact match for a type declaration
2293
		// exact match for a type declaration
2294
		this.resultCollector.showAccuracy = true;
2294
		this.resultCollector.showAccuracy(true);
2295
		search("Missing*", TYPE, DECLARATIONS,  getJavaSearchScope());
2295
		search("Missing*", TYPE, DECLARATIONS,  getJavaSearchScope());
2296
		assertSearchResults(
2296
		assertSearchResults(
2297
			"AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
2297
			"AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
Lines 2491-2505 Link Here
2491
	IPackageFragmentRoot root = getPackageFragmentRoot("JavaSearch", "test20631.jar");
2491
	IPackageFragmentRoot root = getPackageFragmentRoot("JavaSearch", "test20631.jar");
2492
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});
2492
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});
2493
2493
2494
	search(
2494
	this.resultCollector.showJarFile();
2495
		"Y",
2495
	search("Y", TYPE, DECLARATIONS, scope);
2496
		TYPE,
2497
		DECLARATIONS,
2498
		scope,
2499
		this.resultCollector);
2500
	assertSearchResults(
2496
	assertSearchResults(
2501
		"test20631.jar Y",
2497
		"test20631.jar|X$Y.class X$Y"
2502
		this.resultCollector);
2498
	);
2503
}
2499
}
2504
/**
2500
/**
2505
 * Type declaration using a package scope test.
2501
 * Type declaration using a package scope test.
Lines 2737-2743 Link Here
2737
public void testTypeReference03() throws CoreException {
2733
public void testTypeReference03() throws CoreException {
2738
	SearchPattern pattern = createPattern("x31985", TYPE, REFERENCES, false);
2734
	SearchPattern pattern = createPattern("x31985", TYPE, REFERENCES, false);
2739
2735
2740
	this.resultCollector.showAccuracy = true;
2736
	this.resultCollector.showAccuracy(true);
2741
	search(
2737
	search(
2742
		pattern,
2738
		pattern,
2743
		getJavaSearchScope(),
2739
		getJavaSearchScope(),
Lines 2857-2863 Link Here
2857
public void testTypeReference10() throws CoreException { // was testMemberTypeReference
2853
public void testTypeReference10() throws CoreException { // was testMemberTypeReference
2858
	// references to second level member type
2854
	// references to second level member type
2859
2855
2860
	this.resultCollector.showAccuracy = true;
2856
	this.resultCollector.showAccuracy(true);
2861
	search(
2857
	search(
2862
		"BMember",
2858
		"BMember",
2863
		TYPE,
2859
		TYPE,
Lines 2874-2880 Link Here
2874
2870
2875
	// references to first level member type
2871
	// references to first level member type
2876
	this.resultCollector = new JavaSearchResultCollector();
2872
	this.resultCollector = new JavaSearchResultCollector();
2877
	this.resultCollector.showAccuracy = true;
2873
	this.resultCollector.showAccuracy(true);
2878
	search(
2874
	search(
2879
		"AzzMember",
2875
		"AzzMember",
2880
		TYPE,
2876
		TYPE,
Lines 2889-2895 Link Here
2889
2885
2890
	// no reference to a field with same name as member type
2886
	// no reference to a field with same name as member type
2891
	this.resultCollector = new JavaSearchResultCollector();
2887
	this.resultCollector = new JavaSearchResultCollector();
2892
	this.resultCollector.showAccuracy = true;
2888
	this.resultCollector.showAccuracy(true);
2893
	search(
2889
	search(
2894
		"BMember",
2890
		"BMember",
2895
		FIELD,
2891
		FIELD,
Lines 2927-2933 Link Here
2927
		.getType("A")
2923
		.getType("A")
2928
		.getType("Object");
2924
		.getType("Object");
2929
2925
2930
	this.resultCollector.showAccuracy = true;
2926
	this.resultCollector.showAccuracy(true);
2931
	search(
2927
	search(
2932
		type,
2928
		type,
2933
		REFERENCES,
2929
		REFERENCES,
Lines 3136-3142 Link Here
3136
public void testTypeReference24() throws CoreException { // was testTypeReferenceInThrows
3132
public void testTypeReference24() throws CoreException { // was testTypeReferenceInThrows
3137
	IType type = getCompilationUnit("JavaSearch", "src", "a7", "X.java").getType("MyException");
3133
	IType type = getCompilationUnit("JavaSearch", "src", "a7", "X.java").getType("MyException");
3138
3134
3139
	this.resultCollector.showAccuracy = true;
3135
	this.resultCollector.showAccuracy(true);
3140
	search(
3136
	search(
3141
		type,
3137
		type,
3142
		REFERENCES,
3138
		REFERENCES,
Lines 3173-3180 Link Here
3173
 */
3169
 */
3174
public void testTypeReference26() throws CoreException { // was testInnacurateTypeReference2
3170
public void testTypeReference26() throws CoreException { // was testInnacurateTypeReference2
3175
3171
3176
	this.resultCollector.showAccuracy = true;
3172
	this.resultCollector.showAccuracy(true);
3177
	this.resultCollector.showSelection = true;
3173
	this.resultCollector.showSelection();
3178
	search(
3174
	search(
3179
		"p.Zork",
3175
		"p.Zork",
3180
		TYPE,
3176
		TYPE,
Lines 3196-3202 Link Here
3196
public void testTypeReference27() throws CoreException { // was testInnacurateTypeReference3
3192
public void testTypeReference27() throws CoreException { // was testInnacurateTypeReference3
3197
	IType type = getCompilationUnit("JavaSearch", "src", "r3", "A21485.java").getType("A21485");
3193
	IType type = getCompilationUnit("JavaSearch", "src", "r3", "A21485.java").getType("A21485");
3198
3194
3199
	this.resultCollector.showAccuracy = true;
3195
	this.resultCollector.showAccuracy(true);
3200
	search(
3196
	search(
3201
		type,
3197
		type,
3202
		REFERENCES,
3198
		REFERENCES,
Lines 3298-3304 Link Here
3298
public void testTypeReference33() throws CoreException { // was testTypeReferenceWithRecovery
3294
public void testTypeReference33() throws CoreException { // was testTypeReferenceWithRecovery
3299
	IType type = getCompilationUnit("JavaSearch", "src", "e1", "A29366.java").getType("A29366");
3295
	IType type = getCompilationUnit("JavaSearch", "src", "e1", "A29366.java").getType("A29366");
3300
3296
3301
	this.resultCollector.showAccuracy = true;
3297
	this.resultCollector.showAccuracy(true);
3302
	search(
3298
	search(
3303
		type,
3299
		type,
3304
		REFERENCES,
3300
		REFERENCES,
Lines 3315-3321 Link Here
3315
public void testTypeReference34() throws CoreException { // was testTypeReferenceWithProblem
3311
public void testTypeReference34() throws CoreException { // was testTypeReferenceWithProblem
3316
	IType type = getCompilationUnit("JavaSearch", "src", "e6", "A.java").getType("A");
3312
	IType type = getCompilationUnit("JavaSearch", "src", "e6", "A.java").getType("A");
3317
3313
3318
	this.resultCollector.showAccuracy = true;
3314
	this.resultCollector.showAccuracy(true);
3319
	search(
3315
	search(
3320
		"B36479",
3316
		"B36479",
3321
		TYPE,
3317
		TYPE,
Lines 3343-3349 Link Here
3343
3339
3344
		IType type = getCompilationUnit("JavaSearch", "src", "e7", "A.java").getType("A");
3340
		IType type = getCompilationUnit("JavaSearch", "src", "e7", "A.java").getType("A");
3345
3341
3346
		this.resultCollector.showAccuracy = true;
3342
		this.resultCollector.showAccuracy(true);
3347
		search(
3343
		search(
3348
			type,
3344
			type,
3349
			REFERENCES,
3345
			REFERENCES,
Lines 3363-3369 Link Here
3363
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "f2");
3359
	IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "f2");
3364
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});
3360
	IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});
3365
3361
3366
	this.resultCollector.showSelection = true;
3362
	this.resultCollector.showSelection();
3367
	search(
3363
	search(
3368
		"Y",
3364
		"Y",
3369
		TYPE,
3365
		TYPE,
Lines 3384-3390 Link Here
3384
3380
3385
	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
3381
	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
3386
3382
3387
	this.resultCollector.showSelection = true;
3383
	this.resultCollector.showSelection();
3388
	search(
3384
	search(
3389
		localType,
3385
		localType,
3390
		REFERENCES,
3386
		REFERENCES,
Lines 3399-3405 Link Here
3399
 */
3395
 */
3400
public void testTypeReference38() throws CoreException { // was testTypeReferenceInOutDocComment
3396
public void testTypeReference38() throws CoreException { // was testTypeReferenceInOutDocComment
3401
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
3397
	IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X");
3402
	this.resultCollector.showInsideDoc = true;
3398
	this.resultCollector.showInsideDoc();
3403
	search(type, REFERENCES, getJavaSearchScope(), this.resultCollector);
3399
	search(type, REFERENCES, getJavaSearchScope(), this.resultCollector);
3404
	assertSearchResults(
3400
	assertSearchResults(
3405
		"src/s4/X.java void s4.X.bar() [X] INSIDE_JAVADOC\n" +
3401
		"src/s4/X.java void s4.X.bar() [X] INSIDE_JAVADOC\n" +
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-1 / +4 lines)
Lines 433-440 Link Here
433
	protected void addLibraryEntry(String path, boolean exported) throws JavaModelException {
433
	protected void addLibraryEntry(String path, boolean exported) throws JavaModelException {
434
		addLibraryEntry(this.currentProject, new Path(path), null, null, null, null, exported);
434
		addLibraryEntry(this.currentProject, new Path(path), null, null, null, null, exported);
435
	}
435
	}
436
	protected void addLibraryEntry(IJavaProject project, String path) throws JavaModelException {
437
		addLibraryEntry(project, new Path(path), null, null, null, null, false);
438
	}
436
	protected void addLibraryEntry(IJavaProject project, String path, boolean exported) throws JavaModelException {
439
	protected void addLibraryEntry(IJavaProject project, String path, boolean exported) throws JavaModelException {
437
		addLibraryEntry(project, new Path(path), exported);
440
		addLibraryEntry(project, new Path(path), null, null, null, null, exported);
438
	}
441
	}
439
	protected void addLibraryEntry(IJavaProject project, IPath path, boolean exported) throws JavaModelException {
442
	protected void addLibraryEntry(IJavaProject project, IPath path, boolean exported) throws JavaModelException {
440
		addLibraryEntry(project, path, null, null, null, null, exported);
443
		addLibraryEntry(project, path, null, null, null, null, exported);
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchGenericTests.java (-2 / +2 lines)
Lines 32-39 Link Here
32
32
33
	protected void setUp () throws Exception {
33
	protected void setUp () throws Exception {
34
		super.setUp();
34
		super.setUp();
35
		this.resultCollector.showAccuracy = true;
35
		this.resultCollector.showAccuracy(true);
36
		this.resultCollector.showRule = true;
36
		this.resultCollector.showRule();
37
	}
37
	}
38
38
39
	/*
39
	/*
(-)src/org/eclipse/jdt/core/tests/model/SearchTests.java (-1 / +2 lines)
Lines 81-87 Link Here
81
					CharOperation.concatWith(enclosingTypeNames, '$'),
81
					CharOperation.concatWith(enclosingTypeNames, '$'),
82
					simpleTypeName,
82
					simpleTypeName,
83
					'$');
83
					'$');
84
			this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.')));
84
			String qualifiedName = new String(CharOperation.concat(packageName, typeName, '.'));
85
			this.results.addElement(qualifiedName);
85
		}
86
		}
86
		public String toString(){
87
		public String toString(){
87
			int length = this.results.size();
88
			int length = this.results.size();
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-136 / +230 lines)
Lines 37-44 Link Here
37
import org.eclipse.jdt.internal.core.index.Index;
37
import org.eclipse.jdt.internal.core.index.Index;
38
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
38
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
39
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
39
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
40
import org.eclipse.jdt.internal.core.search.matching.AndPattern;
41
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
40
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
41
import org.eclipse.jdt.internal.core.search.matching.AndPattern;
42
import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
42
import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
43
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
43
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
44
import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern;
44
import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern;
Lines 57-62 Link Here
57
	return buildModelTestSuite(JavaSearchBugsTests.class);
57
	return buildModelTestSuite(JavaSearchBugsTests.class);
58
}
58
}
59
static {
59
static {
60
//	org.eclipse.jdt.internal.core.search.processing.JobManager.VERBOSE = true;
60
//	org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
61
//	org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true;
61
//	org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
62
//	org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
62
}
63
}
Lines 130-137 Link Here
130
protected void setUp () throws Exception {
131
protected void setUp () throws Exception {
131
	super.setUp();
132
	super.setUp();
132
	this.resultCollector = new TestCollector();
133
	this.resultCollector = new TestCollector();
133
	this.resultCollector.showInsideDoc = false;
134
	this.resultCollector.showAccuracy(true);
134
	this.resultCollector.showAccuracy = true;
135
}
136
137
/**
138
 * @bug 12044: [search] Reference to package is not found in qualified annotation
139
 * @test Ensure that references to package are also found in qualified annotation
140
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=12044"
141
 */
142
private String[] sourcesBug12044() throws CoreException {
143
	return new String[] {
144
		"Def.java",
145
	    "public class Def {\n" + 
146
	    "	public static final int ONE = 1;\n" + 
147
	    "	public static final int TWO = 2;\n" + 
148
	    "	public static final int THREE = 3;\n" + 
149
	    "}\n",
150
		"Ref.java",
151
	    "public class Ref {\n" +
152
	    "	class Sub {\n" + 
153
	    "		int x = Def.ONE;\n" + 
154
	    "		int getX() {\n" + 
155
	    "			return x;\n" + 
156
	    "		}\n" + 
157
	    "	}\n" + 
158
	    "	void foo(Sub sub) {\n" + 
159
	    "		switch (sub.getX()) {\n" + 
160
	    "			case Def.ONE:\n" + 
161
	    "				break;\n" + 
162
	    "			case Def.TWO:\n" + 
163
	    "				break;\n" + 
164
	    "			case Def.THREE:\n" + 
165
	    "				break;\n" + 
166
	    "		}\n" + 
167
	    "	}\n" + 
168
	    "}\n"
169
	};
170
}
171
static { TESTS_PREFIX = "testBug12044"; }
172
public void testBug12044_no_src() throws CoreException, IOException {
173
	IJavaProject javaProject = null;
174
	try {
175
		javaProject = createJavaProject("b012044", new String[] { "src" }, new String[] {"JCL_LIB" }, "bin");
176
		waitUntilIndexesReady();
177
		String jarPath = getWorkspacePath()+"b012044"+File.separator+"b012044.jar";
178
		createJar(sourcesBug12044(), jarPath);
179
		refresh(javaProject);
180
		String resourcePath = "/b012044/b012044.jar";
181
		addLibraryEntry(javaProject, resourcePath);
182
		waitUntilIndexesReady();
183
		IClassFile classFile = getClassFile("b012044", resourcePath, "", "Def.class");
184
		IField field = classFile.getType().getField("ONE");
185
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject } );
186
		this.resultCollector.showJarFile();
187
		search(field, ALL_OCCURRENCES, scope);
188
		assertSearchResults(
189
		"b012044.jar|Def.class Def.ONE [No source] EXACT_MATCH"
190
		);
191
	}
192
	finally {
193
		if (javaProject != null) {
194
			deleteProject(javaProject);
195
		}
196
	}
197
}
198
public void testBug12044_src_in_zip() throws CoreException, IOException {
199
	IJavaProject javaProject = null;
200
	try {
201
		javaProject = createJavaProject("b012044", new String[] { "src" }, new String[] {"JCL_LIB" }, "bin");
202
		waitUntilIndexesReady();
203
		String path = getWorkspacePath()+"b012044"+File.separator+"b012044";
204
		String jarPath = path+".jar";
205
		createJar(sourcesBug12044(), jarPath);
206
		String zipPath = path+".zip";
207
		Util.createSourceZip(sourcesBug12044(), zipPath);
208
		refresh(javaProject);
209
		String resourcePath = "/b012044/b012044.jar";
210
		String resourceZipPath = "/b012044/b012044.zip";
211
		addLibraryEntry(javaProject, resourcePath, resourceZipPath);
212
		waitUntilIndexesReady();
213
		IClassFile classFile = getClassFile("b012044", resourcePath, "", "Def.class");
214
		IField field = classFile.getType().getField("ONE");
215
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject } );
216
		this.resultCollector.showJarFile();
217
		search(field, ALL_OCCURRENCES, scope);
218
		assertSearchResults(
219
			"b012044.jar|Def.class Def.ONE EXACT_MATCH\n" + 
220
			"b012044.jar|Ref.class void Ref.foo(Ref.Sub) EXACT_MATCH\n" + 
221
			"b012044.jar|Ref$Sub.class Ref$Sub.x EXACT_MATCH"
222
		);
223
	}
224
	finally {
225
		if (javaProject != null) {
226
			deleteProject(javaProject);
227
		}
228
	}
135
}
229
}
136
230
137
/**
231
/**
Lines 775-781 Link Here
775
	);
869
	);
776
}
870
}
777
public void testBug79378b() throws CoreException {
871
public void testBug79378b() throws CoreException {
778
	this.resultCollector.showRule = true;
872
	this.resultCollector.showRule();
779
	this.workingCopies = new ICompilationUnit[1];
873
	this.workingCopies = new ICompilationUnit[1];
780
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79378/A.java",
874
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79378/A.java",
781
		"package b79378;\n" +
875
		"package b79378;\n" +
Lines 1491-1497 Link Here
1491
	);
1585
	);
1492
}
1586
}
1493
public void testBug82208_TYPE() throws CoreException {
1587
public void testBug82208_TYPE() throws CoreException {
1494
	this.resultCollector.showRule = true;
1588
	this.resultCollector.showRule();
1495
	setUpBug82208();
1589
	setUpBug82208();
1496
	search("B82208*", TYPE, ALL_OCCURRENCES);
1590
	search("B82208*", TYPE, ALL_OCCURRENCES);
1497
	assertSearchResults(
1591
	assertSearchResults(
Lines 1502-1508 Link Here
1502
	);
1596
	);
1503
}
1597
}
1504
public void testBug82208_CLASS() throws CoreException {
1598
public void testBug82208_CLASS() throws CoreException {
1505
	this.resultCollector.showRule = true;
1599
	this.resultCollector.showRule();
1506
	setUpBug82208();
1600
	setUpBug82208();
1507
	search("B82208*", CLASS, ALL_OCCURRENCES);
1601
	search("B82208*", CLASS, ALL_OCCURRENCES);
1508
	assertSearchResults(
1602
	assertSearchResults(
Lines 1510-1516 Link Here
1510
	);
1604
	);
1511
}
1605
}
1512
public void testBug82208_INTERFACE() throws CoreException {
1606
public void testBug82208_INTERFACE() throws CoreException {
1513
	this.resultCollector.showRule = true;
1607
	this.resultCollector.showRule();
1514
	setUpBug82208();
1608
	setUpBug82208();
1515
	search("B82208*", INTERFACE, ALL_OCCURRENCES);
1609
	search("B82208*", INTERFACE, ALL_OCCURRENCES);
1516
	assertSearchResults(
1610
	assertSearchResults(
Lines 1518-1524 Link Here
1518
	);
1612
	);
1519
}
1613
}
1520
public void testBug82208_ENUM() throws CoreException {
1614
public void testBug82208_ENUM() throws CoreException {
1521
	this.resultCollector.showRule = true;
1615
	this.resultCollector.showRule();
1522
	setUpBug82208();
1616
	setUpBug82208();
1523
	search("B82208*", ENUM, ALL_OCCURRENCES);
1617
	search("B82208*", ENUM, ALL_OCCURRENCES);
1524
	assertSearchResults(
1618
	assertSearchResults(
Lines 1526-1532 Link Here
1526
	);
1620
	);
1527
}
1621
}
1528
public void testBug82208_ANNOTATION_TYPE() throws CoreException {
1622
public void testBug82208_ANNOTATION_TYPE() throws CoreException {
1529
	this.resultCollector.showRule = true;
1623
	this.resultCollector.showRule();
1530
	setUpBug82208();
1624
	setUpBug82208();
1531
	search("B82208*", ANNOTATION_TYPE, ALL_OCCURRENCES);
1625
	search("B82208*", ANNOTATION_TYPE, ALL_OCCURRENCES);
1532
	assertSearchResults(
1626
	assertSearchResults(
Lines 1534-1540 Link Here
1534
	);
1628
	);
1535
}
1629
}
1536
public void testBug82208_CLASS_AND_INTERFACE() throws CoreException {
1630
public void testBug82208_CLASS_AND_INTERFACE() throws CoreException {
1537
	this.resultCollector.showRule = true;
1631
	this.resultCollector.showRule();
1538
	setUpBug82208();
1632
	setUpBug82208();
1539
	search("B82208*", CLASS_AND_INTERFACE, ALL_OCCURRENCES);
1633
	search("B82208*", CLASS_AND_INTERFACE, ALL_OCCURRENCES);
1540
	assertSearchResults(
1634
	assertSearchResults(
Lines 1543-1549 Link Here
1543
	);
1637
	);
1544
}
1638
}
1545
public void testBug82208_CLASS_AND_ENUMERATION() throws CoreException {
1639
public void testBug82208_CLASS_AND_ENUMERATION() throws CoreException {
1546
	this.resultCollector.showRule = true;
1640
	this.resultCollector.showRule();
1547
	setUpBug82208();
1641
	setUpBug82208();
1548
	search("B82208*", CLASS_AND_ENUM, ALL_OCCURRENCES);
1642
	search("B82208*", CLASS_AND_ENUM, ALL_OCCURRENCES);
1549
	assertSearchResults(
1643
	assertSearchResults(
Lines 1557-1563 Link Here
1557
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012"
1651
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012"
1558
 */
1652
 */
1559
public void testBug82673() throws CoreException {
1653
public void testBug82673() throws CoreException {
1560
	this.resultCollector.showRule = true;
1654
	this.resultCollector.showRule();
1561
	this.workingCopies = new ICompilationUnit[1];
1655
	this.workingCopies = new ICompilationUnit[1];
1562
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82673/Test.java",
1656
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82673/Test.java",
1563
		"package b82673;\n" +
1657
		"package b82673;\n" +
Lines 1590-1596 Link Here
1590
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012"
1684
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012"
1591
 */
1685
 */
1592
public void testBug83012() throws CoreException {
1686
public void testBug83012() throws CoreException {
1593
	this.resultCollector.showRule = true;
1687
	this.resultCollector.showRule();
1594
	this.workingCopies = new ICompilationUnit[1];
1688
	this.workingCopies = new ICompilationUnit[1];
1595
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83012/Test.java",
1689
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83012/Test.java",
1596
		"package b83012;\n" +
1690
		"package b83012;\n" +
Lines 1622-1628 Link Here
1622
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83230"
1716
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83230"
1623
 */
1717
 */
1624
private void setUpBug83230_Explicit() throws CoreException {
1718
private void setUpBug83230_Explicit() throws CoreException {
1625
	this.resultCollector.showRule = true;
1719
	this.resultCollector.showRule();
1626
	this.workingCopies = new ICompilationUnit[1];
1720
	this.workingCopies = new ICompilationUnit[1];
1627
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java",
1721
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java",
1628
		"package b83230;\n" +
1722
		"package b83230;\n" +
Lines 1661-1667 Link Here
1661
	);
1755
	);
1662
}
1756
}
1663
public void testBug83230_Explicit() throws CoreException {
1757
public void testBug83230_Explicit() throws CoreException {
1664
	this.resultCollector.showRule = true;
1758
	this.resultCollector.showRule();
1665
	setUpBug83230_Explicit();
1759
	setUpBug83230_Explicit();
1666
	IMethod method = selectMethod(this.workingCopies[0], "authorName");
1760
	IMethod method = selectMethod(this.workingCopies[0], "authorName");
1667
	search(method, REFERENCES);
1761
	search(method, REFERENCES);
Lines 1676-1682 Link Here
1676
	);
1770
	);
1677
}
1771
}
1678
public void testBug83230_Explicit01() throws CoreException {
1772
public void testBug83230_Explicit01() throws CoreException {
1679
	this.resultCollector.showRule = true;
1773
	this.resultCollector.showRule();
1680
	setUpBug83230_Explicit();
1774
	setUpBug83230_Explicit();
1681
	IMethod method = selectMethod(this.workingCopies[0], "authorName");
1775
	IMethod method = selectMethod(this.workingCopies[0], "authorName");
1682
	search(method, DECLARATIONS);
1776
	search(method, DECLARATIONS);
Lines 1685-1691 Link Here
1685
	);
1779
	);
1686
}
1780
}
1687
public void testBug83230_Explicit02() throws CoreException {
1781
public void testBug83230_Explicit02() throws CoreException {
1688
	this.resultCollector.showRule = true;
1782
	this.resultCollector.showRule();
1689
	setUpBug83230_Explicit();
1783
	setUpBug83230_Explicit();
1690
	IType type = selectType(this.workingCopies[0], "Address");
1784
	IType type = selectType(this.workingCopies[0], "Address");
1691
	search(type, REFERENCES);
1785
	search(type, REFERENCES);
Lines 1695-1701 Link Here
1695
	);
1789
	);
1696
}
1790
}
1697
public void testBug83230_Explicit03() throws CoreException {
1791
public void testBug83230_Explicit03() throws CoreException {
1698
	this.resultCollector.showRule = true;
1792
	this.resultCollector.showRule();
1699
	setUpBug83230_Explicit();
1793
	setUpBug83230_Explicit();
1700
	IMethod method = selectMethod(this.workingCopies[0], "foo");
1794
	IMethod method = selectMethod(this.workingCopies[0], "foo");
1701
	search(method, REFERENCES);
1795
	search(method, REFERENCES);
Lines 1704-1710 Link Here
1704
	);
1798
	);
1705
}
1799
}
1706
public void testBug83230_Explicit04() throws CoreException {
1800
public void testBug83230_Explicit04() throws CoreException {
1707
	this.resultCollector.showRule = true;
1801
	this.resultCollector.showRule();
1708
	setUpBug83230_Explicit();
1802
	setUpBug83230_Explicit();
1709
	IField field = selectField(this.workingCopies[0], "city");
1803
	IField field = selectField(this.workingCopies[0], "city");
1710
	search(field, REFERENCES);
1804
	search(field, REFERENCES);
Lines 1713-1719 Link Here
1713
	);
1807
	);
1714
}
1808
}
1715
public void testBug83230_Explicit05() throws CoreException {
1809
public void testBug83230_Explicit05() throws CoreException {
1716
	this.resultCollector.showRule = true;
1810
	this.resultCollector.showRule();
1717
	setUpBug83230_Explicit();
1811
	setUpBug83230_Explicit();
1718
	IField field = selectField(this.workingCopies[0], "ageMin");
1812
	IField field = selectField(this.workingCopies[0], "ageMin");
1719
	search(field, REFERENCES);
1813
	search(field, REFERENCES);
Lines 1722-1728 Link Here
1722
	);
1816
	);
1723
}
1817
}
1724
public void testBug83230_Implicit01() throws CoreException {
1818
public void testBug83230_Implicit01() throws CoreException {
1725
	this.resultCollector.showRule = true;
1819
	this.resultCollector.showRule();
1726
	this.workingCopies = new ICompilationUnit[1];
1820
	this.workingCopies = new ICompilationUnit[1];
1727
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java",
1821
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java",
1728
		"package b83230;\n" +
1822
		"package b83230;\n" +
Lines 1747-1753 Link Here
1747
	);
1841
	);
1748
}
1842
}
1749
public void testBug83230_Implicit02() throws CoreException {
1843
public void testBug83230_Implicit02() throws CoreException {
1750
	this.resultCollector.showRule = true;
1844
	this.resultCollector.showRule();
1751
	this.workingCopies = new ICompilationUnit[1];
1845
	this.workingCopies = new ICompilationUnit[1];
1752
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java",
1846
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java",
1753
		"package b83230;\n" +
1847
		"package b83230;\n" +
Lines 1778-1784 Link Here
1778
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83304"
1872
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83304"
1779
 */
1873
 */
1780
public void testBug83304() throws CoreException {
1874
public void testBug83304() throws CoreException {
1781
	this.resultCollector.showRule = true;
1875
	this.resultCollector.showRule();
1782
	this.workingCopies = new ICompilationUnit[1];
1876
	this.workingCopies = new ICompilationUnit[1];
1783
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Test.java",
1877
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Test.java",
1784
		"package b83304;\n" +
1878
		"package b83304;\n" +
Lines 1800-1806 Link Here
1800
	);
1894
	);
1801
}
1895
}
1802
private void setUpBug83304_TypeParameterizedElementPattern() throws CoreException {
1896
private void setUpBug83304_TypeParameterizedElementPattern() throws CoreException {
1803
	this.resultCollector.showRule = true;
1897
	this.resultCollector.showRule();
1804
	this.workingCopies = new ICompilationUnit[1];
1898
	this.workingCopies = new ICompilationUnit[1];
1805
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Types.java",
1899
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Types.java",
1806
		"package b83304;\n" +
1900
		"package b83304;\n" +
Lines 1816-1822 Link Here
1816
	);
1910
	);
1817
}
1911
}
1818
public void testBug83304_TypeParameterizedElementPattern() throws CoreException {
1912
public void testBug83304_TypeParameterizedElementPattern() throws CoreException {
1819
	this.resultCollector.showRule = true;
1913
	this.resultCollector.showRule();
1820
	setUpBug83304_TypeParameterizedElementPattern();
1914
	setUpBug83304_TypeParameterizedElementPattern();
1821
	IType type = selectType(this.workingCopies[0], "Generic", 4);
1915
	IType type = selectType(this.workingCopies[0], "Generic", 4);
1822
	search(type, REFERENCES, ERASURE_RULE);
1916
	search(type, REFERENCES, ERASURE_RULE);
Lines 1832-1838 Link Here
1832
	);
1926
	);
1833
}
1927
}
1834
public void testBug83304_TypeGenericElementPattern() throws CoreException {
1928
public void testBug83304_TypeGenericElementPattern() throws CoreException {
1835
	this.resultCollector.showRule = true;
1929
	this.resultCollector.showRule();
1836
	setUpBug83304_TypeParameterizedElementPattern();
1930
	setUpBug83304_TypeParameterizedElementPattern();
1837
	IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g1.t.s.def", "Generic.class").getType();
1931
	IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g1.t.s.def", "Generic.class").getType();
1838
	search(type, REFERENCES, ERASURE_RULE);
1932
	search(type, REFERENCES, ERASURE_RULE);
Lines 1848-1854 Link Here
1848
	);
1942
	);
1849
}
1943
}
1850
public void testBug83304_TypeStringPattern() throws CoreException {
1944
public void testBug83304_TypeStringPattern() throws CoreException {
1851
	this.resultCollector.showRule = true;
1945
	this.resultCollector.showRule();
1852
	setUpBug83304_TypeParameterizedElementPattern();
1946
	setUpBug83304_TypeParameterizedElementPattern();
1853
	search("Generic<? super Exception>", TYPE, REFERENCES, ERASURE_RULE);
1947
	search("Generic<? super Exception>", TYPE, REFERENCES, ERASURE_RULE);
1854
	assertSearchResults(
1948
	assertSearchResults(
Lines 1863-1869 Link Here
1863
	);
1957
	);
1864
}
1958
}
1865
private void setUpBug83304_MethodParameterizedElementPattern() throws CoreException {
1959
private void setUpBug83304_MethodParameterizedElementPattern() throws CoreException {
1866
	this.resultCollector.showRule = true;
1960
	this.resultCollector.showRule();
1867
	this.workingCopies = new ICompilationUnit[1];
1961
	this.workingCopies = new ICompilationUnit[1];
1868
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Methods.java",
1962
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Methods.java",
1869
		"package b83304;\n" +
1963
		"package b83304;\n" +
Lines 1880-1886 Link Here
1880
	);
1974
	);
1881
}
1975
}
1882
public void testBug83304_MethodParameterizedElementPattern() throws CoreException {
1976
public void testBug83304_MethodParameterizedElementPattern() throws CoreException {
1883
	this.resultCollector.showRule = true;
1977
	this.resultCollector.showRule();
1884
	setUpBug83304_MethodParameterizedElementPattern();
1978
	setUpBug83304_MethodParameterizedElementPattern();
1885
	IMethod method = selectMethod(this.workingCopies[0], "generic", 2);
1979
	IMethod method = selectMethod(this.workingCopies[0], "generic", 2);
1886
	search(method, REFERENCES, ERASURE_RULE);
1980
	search(method, REFERENCES, ERASURE_RULE);
Lines 1891-1897 Link Here
1891
	);
1985
	);
1892
}
1986
}
1893
public void testBug83304_MethodGenericElementPattern() throws CoreException {
1987
public void testBug83304_MethodGenericElementPattern() throws CoreException {
1894
	this.resultCollector.showRule = true;
1988
	this.resultCollector.showRule();
1895
	setUpBug83304_MethodParameterizedElementPattern();
1989
	setUpBug83304_MethodParameterizedElementPattern();
1896
	IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.m.def", "Single.class").getType();
1990
	IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.m.def", "Single.class").getType();
1897
	IMethod method = type.getMethod("generic", new String[] { "TU;" });
1991
	IMethod method = type.getMethod("generic", new String[] { "TU;" });
Lines 1903-1909 Link Here
1903
	);
1997
	);
1904
}
1998
}
1905
public void testBug83304_MethodStringPattern() throws CoreException {
1999
public void testBug83304_MethodStringPattern() throws CoreException {
1906
	this.resultCollector.showRule = true;
2000
	this.resultCollector.showRule();
1907
	setUpBug83304_MethodParameterizedElementPattern();
2001
	setUpBug83304_MethodParameterizedElementPattern();
1908
	search("<Exception>generic", METHOD, REFERENCES, ERASURE_RULE);
2002
	search("<Exception>generic", METHOD, REFERENCES, ERASURE_RULE);
1909
	assertSearchResults(
2003
	assertSearchResults(
Lines 1913-1919 Link Here
1913
	);
2007
	);
1914
}
2008
}
1915
private void setUpBug83304_ConstructorGenericElementPattern() throws CoreException {
2009
private void setUpBug83304_ConstructorGenericElementPattern() throws CoreException {
1916
	this.resultCollector.showRule = true;
2010
	this.resultCollector.showRule();
1917
	this.workingCopies = new ICompilationUnit[1];
2011
	this.workingCopies = new ICompilationUnit[1];
1918
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Constructors.java",
2012
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Constructors.java",
1919
		"package b83304;\n" +
2013
		"package b83304;\n" +
Lines 1929-1935 Link Here
1929
	);
2023
	);
1930
}
2024
}
1931
public void testBug83304_ConstructorGenericElementPattern() throws CoreException {
2025
public void testBug83304_ConstructorGenericElementPattern() throws CoreException {
1932
	this.resultCollector.showRule = true;
2026
	this.resultCollector.showRule();
1933
	setUpBug83304_ConstructorGenericElementPattern();
2027
	setUpBug83304_ConstructorGenericElementPattern();
1934
	IMethod method = selectMethod(this.workingCopies[0], "Single", 3);
2028
	IMethod method = selectMethod(this.workingCopies[0], "Single", 3);
1935
	search(method, REFERENCES, ERASURE_RULE);
2029
	search(method, REFERENCES, ERASURE_RULE);
Lines 1940-1946 Link Here
1940
	);
2034
	);
1941
}
2035
}
1942
public void testBug83304_ConstructorParameterizedElementPattern() throws CoreException {
2036
public void testBug83304_ConstructorParameterizedElementPattern() throws CoreException {
1943
	this.resultCollector.showRule = true;
2037
	this.resultCollector.showRule();
1944
	setUpBug83304_ConstructorGenericElementPattern();
2038
	setUpBug83304_ConstructorGenericElementPattern();
1945
	IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.c.def", "Single.class").getType();
2039
	IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.c.def", "Single.class").getType();
1946
	IMethod method = type.getMethod("Single", new String[] { "TT;", "TU;" });
2040
	IMethod method = type.getMethod("Single", new String[] { "TT;", "TU;" });
Lines 1952-1958 Link Here
1952
	);
2046
	);
1953
}
2047
}
1954
public void testBug83304_ConstructorStringPattern() throws CoreException {
2048
public void testBug83304_ConstructorStringPattern() throws CoreException {
1955
	this.resultCollector.showRule = true;
2049
	this.resultCollector.showRule();
1956
	setUpBug83304_ConstructorGenericElementPattern();
2050
	setUpBug83304_ConstructorGenericElementPattern();
1957
	search("<Exception>Single", CONSTRUCTOR, REFERENCES, ERASURE_RULE);
2051
	search("<Exception>Single", CONSTRUCTOR, REFERENCES, ERASURE_RULE);
1958
	assertSearchResults(
2052
	assertSearchResults(
Lines 1997-2003 Link Here
1997
	);
2091
	);
1998
}
2092
}
1999
public void testBug83804_Type() throws CoreException {
2093
public void testBug83804_Type() throws CoreException {
2000
	this.resultCollector.showInsideDoc = true;
2094
	this.resultCollector.showInsideDoc();
2001
	setUpBug83804_Type();
2095
	setUpBug83804_Type();
2002
	IType type = this.workingCopies[1].getType("Test");
2096
	IType type = this.workingCopies[1].getType("Test");
2003
	search(type, REFERENCES);
2097
	search(type, REFERENCES);
Lines 2010-2016 Link Here
2010
	);
2104
	);
2011
}
2105
}
2012
public void testBug83804_Method() throws CoreException {
2106
public void testBug83804_Method() throws CoreException {
2013
	this.resultCollector.showInsideDoc = true;
2107
	this.resultCollector.showInsideDoc();
2014
	setUpBug83804_Type();
2108
	setUpBug83804_Type();
2015
	IMethod[] methods = this.workingCopies[1].getType("Test").getMethods();
2109
	IMethod[] methods = this.workingCopies[1].getType("Test").getMethods();
2016
	assertEquals("Invalid number of methods", 1, methods.length);
2110
	assertEquals("Invalid number of methods", 1, methods.length);
Lines 2020-2026 Link Here
2020
	);
2114
	);
2021
}
2115
}
2022
public void testBug83804_Field() throws CoreException {
2116
public void testBug83804_Field() throws CoreException {
2023
	this.resultCollector.showInsideDoc = true;
2117
	this.resultCollector.showInsideDoc();
2024
	setUpBug83804_Type();
2118
	setUpBug83804_Type();
2025
	IField[] fields = this.workingCopies[1].getType("Test").getFields();
2119
	IField[] fields = this.workingCopies[1].getType("Test").getFields();
2026
	assertEquals("Invalid number of fields", 1, fields.length);
2120
	assertEquals("Invalid number of fields", 1, fields.length);
Lines 2035-2041 Link Here
2035
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83388"
2129
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83388"
2036
 */
2130
 */
2037
public void testBug83388() throws CoreException {
2131
public void testBug83388() throws CoreException {
2038
	this.resultCollector.showRule = true;
2132
	this.resultCollector.showRule();
2039
	this.workingCopies = new ICompilationUnit[1];
2133
	this.workingCopies = new ICompilationUnit[1];
2040
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java",
2134
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java",
2041
		"package b83388;\n" +
2135
		"package b83388;\n" +
Lines 2063-2069 Link Here
2063
	);
2157
	);
2064
}
2158
}
2065
public void testBug83388b() throws CoreException {
2159
public void testBug83388b() throws CoreException {
2066
	this.resultCollector.showRule = true;
2160
	this.resultCollector.showRule();
2067
	this.workingCopies = new ICompilationUnit[1];
2161
	this.workingCopies = new ICompilationUnit[1];
2068
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java",
2162
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java",
2069
		"package b83388;\n" +
2163
		"package b83388;\n" +
Lines 2096-2103 Link Here
2096
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83693"
2190
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83693"
2097
 */
2191
 */
2098
public void testBug83693() throws CoreException {
2192
public void testBug83693() throws CoreException {
2099
	this.resultCollector.showRule = true;
2193
	this.resultCollector.showRule();
2100
	this.resultCollector.showInsideDoc = true;
2194
	this.resultCollector.showInsideDoc();
2101
	this.workingCopies = new ICompilationUnit[1];
2195
	this.workingCopies = new ICompilationUnit[1];
2102
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83693/A.java",
2196
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83693/A.java",
2103
		"package b83693;\n" +
2197
		"package b83693;\n" +
Lines 2153-2159 Link Here
2153
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84100"
2247
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84100"
2154
 */
2248
 */
2155
private void setUpBug84100() throws CoreException {
2249
private void setUpBug84100() throws CoreException {
2156
	this.resultCollector.showRule = true;
2250
	this.resultCollector.showRule();
2157
	this.workingCopies = new ICompilationUnit[2];
2251
	this.workingCopies = new ICompilationUnit[2];
2158
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84100/X.java",
2252
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84100/X.java",
2159
		"package b84100;\n" +
2253
		"package b84100;\n" +
Lines 2181-2187 Link Here
2181
	);
2275
	);
2182
}
2276
}
2183
public void testBug84100() throws CoreException {
2277
public void testBug84100() throws CoreException {
2184
	this.resultCollector.showRule = true;
2278
	this.resultCollector.showRule();
2185
	setUpBug84100();
2279
	setUpBug84100();
2186
	IMethod method = selectMethod(this.workingCopies[0], "foo", 1);
2280
	IMethod method = selectMethod(this.workingCopies[0], "foo", 1);
2187
	search(method, REFERENCES);
2281
	search(method, REFERENCES);
Lines 2190-2196 Link Here
2190
	);
2284
	);
2191
}
2285
}
2192
public void testBug84100b() throws CoreException {
2286
public void testBug84100b() throws CoreException {
2193
	this.resultCollector.showRule = true;
2287
	this.resultCollector.showRule();
2194
	setUpBug84100();
2288
	setUpBug84100();
2195
	IMethod method = selectMethod(this.workingCopies[0], "foo", 2);
2289
	IMethod method = selectMethod(this.workingCopies[0], "foo", 2);
2196
	search(method, REFERENCES);
2290
	search(method, REFERENCES);
Lines 2199-2205 Link Here
2199
	);
2293
	);
2200
}
2294
}
2201
public void testBug84100c() throws CoreException {
2295
public void testBug84100c() throws CoreException {
2202
	this.resultCollector.showRule = true;
2296
	this.resultCollector.showRule();
2203
	setUpBug84100();
2297
	setUpBug84100();
2204
	IMethod method = selectMethod(this.workingCopies[0], "foo", 3);
2298
	IMethod method = selectMethod(this.workingCopies[0], "foo", 3);
2205
	search(method, REFERENCES);
2299
	search(method, REFERENCES);
Lines 2209-2215 Link Here
2209
	);
2303
	);
2210
}
2304
}
2211
public void testBug84100d() throws CoreException {
2305
public void testBug84100d() throws CoreException {
2212
	this.resultCollector.showRule = true;
2306
	this.resultCollector.showRule();
2213
	setUpBug84100();
2307
	setUpBug84100();
2214
	IMethod method = selectMethod(this.workingCopies[0], "foo", 4);
2308
	IMethod method = selectMethod(this.workingCopies[0], "foo", 4);
2215
	search(method, REFERENCES);
2309
	search(method, REFERENCES);
Lines 2218-2224 Link Here
2218
	);
2312
	);
2219
}
2313
}
2220
public void testBug84100e() throws CoreException {
2314
public void testBug84100e() throws CoreException {
2221
	this.resultCollector.showRule = true;
2315
	this.resultCollector.showRule();
2222
	setUpBug84100();
2316
	setUpBug84100();
2223
	IMethod method = selectMethod(this.workingCopies[0], "foo", 5);
2317
	IMethod method = selectMethod(this.workingCopies[0], "foo", 5);
2224
	search(method, REFERENCES);
2318
	search(method, REFERENCES);
Lines 2232-2238 Link Here
2232
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84121"
2326
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84121"
2233
 */
2327
 */
2234
public void testBug84121() throws CoreException {
2328
public void testBug84121() throws CoreException {
2235
	this.resultCollector.showRule = true;
2329
	this.resultCollector.showRule();
2236
	this.workingCopies = new ICompilationUnit[1];
2330
	this.workingCopies = new ICompilationUnit[1];
2237
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84121/Test.java",
2331
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84121/Test.java",
2238
		"package b84121;\n" +
2332
		"package b84121;\n" +
Lines 2257-2263 Link Here
2257
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84724"
2351
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84724"
2258
 */
2352
 */
2259
private void setUpBug84724() throws CoreException {
2353
private void setUpBug84724() throws CoreException {
2260
	this.resultCollector.showRule = true;
2354
	this.resultCollector.showRule();
2261
	this.workingCopies = new ICompilationUnit[2];
2355
	this.workingCopies = new ICompilationUnit[2];
2262
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84724/X.java",
2356
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84724/X.java",
2263
		"package b84724;\n" +
2357
		"package b84724;\n" +
Lines 2283-2289 Link Here
2283
	);
2377
	);
2284
}
2378
}
2285
public void testBug84724() throws CoreException {
2379
public void testBug84724() throws CoreException {
2286
	this.resultCollector.showRule = true;
2380
	this.resultCollector.showRule();
2287
	setUpBug84724();
2381
	setUpBug84724();
2288
	IMethod method = selectMethod(this.workingCopies[0], "X", 2);
2382
	IMethod method = selectMethod(this.workingCopies[0], "X", 2);
2289
	search(method, REFERENCES);
2383
	search(method, REFERENCES);
Lines 2292-2298 Link Here
2292
	);
2386
	);
2293
}
2387
}
2294
public void testBug84724b() throws CoreException {
2388
public void testBug84724b() throws CoreException {
2295
	this.resultCollector.showRule = true;
2389
	this.resultCollector.showRule();
2296
	setUpBug84724();
2390
	setUpBug84724();
2297
	IMethod method = selectMethod(this.workingCopies[0], "X", 3);
2391
	IMethod method = selectMethod(this.workingCopies[0], "X", 3);
2298
	search(method, REFERENCES);
2392
	search(method, REFERENCES);
Lines 2303-2309 Link Here
2303
	);
2397
	);
2304
}
2398
}
2305
public void testBug84724c() throws CoreException {
2399
public void testBug84724c() throws CoreException {
2306
	this.resultCollector.showRule = true;
2400
	this.resultCollector.showRule();
2307
	setUpBug84724();
2401
	setUpBug84724();
2308
	IMethod method = selectMethod(this.workingCopies[0], "X", 4);
2402
	IMethod method = selectMethod(this.workingCopies[0], "X", 4);
2309
	search(method, REFERENCES);
2403
	search(method, REFERENCES);
Lines 2312-2318 Link Here
2312
	);
2406
	);
2313
}
2407
}
2314
public void testBug84724d() throws CoreException {
2408
public void testBug84724d() throws CoreException {
2315
	this.resultCollector.showRule = true;
2409
	this.resultCollector.showRule();
2316
	setUpBug84724();
2410
	setUpBug84724();
2317
	IMethod method = selectMethod(this.workingCopies[0], "X", 5);
2411
	IMethod method = selectMethod(this.workingCopies[0], "X", 5);
2318
	search(method, REFERENCES);
2412
	search(method, REFERENCES);
Lines 2326-2332 Link Here
2326
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84727"
2420
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84727"
2327
 */
2421
 */
2328
private void setUpBug84727() throws CoreException {
2422
private void setUpBug84727() throws CoreException {
2329
	this.resultCollector.showRule = true;
2423
	this.resultCollector.showRule();
2330
	this.workingCopies = new ICompilationUnit[3];
2424
	this.workingCopies = new ICompilationUnit[3];
2331
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84727/A.java",
2425
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84727/A.java",
2332
		"package b84727;\n" +
2426
		"package b84727;\n" +
Lines 2353-2359 Link Here
2353
	);
2447
	);
2354
}
2448
}
2355
public void testBug84727() throws CoreException {
2449
public void testBug84727() throws CoreException {
2356
	this.resultCollector.showRule = true;
2450
	this.resultCollector.showRule();
2357
	setUpBug84727();
2451
	setUpBug84727();
2358
	IMethod[] methods = this.workingCopies[0].getType("A").getMethods();
2452
	IMethod[] methods = this.workingCopies[0].getType("A").getMethods();
2359
	assertEquals("Invalid number of methods", 2, methods.length);
2453
	assertEquals("Invalid number of methods", 2, methods.length);
Lines 2363-2369 Link Here
2363
	);
2457
	);
2364
}
2458
}
2365
public void testBug84727b() throws CoreException {
2459
public void testBug84727b() throws CoreException {
2366
	this.resultCollector.showRule = true;
2460
	this.resultCollector.showRule();
2367
	setUpBug84727();
2461
	setUpBug84727();
2368
	IMethod[] methods = this.workingCopies[0].getType("A").getMethods();
2462
	IMethod[] methods = this.workingCopies[0].getType("A").getMethods();
2369
	assertEquals("Invalid number of methods", 2, methods.length);
2463
	assertEquals("Invalid number of methods", 2, methods.length);
Lines 2378-2384 Link Here
2378
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=85810"
2472
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=85810"
2379
 */
2473
 */
2380
public void testBug85810() throws CoreException {
2474
public void testBug85810() throws CoreException {
2381
	this.resultCollector.showRule = true;
2475
	this.resultCollector.showRule();
2382
	this.workingCopies = new ICompilationUnit[1];
2476
	this.workingCopies = new ICompilationUnit[1];
2383
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b85810/Test.java",
2477
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b85810/Test.java",
2384
		"package b85810;\n" +
2478
		"package b85810;\n" +
Lines 2400-2406 Link Here
2400
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86596"
2494
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86596"
2401
 */
2495
 */
2402
public void testBug86596() throws CoreException {
2496
public void testBug86596() throws CoreException {
2403
	this.resultCollector.showRule = true;
2497
	this.resultCollector.showRule();
2404
	this.workingCopies = new ICompilationUnit[3];
2498
	this.workingCopies = new ICompilationUnit[3];
2405
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86596/aa/link/A.java",
2499
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86596/aa/link/A.java",
2406
		"package b86596.aa.link;\n" +
2500
		"package b86596.aa.link;\n" +
Lines 2431-2437 Link Here
2431
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86642"
2525
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86642"
2432
 */
2526
 */
2433
public void testBug86642() throws CoreException {
2527
public void testBug86642() throws CoreException {
2434
	this.resultCollector.showRule = true;
2528
	this.resultCollector.showRule();
2435
	this.workingCopies = new ICompilationUnit[2];
2529
	this.workingCopies = new ICompilationUnit[2];
2436
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86642/A.java",
2530
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86642/A.java",
2437
		"package b86642;\n" +
2531
		"package b86642;\n" +
Lines 2475-2481 Link Here
2475
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86380"
2569
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86380"
2476
 */
2570
 */
2477
private void setUpBug86380() throws CoreException {
2571
private void setUpBug86380() throws CoreException {
2478
	this.resultCollector.showInsideDoc = true;
2572
	this.resultCollector.showInsideDoc();
2479
	this.workingCopies = new ICompilationUnit[2];
2573
	this.workingCopies = new ICompilationUnit[2];
2480
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86380/package-info.java",
2574
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86380/package-info.java",
2481
		"/**\n" +
2575
		"/**\n" +
Lines 2493-2499 Link Here
2493
	);
2587
	);
2494
}
2588
}
2495
public void testBug86380_Type() throws CoreException {
2589
public void testBug86380_Type() throws CoreException {
2496
	this.resultCollector.showInsideDoc = true;
2590
	this.resultCollector.showInsideDoc();
2497
	setUpBug86380();
2591
	setUpBug86380();
2498
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java");
2592
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java");
2499
	IType type = unit.getType("Annot");
2593
	IType type = unit.getType("Annot");
Lines 2506-2512 Link Here
2506
	);
2600
	);
2507
}
2601
}
2508
public void testBug86380_Method() throws CoreException {
2602
public void testBug86380_Method() throws CoreException {
2509
	this.resultCollector.showInsideDoc = true;
2603
	this.resultCollector.showInsideDoc();
2510
	setUpBug86380();
2604
	setUpBug86380();
2511
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java");
2605
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java");
2512
	IMethod[] methods = unit.getType("Annot").getMethods();
2606
	IMethod[] methods = unit.getType("Annot").getMethods();
Lines 2518-2524 Link Here
2518
	);
2612
	);
2519
}
2613
}
2520
public void testBug86380_Field() throws CoreException {
2614
public void testBug86380_Field() throws CoreException {
2521
	this.resultCollector.showInsideDoc = true;
2615
	this.resultCollector.showInsideDoc();
2522
	setUpBug86380();
2616
	setUpBug86380();
2523
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java");
2617
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java");
2524
	IField[] fields = unit.getType("Annot").getFields();
2618
	IField[] fields = unit.getType("Annot").getFields();
Lines 2535-2541 Link Here
2535
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=88174"
2629
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=88174"
2536
 */
2630
 */
2537
public void testBug88174() throws CoreException {
2631
public void testBug88174() throws CoreException {
2538
	this.resultCollector.showRule = true;
2632
	this.resultCollector.showRule();
2539
	this.workingCopies = new ICompilationUnit[2];
2633
	this.workingCopies = new ICompilationUnit[2];
2540
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88174/Test.java",
2634
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88174/Test.java",
2541
		"package b88174;\n" +
2635
		"package b88174;\n" +
Lines 3008-3014 Link Here
3008
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92944"
3102
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92944"
3009
 */
3103
 */
3010
private void setUpBug92944() throws CoreException {
3104
private void setUpBug92944() throws CoreException {
3011
	this.resultCollector.showRule = true;
3105
	this.resultCollector.showRule();
3012
	this.workingCopies = new ICompilationUnit[1];
3106
	this.workingCopies = new ICompilationUnit[1];
3013
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b92944/Test.java",
3107
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b92944/Test.java",
3014
		"package b92944;\n" +
3108
		"package b92944;\n" +
Lines 3019-3025 Link Here
3019
	);
3113
	);
3020
}
3114
}
3021
public void testBug92944_TYPE() throws CoreException {
3115
public void testBug92944_TYPE() throws CoreException {
3022
	this.resultCollector.showRule = true;
3116
	this.resultCollector.showRule();
3023
	setUpBug92944();
3117
	setUpBug92944();
3024
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3118
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3025
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3119
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3042-3048 Link Here
3042
		requestor);
3136
		requestor);
3043
}
3137
}
3044
public void testBug92944_CLASS() throws CoreException {
3138
public void testBug92944_CLASS() throws CoreException {
3045
	this.resultCollector.showRule = true;
3139
	this.resultCollector.showRule();
3046
	setUpBug92944();
3140
	setUpBug92944();
3047
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3141
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3048
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3142
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3063-3069 Link Here
3063
		requestor);
3157
		requestor);
3064
}
3158
}
3065
public void testBug92944_CLASS_AND_INTERFACE() throws CoreException {
3159
public void testBug92944_CLASS_AND_INTERFACE() throws CoreException {
3066
	this.resultCollector.showRule = true;
3160
	this.resultCollector.showRule();
3067
	setUpBug92944();
3161
	setUpBug92944();
3068
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3162
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3069
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3163
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3085-3091 Link Here
3085
		requestor);
3179
		requestor);
3086
}
3180
}
3087
public void testBug92944_CLASS_AND_ENUM() throws CoreException {
3181
public void testBug92944_CLASS_AND_ENUM() throws CoreException {
3088
	this.resultCollector.showRule = true;
3182
	this.resultCollector.showRule();
3089
	setUpBug92944();
3183
	setUpBug92944();
3090
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3184
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3091
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3185
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3107-3113 Link Here
3107
		requestor);
3201
		requestor);
3108
}
3202
}
3109
public void testBug92944_INTERFACE() throws CoreException {
3203
public void testBug92944_INTERFACE() throws CoreException {
3110
	this.resultCollector.showRule = true;
3204
	this.resultCollector.showRule();
3111
	setUpBug92944();
3205
	setUpBug92944();
3112
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3206
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3113
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3207
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3127-3133 Link Here
3127
		requestor);
3221
		requestor);
3128
}
3222
}
3129
public void testBug92944_ENUM() throws CoreException {
3223
public void testBug92944_ENUM() throws CoreException {
3130
	this.resultCollector.showRule = true;
3224
	this.resultCollector.showRule();
3131
	setUpBug92944();
3225
	setUpBug92944();
3132
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3226
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3133
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3227
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3147-3153 Link Here
3147
		requestor);
3241
		requestor);
3148
}
3242
}
3149
public void testBug92944_ANNOTATION_TYPE() throws CoreException {
3243
public void testBug92944_ANNOTATION_TYPE() throws CoreException {
3150
	this.resultCollector.showRule = true;
3244
	this.resultCollector.showRule();
3151
	setUpBug92944();
3245
	setUpBug92944();
3152
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3246
	TypeNameRequestor requestor =  new SearchTests.SearchTypeNameRequestor();
3153
	new SearchEngine(this.workingCopies).searchAllTypeNames(
3247
	new SearchEngine(this.workingCopies).searchAllTypeNames(
Lines 3177-3183 Link Here
3177
 */
3271
 */
3178
public void testBug93392() throws CoreException {
3272
public void testBug93392() throws CoreException {
3179
	TestCollector collector = new TestCollector();
3273
	TestCollector collector = new TestCollector();
3180
	collector.showAccuracy = true;
3274
	collector.showAccuracy(true);
3181
	this.workingCopies = new ICompilationUnit[1];
3275
	this.workingCopies = new ICompilationUnit[1];
3182
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b93392/Test.java",
3276
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b93392/Test.java",
3183
		"package b93392;\n" +
3277
		"package b93392;\n" +
Lines 3503-3509 Link Here
3503
3597
3504
	// Verify matches
3598
	// Verify matches
3505
	TestCollector occurencesCollector = new TestCollector();
3599
	TestCollector occurencesCollector = new TestCollector();
3506
	occurencesCollector.showAccuracy = true;
3600
	occurencesCollector.showAccuracy(true);
3507
	search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector);
3601
	search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector);
3508
	assertSearchResults(
3602
	assertSearchResults(
3509
		"src/b95794/Test.java [b95794.Test] EXACT_MATCH\n" +
3603
		"src/b95794/Test.java [b95794.Test] EXACT_MATCH\n" +
Lines 3519-3531 Link Here
3519
	assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size());
3613
	assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size());
3520
}
3614
}
3521
public void testBug95794b() throws CoreException {
3615
public void testBug95794b() throws CoreException {
3522
	this.resultCollector.showRule = true;
3616
	this.resultCollector.showRule();
3523
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java");
3617
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java");
3524
	IType type = unit.getType("Test").getType("Color");
3618
	IType type = unit.getType("Test").getType("Color");
3525
3619
3526
	// Verify matches
3620
	// Verify matches
3527
	TestCollector occurencesCollector = new TestCollector();
3621
	TestCollector occurencesCollector = new TestCollector();
3528
	occurencesCollector.showAccuracy = true;
3622
	occurencesCollector.showAccuracy(true);
3529
	search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector);
3623
	search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector);
3530
	assertSearchResults(
3624
	assertSearchResults(
3531
		"src/b95794/Test.java [b95794.Test.Color] EXACT_MATCH\n" +
3625
		"src/b95794/Test.java [b95794.Test.Color] EXACT_MATCH\n" +
Lines 3541-3553 Link Here
3541
	assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size());
3635
	assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size());
3542
}
3636
}
3543
public void testBug95794c() throws CoreException {
3637
public void testBug95794c() throws CoreException {
3544
	this.resultCollector.showRule = true;
3638
	this.resultCollector.showRule();
3545
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java");
3639
	ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java");
3546
	IField field = unit.getType("Test").getType("Color").getField("WHITE");
3640
	IField field = unit.getType("Test").getType("Color").getField("WHITE");
3547
3641
3548
	// Verify matches
3642
	// Verify matches
3549
	TestCollector occurencesCollector = new TestCollector();
3643
	TestCollector occurencesCollector = new TestCollector();
3550
	occurencesCollector.showAccuracy = true;
3644
	occurencesCollector.showAccuracy(true);
3551
	search(field, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector);
3645
	search(field, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector);
3552
	assertSearchResults(
3646
	assertSearchResults(
3553
		"src/b95794/Test.java [WHITE] EXACT_MATCH\n" +
3647
		"src/b95794/Test.java [WHITE] EXACT_MATCH\n" +
Lines 3656-3662 Link Here
3656
 */
3750
 */
3657
public void testBug97087() throws CoreException {
3751
public void testBug97087() throws CoreException {
3658
	this.workingCopies = new ICompilationUnit[1];
3752
	this.workingCopies = new ICompilationUnit[1];
3659
	this.resultCollector.showRule = true;
3753
	this.resultCollector.showRule();
3660
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java",
3754
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java",
3661
		"package b97087;\n" +
3755
		"package b97087;\n" +
3662
		"public class Bug<Type> {\n" +
3756
		"public class Bug<Type> {\n" +
Lines 3796-3802 Link Here
3796
		this.workingCopies[1].commitWorkingCopy(true, null);
3890
		this.workingCopies[1].commitWorkingCopy(true, null);
3797
		this.workingCopies[2].commitWorkingCopy(true, null);
3891
		this.workingCopies[2].commitWorkingCopy(true, null);
3798
		this.workingCopies[3].commitWorkingCopy(true, null);
3892
		this.workingCopies[3].commitWorkingCopy(true, null);
3799
		this.resultCollector.showRule = true;
3893
		this.resultCollector.showRule();
3800
		IType type = this.workingCopies[0].getType("L");
3894
		IType type = this.workingCopies[0].getType("L");
3801
		search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH);
3895
		search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH);
3802
		assertSearchResults(
3896
		assertSearchResults(
Lines 3849-3855 Link Here
3849
		this.workingCopies[1].commitWorkingCopy(true, null);
3943
		this.workingCopies[1].commitWorkingCopy(true, null);
3850
		this.workingCopies[2].commitWorkingCopy(true, null);
3944
		this.workingCopies[2].commitWorkingCopy(true, null);
3851
		this.workingCopies[3].commitWorkingCopy(true, null);
3945
		this.workingCopies[3].commitWorkingCopy(true, null);
3852
		this.resultCollector.showRule = true;
3946
		this.resultCollector.showRule();
3853
		IType type = this.workingCopies[0].getType("L");
3947
		IType type = this.workingCopies[0].getType("L");
3854
		search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH);
3948
		search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH);
3855
		assertSearchResults(
3949
		assertSearchResults(
Lines 4042-4048 Link Here
4042
		"public @interface Annot {\n" +
4136
		"public @interface Annot {\n" +
4043
		"}\n"
4137
		"}\n"
4044
	);
4138
	);
4045
	this.resultCollector.showInsideDoc = true;
4139
	this.resultCollector.showInsideDoc();
4046
	IType type = this.workingCopies[1].getType("Test");
4140
	IType type = this.workingCopies[1].getType("Test");
4047
	search(type, REFERENCES);
4141
	search(type, REFERENCES);
4048
	assertSearchResults(
4142
	assertSearchResults(
Lines 6036-6042 Link Here
6036
		"}"
6130
		"}"
6037
	);
6131
	);
6038
	IType type = this.workingCopies[0].getType("X");
6132
	IType type = this.workingCopies[0].getType("X");
6039
	this.resultCollector.showRule = true;
6133
	this.resultCollector.showRule();
6040
	search(type, REFERENCES, ERASURE_RULE);
6134
	search(type, REFERENCES, ERASURE_RULE);
6041
	assertSearchResults(
6135
	assertSearchResults(
6042
		"src/p1/X.java p1.X.gen [X] EXACT_MATCH\n" +
6136
		"src/p1/X.java p1.X.gen [X] EXACT_MATCH\n" +
Lines 6485-6491 Link Here
6485
		"}"
6579
		"}"
6486
	);
6580
	);
6487
	IType type = this.workingCopies[0].getType("Foo");
6581
	IType type = this.workingCopies[0].getType("Foo");
6488
	this.resultCollector.showRule = true;
6582
	this.resultCollector.showRule();
6489
	new SearchEngine(this.workingCopies).search(
6583
	new SearchEngine(this.workingCopies).search(
6490
		SearchPattern.createPattern(type, REFERENCES),
6584
		SearchPattern.createPattern(type, REFERENCES),
6491
		new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
6585
		new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 7449-7455 Link Here
7449
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=148380"
7543
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=148380"
7450
 */
7544
 */
7451
public void testBug148380_SearchAllTypes_wc() throws CoreException {
7545
public void testBug148380_SearchAllTypes_wc() throws CoreException {
7452
	this.resultCollector.showRule = true;
7546
	this.resultCollector.showRule();
7453
	this.workingCopies = new ICompilationUnit[4];
7547
	this.workingCopies = new ICompilationUnit[4];
7454
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b148380/I.java",
7548
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b148380/I.java",
7455
		"package b148380;\n" +
7549
		"package b148380;\n" +
Lines 7556-7562 Link Here
7556
		);
7650
		);
7557
		waitUntilIndexesReady();
7651
		waitUntilIndexesReady();
7558
		IPackageFragment packageFragment = getPackage("/JavaSearchBugs/src/b153765");
7652
		IPackageFragment packageFragment = getPackage("/JavaSearchBugs/src/b153765");
7559
		this.resultCollector.showSelection = true;
7653
		this.resultCollector.showSelection();
7560
		search(packageFragment, REFERENCES);
7654
		search(packageFragment, REFERENCES);
7561
		assertSearchResults(
7655
		assertSearchResults(
7562
			"src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [        @§|b153765|§.Unimportant public void foo() {}] EXACT_MATCH"
7656
			"src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [        @§|b153765|§.Unimportant public void foo() {}] EXACT_MATCH"
Lines 7610-7616 Link Here
7610
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156177"
7704
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156177"
7611
 */
7705
 */
7612
public void testBug156177() throws CoreException {
7706
public void testBug156177() throws CoreException {
7613
	this.resultCollector.showRule = true;
7707
	this.resultCollector.showRule();
7614
	this.workingCopies = new ICompilationUnit[1];
7708
	this.workingCopies = new ICompilationUnit[1];
7615
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b156177/Test.java",
7709
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b156177/Test.java",
7616
		"package b156177;\n" +
7710
		"package b156177;\n" +
Lines 7643-7649 Link Here
7643
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491"
7737
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491"
7644
 */
7738
 */
7645
public void testBug156491() throws CoreException {
7739
public void testBug156491() throws CoreException {
7646
	this.resultCollector.showRule = true;
7740
	this.resultCollector.showRule();
7647
	this.workingCopies = new ICompilationUnit[1];
7741
	this.workingCopies = new ICompilationUnit[1];
7648
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java",
7742
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java",
7649
		"package pack;\n" +
7743
		"package pack;\n" +
Lines 7714-7720 Link Here
7714
	);
7808
	);
7715
}
7809
}
7716
public void testBug156491a() throws CoreException {
7810
public void testBug156491a() throws CoreException {
7717
	this.resultCollector.showRule = true;
7811
	this.resultCollector.showRule();
7718
	setUpBug156491();
7812
	setUpBug156491();
7719
	IMethod method = this.workingCopies[0].getType("L2").getMethod("test", new String[0]);
7813
	IMethod method = this.workingCopies[0].getType("L2").getMethod("test", new String[0]);
7720
	this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR;
7814
	this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR;
Lines 7726-7732 Link Here
7726
	);
7820
	);
7727
}
7821
}
7728
public void testBug156491b() throws CoreException {
7822
public void testBug156491b() throws CoreException {
7729
	this.resultCollector.showRule = true;
7823
	this.resultCollector.showRule();
7730
	setUpBug156491();
7824
	setUpBug156491();
7731
	IMethod method = this.workingCopies[0].getType("L1").getMethod("test", new String[0]);
7825
	IMethod method = this.workingCopies[0].getType("L1").getMethod("test", new String[0]);
7732
	this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR;
7826
	this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR;
Lines 7744-7750 Link Here
7744
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160301"
7838
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160301"
7745
 */
7839
 */
7746
public void testBug160301() throws CoreException {
7840
public void testBug160301() throws CoreException {
7747
	this.resultCollector.showRule = true;
7841
	this.resultCollector.showRule();
7748
	this.workingCopies = new ICompilationUnit[1];
7842
	this.workingCopies = new ICompilationUnit[1];
7749
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7843
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7750
		"public class Test {\n" +
7844
		"public class Test {\n" +
Lines 7774-7780 Link Here
7774
	);
7868
	);
7775
}
7869
}
7776
public void testBug160301b() throws CoreException {
7870
public void testBug160301b() throws CoreException {
7777
	this.resultCollector.showRule = true;
7871
	this.resultCollector.showRule();
7778
	this.workingCopies = new ICompilationUnit[1];
7872
	this.workingCopies = new ICompilationUnit[1];
7779
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java",
7873
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java",
7780
		"package test;\n" +
7874
		"package test;\n" +
Lines 7810-7816 Link Here
7810
	);
7904
	);
7811
}
7905
}
7812
public void testBug160301_Interface() throws CoreException {
7906
public void testBug160301_Interface() throws CoreException {
7813
	this.resultCollector.showRule = true;
7907
	this.resultCollector.showRule();
7814
	this.workingCopies = new ICompilationUnit[1];
7908
	this.workingCopies = new ICompilationUnit[1];
7815
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7909
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7816
		"public class Test {\n" +
7910
		"public class Test {\n" +
Lines 7864-7870 Link Here
7864
	);
7958
	);
7865
}
7959
}
7866
public void testBug160301_Abstract() throws CoreException {
7960
public void testBug160301_Abstract() throws CoreException {
7867
	this.resultCollector.showRule = true;
7961
	this.resultCollector.showRule();
7868
	this.workingCopies = new ICompilationUnit[1];
7962
	this.workingCopies = new ICompilationUnit[1];
7869
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7963
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7870
		"public class Test {\n" +
7964
		"public class Test {\n" +
Lines 7911-7917 Link Here
7911
	);
8005
	);
7912
}
8006
}
7913
public void testBug160301_Abstract2() throws CoreException {
8007
public void testBug160301_Abstract2() throws CoreException {
7914
	this.resultCollector.showRule = true;
8008
	this.resultCollector.showRule();
7915
	this.workingCopies = new ICompilationUnit[1];
8009
	this.workingCopies = new ICompilationUnit[1];
7916
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
8010
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7917
		"public class Test {\n" +
8011
		"public class Test {\n" +
Lines 7946-7952 Link Here
7946
	);
8040
	);
7947
}
8041
}
7948
public void testBug160301_Abstract3() throws CoreException {
8042
public void testBug160301_Abstract3() throws CoreException {
7949
	this.resultCollector.showRule = true;
8043
	this.resultCollector.showRule();
7950
	this.workingCopies = new ICompilationUnit[1];
8044
	this.workingCopies = new ICompilationUnit[1];
7951
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
8045
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
7952
		"public class Test {\n" +
8046
		"public class Test {\n" +
Lines 8301-8307 Link Here
8301
	);
8395
	);
8302
}
8396
}
8303
public void testBug164121a() throws CoreException {
8397
public void testBug164121a() throws CoreException {
8304
	this.resultCollector.showRule = true;
8398
	this.resultCollector.showRule();
8305
	setUpBug164121();
8399
	setUpBug164121();
8306
	ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param");
8400
	ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param");
8307
	search(param, DECLARATIONS);
8401
	search(param, DECLARATIONS);
Lines 8310-8316 Link Here
8310
	);
8404
	);
8311
}
8405
}
8312
public void testBug164121b() throws CoreException {
8406
public void testBug164121b() throws CoreException {
8313
	this.resultCollector.showRule = true;
8407
	this.resultCollector.showRule();
8314
	setUpBug164121();
8408
	setUpBug164121();
8315
	ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param");
8409
	ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param");
8316
	search(param, ALL_OCCURRENCES);
8410
	search(param, ALL_OCCURRENCES);
Lines 8336-8342 Link Here
8336
			assertTrue("Search match element "+element.getElementName()+" should exist!!!", element.exists());
8430
			assertTrue("Search match element "+element.getElementName()+" should exist!!!", element.exists());
8337
		}
8431
		}
8338
	};
8432
	};
8339
	collector.showAccuracy = true;
8433
	collector.showAccuracy(true);
8340
	search(type, REFERENCES, getJavaSearchScope(), collector);
8434
	search(type, REFERENCES, getJavaSearchScope(), collector);
8341
	assertSearchResults(
8435
	assertSearchResults(
8342
		"lib/b164791.jar test.<anonymous> EXACT_MATCH\n" +
8436
		"lib/b164791.jar test.<anonymous> EXACT_MATCH\n" +
Lines 8459-8465 Link Here
8459
        }
8553
        }
8460
8554
8461
	};
8555
	};
8462
	testCollector.showAccuracy = true;
8556
	testCollector.showAccuracy(true);
8463
	IMethod method = this.workingCopies[0].getType("ClassA").getMethod("setValue", new String[] { "I" });
8557
	IMethod method = this.workingCopies[0].getType("ClassA").getMethod("setValue", new String[] { "I" });
8464
	search(method, REFERENCES, getJavaSearchScope(), testCollector);
8558
	search(method, REFERENCES, getJavaSearchScope(), testCollector);
8465
	assertSearchResults(
8559
	assertSearchResults(
Lines 8675-8681 Link Here
8675
		"}\n" +
8769
		"}\n" +
8676
		"class Ref {}"
8770
		"class Ref {}"
8677
	);
8771
	);
8678
	this.resultCollector.showInsideDoc = true;
8772
	this.resultCollector.showInsideDoc();
8679
	new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null);
8773
	new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null);
8680
	assertSearchResults(
8774
	assertSearchResults(
8681
		"src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC"
8775
		"src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC"
Lines 8696-8702 Link Here
8696
		"}\n" +
8790
		"}\n" +
8697
		"class Ref {}"
8791
		"class Ref {}"
8698
	);
8792
	);
8699
	this.resultCollector.showInsideDoc = true;
8793
	this.resultCollector.showInsideDoc();
8700
	new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null);
8794
	new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null);
8701
	assertSearchResults(
8795
	assertSearchResults(
8702
		"src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC"
8796
		"src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC"
Lines 8713-8719 Link Here
8713
		"}\n" +
8807
		"}\n" +
8714
		"class Ref {}"
8808
		"class Ref {}"
8715
	);
8809
	);
8716
	this.resultCollector.showInsideDoc = true;
8810
	this.resultCollector.showInsideDoc();
8717
	new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null);
8811
	new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null);
8718
	assertSearchResults(
8812
	assertSearchResults(
8719
		"src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC"
8813
		"src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC"
Lines 8731-8737 Link Here
8731
		"}\n" +
8825
		"}\n" +
8732
		"class Ref {}"
8826
		"class Ref {}"
8733
	);
8827
	);
8734
	this.resultCollector.showInsideDoc = true;
8828
	this.resultCollector.showInsideDoc();
8735
	String docCommentSupport = JAVA_PROJECT.getOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, true);
8829
	String docCommentSupport = JAVA_PROJECT.getOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, true);
8736
	JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED);
8830
	JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED);
8737
	try {
8831
	try {
Lines 9305-9311 Link Here
9305
	);
9399
	);
9306
	IType type = this.workingCopies[0].getType("Test");
9400
	IType type = this.workingCopies[0].getType("Test");
9307
	ReferenceCollector collector = new ReferenceCollector();
9401
	ReferenceCollector collector = new ReferenceCollector();
9308
	collector.showSelection = true;
9402
	collector.showSelection();
9309
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9403
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9310
	assertSearchResults(
9404
	assertSearchResults(
9311
		"src/test/Test.java @Annot(clazz=Test.class) [        @Annot(clazz=§|Test|§.class) int x;]",
9405
		"src/test/Test.java @Annot(clazz=Test.class) [        @Annot(clazz=§|Test|§.class) int x;]",
Lines 9321-9327 Link Here
9321
		"}\n"
9415
		"}\n"
9322
	);
9416
	);
9323
	ReferenceCollector collector = new ReferenceCollector();
9417
	ReferenceCollector collector = new ReferenceCollector();
9324
	collector.showSelection = true;
9418
	collector.showSelection();
9325
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9419
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9326
	assertSearchResults(
9420
	assertSearchResults(
9327
		"src/test/Test.java @Deprecated() [        @§|Deprecated|§ foo() {}]",
9421
		"src/test/Test.java @Deprecated() [        @§|Deprecated|§ foo() {}]",
Lines 9347-9353 Link Here
9347
	);
9441
	);
9348
	IType type = this.workingCopies[0].getType("Ref");
9442
	IType type = this.workingCopies[0].getType("Ref");
9349
	ReferenceCollector collector = new ReferenceCollector();
9443
	ReferenceCollector collector = new ReferenceCollector();
9350
	collector.showSelection = true;
9444
	collector.showSelection();
9351
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9445
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9352
	assertSearchResults(
9446
	assertSearchResults(
9353
		"src/comment5/Ref.java void comment5.Ref.doA(Ref).ref [    void doA(§|Ref|§ ref) {}]\n" +
9447
		"src/comment5/Ref.java void comment5.Ref.doA(Ref).ref [    void doA(§|Ref|§ ref) {}]\n" +
Lines 9370-9376 Link Here
9370
	);
9464
	);
9371
	IField field = this.workingCopies[0].getType("Num").getField("CONST");
9465
	IField field = this.workingCopies[0].getType("Num").getField("CONST");
9372
	ReferenceCollector collector = new ReferenceCollector();
9466
	ReferenceCollector collector = new ReferenceCollector();
9373
	collector.showSelection = true;
9467
	collector.showSelection();
9374
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9468
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9375
	assertSearchResults(
9469
	assertSearchResults(
9376
		"src/comment10/Ref.java @Num(number=Num.CONST) [@Num(number= Num.§|CONST|§)]",
9470
		"src/comment10/Ref.java @Num(number=Num.CONST) [@Num(number= Num.§|CONST|§)]",
Lines 9392-9398 Link Here
9392
	);
9486
	);
9393
	IType type = this.workingCopies[0].getType("Tag");
9487
	IType type = this.workingCopies[0].getType("Tag");
9394
	TypeReferenceCollector collector = new TypeReferenceCollector();
9488
	TypeReferenceCollector collector = new TypeReferenceCollector();
9395
	collector.showSelection = true;
9489
	collector.showSelection();
9396
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9490
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9397
	assertSearchResults(
9491
	assertSearchResults(
9398
		"src/comment22/Test.java @Tag() [    @§|Tag|§ Test test1, test2, test3;]\n" +
9492
		"src/comment22/Test.java @Tag() [    @§|Tag|§ Test test1, test2, test3;]\n" +
Lines 9414-9420 Link Here
9414
	);
9508
	);
9415
	IType type = this.workingCopies[0].getType("Test");
9509
	IType type = this.workingCopies[0].getType("Test");
9416
	TypeReferenceCollector collector = new TypeReferenceCollector();
9510
	TypeReferenceCollector collector = new TypeReferenceCollector();
9417
	collector.showSelection = true;
9511
	collector.showSelection();
9418
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9512
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9419
	assertSearchResults(
9513
	assertSearchResults(
9420
		"src/test/Test.java @Annot(clazz=test.Test.class) [    @Annot(clazz = §|test.Test|§.class) int x, y;]",
9514
		"src/test/Test.java @Annot(clazz=test.Test.class) [    @Annot(clazz = §|test.Test|§.class) int x, y;]",
Lines 9469-9475 Link Here
9469
		"public class Types {\n" +
9563
		"public class Types {\n" +
9470
		"}\n"
9564
		"}\n"
9471
	);
9565
	);
9472
	this.resultCollector.showSelection = true;
9566
	this.resultCollector.showSelection();
9473
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9567
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9474
	assertSearchResults(
9568
	assertSearchResults(
9475
		"src/generics/Generic.java [import §|java.io.Serializable|§;] EXACT_MATCH\n" +
9569
		"src/generics/Generic.java [import §|java.io.Serializable|§;] EXACT_MATCH\n" +
Lines 9508-9514 Link Here
9508
		"	Test test;\n" +
9602
		"	Test test;\n" +
9509
		"}\n"
9603
		"}\n"
9510
	);
9604
	);
9511
	this.resultCollector.showSelection = true;
9605
	this.resultCollector.showSelection();
9512
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9606
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9513
	assertSearchResults(
9607
	assertSearchResults(
9514
		"src/test/Ref.java [import §|pack.Test|§;] EXACT_MATCH\n" +
9608
		"src/test/Ref.java [import §|pack.Test|§;] EXACT_MATCH\n" +
Lines 9525-9531 Link Here
9525
	addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false);
9619
	addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false);
9526
	try {
9620
	try {
9527
		IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType();
9621
		IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType();
9528
		this.resultCollector.showMatchKind = true;
9622
		this.resultCollector.showMatchKind();
9529
		search(type, REFERENCES);
9623
		search(type, REFERENCES);
9530
		assertSearchResults(
9624
		assertSearchResults(
9531
			"TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" +
9625
			"TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" +
Lines 9545-9551 Link Here
9545
		SearchPattern rightPattern = SearchPattern.createPattern(type, REFERENCES);
9639
		SearchPattern rightPattern = SearchPattern.createPattern(type, REFERENCES);
9546
		SearchPattern leftPattern = SearchPattern.createPattern(type, DECLARATIONS);
9640
		SearchPattern leftPattern = SearchPattern.createPattern(type, DECLARATIONS);
9547
		SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
9641
		SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
9548
		this.resultCollector.showMatchKind = true;
9642
		this.resultCollector.showMatchKind();
9549
		new SearchEngine(this.workingCopies).search(
9643
		new SearchEngine(this.workingCopies).search(
9550
			pattern,
9644
			pattern,
9551
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
9645
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 9579-9585 Link Here
9579
				SearchPattern.createPattern("Bug", TYPE, REFERENCES, SearchPattern.R_EXACT_MATCH)));
9673
				SearchPattern.createPattern("Bug", TYPE, REFERENCES, SearchPattern.R_EXACT_MATCH)));
9580
		IPackageFragmentRoot root = JAVA_PROJECT.getPackageFragmentRoot("/JavaSearchBugs/lib/b211366.jar");
9674
		IPackageFragmentRoot root = JAVA_PROJECT.getPackageFragmentRoot("/JavaSearchBugs/lib/b211366.jar");
9581
		this.resultCollector.sorted = true;
9675
		this.resultCollector.sorted = true;
9582
		this.resultCollector.showMatchKind = true;
9676
		this.resultCollector.showMatchKind();
9583
		new SearchEngine(this.workingCopies).search(
9677
		new SearchEngine(this.workingCopies).search(
9584
			SearchPattern.createOrPattern(leftPattern, rightPattern),
9678
			SearchPattern.createOrPattern(leftPattern, rightPattern),
9585
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
9679
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 9731-9737 Link Here
9731
		"\n" +
9825
		"\n" +
9732
		"}\n"
9826
		"}\n"
9733
	);
9827
	);
9734
	this.resultCollector.showSelection = true;
9828
	this.resultCollector.showSelection();
9735
	ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test");
9829
	ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test");
9736
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9830
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9737
	assertSearchResults(
9831
	assertSearchResults(
Lines 9751-9757 Link Here
9751
		"	int fField;" +
9845
		"	int fField;" +
9752
		"}"
9846
		"}"
9753
	);
9847
	);
9754
	this.resultCollector.showSelection = true;
9848
	this.resultCollector.showSelection();
9755
	IField field = this.workingCopies[0].getType("Test").getField("fWrapped");
9849
	IField field = this.workingCopies[0].getType("Test").getField("fWrapped");
9756
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9850
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9757
	assertSearchResults(
9851
	assertSearchResults(
Lines 9777-9783 Link Here
9777
		"	}\n" +
9871
		"	}\n" +
9778
		"}\n"
9872
		"}\n"
9779
	);
9873
	);
9780
	this.resultCollector.showSelection = true;
9874
	this.resultCollector.showSelection();
9781
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9875
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9782
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9876
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9783
	assertSearchResults(
9877
	assertSearchResults(
Lines 9806-9812 Link Here
9806
		"	}\n" +
9900
		"	}\n" +
9807
		"}\n"
9901
		"}\n"
9808
	);
9902
	);
9809
	this.resultCollector.showSelection = true;
9903
	this.resultCollector.showSelection();
9810
	IField field = this.workingCopies[1].getType("X").getField("t1");
9904
	IField field = this.workingCopies[1].getType("X").getField("t1");
9811
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9905
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9812
	assertSearchResults(
9906
	assertSearchResults(
Lines 9834-9840 Link Here
9834
		"	}\n" +
9928
		"	}\n" +
9835
		"}\n"
9929
		"}\n"
9836
	);
9930
	);
9837
	this.resultCollector.showSelection = true;
9931
	this.resultCollector.showSelection();
9838
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9932
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9839
	search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9933
	search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9840
	assertSearchResults(
9934
	assertSearchResults(
Lines 9861-9867 Link Here
9861
		"	}\n" +
9955
		"	}\n" +
9862
		"}\n"
9956
		"}\n"
9863
	);
9957
	);
9864
	this.resultCollector.showSelection = true;
9958
	this.resultCollector.showSelection();
9865
	IField field = this.workingCopies[1].getType("X").getField("t1");
9959
	IField field = this.workingCopies[1].getType("X").getField("t1");
9866
	search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9960
	search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9867
	assertSearchResults(
9961
	assertSearchResults(
Lines 9887-9895 Link Here
9887
		"	}\n" +
9981
		"	}\n" +
9888
		"}\n"
9982
		"}\n"
9889
	);
9983
	);
9890
	this.resultCollector.showSelection = true;
9984
	this.resultCollector.showSelection();
9891
	this.resultCollector.showAccess = true;
9985
	this.resultCollector.showAccess();
9892
	this.resultCollector.showAccuracy = false;
9986
	this.resultCollector.showAccuracy(false);
9893
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9987
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9894
	search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9988
	search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9895
	assertSearchResults(
9989
	assertSearchResults(
Lines 9919-9927 Link Here
9919
		"	}\n" +
10013
		"	}\n" +
9920
		"}\n"
10014
		"}\n"
9921
	);
10015
	);
9922
	this.resultCollector.showSelection = true;
10016
	this.resultCollector.showSelection();
9923
	this.resultCollector.showAccess = true;
10017
	this.resultCollector.showAccess();
9924
	this.resultCollector.showAccuracy = false;
10018
	this.resultCollector.showAccuracy(false);
9925
	IField field = this.workingCopies[1].getType("X").getField("t1");
10019
	IField field = this.workingCopies[1].getType("X").getField("t1");
9926
	search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10020
	search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9927
	assertSearchResults(
10021
	assertSearchResults(
Lines 9949-9955 Link Here
9949
		"	}\n" +
10043
		"	}\n" +
9950
		"}"
10044
		"}"
9951
	);
10045
	);
9952
	this.resultCollector.showSelection = true;
10046
	this.resultCollector.showSelection();
9953
	IType type = selectType(this.workingCopies[0], "Row");
10047
	IType type = selectType(this.workingCopies[0], "Row");
9954
	search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10048
	search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9955
	assertSearchResults(
10049
	assertSearchResults(
Lines 9975-9982 Link Here
9975
		"	}\n" +
10069
		"	}\n" +
9976
		"}\n"
10070
		"}\n"
9977
	);
10071
	);
9978
	this.resultCollector.showSelection = true;
10072
	this.resultCollector.showSelection();
9979
	this.resultCollector.showRule = true;
10073
	this.resultCollector.showRule();
9980
	SearchPattern typePattern = SearchPattern.createPattern("test", TYPE, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
10074
	SearchPattern typePattern = SearchPattern.createPattern("test", TYPE, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
9981
	SearchPattern methPattern = SearchPattern.createPattern("test", METHOD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
10075
	SearchPattern methPattern = SearchPattern.createPattern("test", METHOD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
9982
	SearchPattern fieldPattern = SearchPattern.createPattern("test", FIELD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
10076
	SearchPattern fieldPattern = SearchPattern.createPattern("test", FIELD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH);
Lines 10014-10021 Link Here
10014
		"public class Y<T extends X<?>> {\n" +
10108
		"public class Y<T extends X<?>> {\n" +
10015
		"}\n"
10109
		"}\n"
10016
	);
10110
	);
10017
	this.resultCollector.showSelection = true;
10111
	this.resultCollector.showSelection();
10018
	this.resultCollector.showRule = true;
10112
	this.resultCollector.showRule();
10019
	IType type = this.workingCopies[0].getType("X");
10113
	IType type = this.workingCopies[0].getType("X");
10020
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10114
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10021
	assertSearchResults(
10115
	assertSearchResults(
Lines 10036-10043 Link Here
10036
		"public class Z<T extends X<?> & I<?>> {\n" +
10130
		"public class Z<T extends X<?> & I<?>> {\n" +
10037
		"}\n"
10131
		"}\n"
10038
	);
10132
	);
10039
	this.resultCollector.showSelection = true;
10133
	this.resultCollector.showSelection();
10040
	this.resultCollector.showRule = true;
10134
	this.resultCollector.showRule();
10041
	IType type = this.workingCopies[0].getType("I");
10135
	IType type = this.workingCopies[0].getType("I");
10042
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10136
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10043
	assertSearchResults(
10137
	assertSearchResults(
Lines 10107-10113 Link Here
10107
		"\n" +
10201
		"\n" +
10108
		"}\n"
10202
		"}\n"
10109
	);
10203
	);
10110
	this.resultCollector.showSelection = true;
10204
	this.resultCollector.showSelection();
10111
	IType type = this.workingCopies[0].getType("Test");
10205
	IType type = this.workingCopies[0].getType("Test");
10112
	search(type, REFERENCES, getJavaSearchWorkingCopiesScope());
10206
	search(type, REFERENCES, getJavaSearchWorkingCopiesScope());
10113
10207
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchGenericFieldTests.java (-1 / +1 lines)
Lines 30-36 Link Here
30
30
31
protected void setUp () throws Exception {
31
protected void setUp () throws Exception {
32
	super.setUp();
32
	super.setUp();
33
	this.resultCollector.showAccuracy = true;
33
	this.resultCollector.showAccuracy(true);
34
}
34
}
35
35
36
/**
36
/**
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchScopeTests.java (-6 / +6 lines)
Lines 16-22 Link Here
16
16
17
import org.eclipse.core.resources.IncrementalProjectBuilder;
17
import org.eclipse.core.resources.IncrementalProjectBuilder;
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.Path;
20
import org.eclipse.jdt.core.*;
19
import org.eclipse.jdt.core.*;
21
import org.eclipse.jdt.core.search.*;
20
import org.eclipse.jdt.core.search.*;
22
import org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector;
21
import org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector;
Lines 873-879 Link Here
873
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFolder("/P1/test"));
872
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFolder("/P1/test"));
874
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});
873
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});
875
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
874
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
876
		resultCollector.showProject = true;
875
		resultCollector.showProject();
877
		search("foo", METHOD, DECLARATIONS, scope, resultCollector);
876
		search("foo", METHOD, DECLARATIONS, scope, resultCollector);
878
		assertSearchResults(
877
		assertSearchResults(
879
			"test/Test.java [in P1] void Test.foo() [foo]",
878
			"test/Test.java [in P1] void Test.foo() [foo]",
Lines 910-916 Link Here
910
		);
909
		);
911
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
910
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
912
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
911
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
913
		resultCollector.showProject = true;
912
		resultCollector.showProject();
914
		search("ITest", TYPE, REFERENCES, scope, resultCollector);
913
		search("ITest", TYPE, REFERENCES, scope, resultCollector);
915
		assertSearchResults(
914
		assertSearchResults(
916
			"test/Test.java [in P1] Test.test [ITest]\n" +
915
			"test/Test.java [in P1] Test.test [ITest]\n" +
Lines 947-953 Link Here
947
		assertNotNull("We should have a default fragment for project P1!", defaultFragment);
946
		assertNotNull("We should have a default fragment for project P1!", defaultFragment);
948
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {defaultFragment});
947
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {defaultFragment});
949
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
948
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
950
		resultCollector.showProject = true;
949
		resultCollector.showProject();
951
		search("main(String[]) void", METHOD, DECLARATIONS, scope, resultCollector);
950
		search("main(String[]) void", METHOD, DECLARATIONS, scope, resultCollector);
952
		assertSearchResults(
951
		assertSearchResults(
953
			"Test.java [in P1] void Test.main(String[]) [main]",
952
			"Test.java [in P1] void Test.main(String[]) [main]",
Lines 982-988 Link Here
982
		);
981
		);
983
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project });
982
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project });
984
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
983
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
985
		resultCollector.showProject = true;
984
		resultCollector.showProject();
986
		search("Test", TYPE, REFERENCES, scope, resultCollector);
985
		search("Test", TYPE, REFERENCES, scope, resultCollector);
987
		assertSearchResults(
986
		assertSearchResults(
988
			"src/X.java [in P1] X.test [Test]",
987
			"src/X.java [in P1] X.test [Test]",
Lines 1023-1029 Link Here
1023
1022
1024
		// Index the output location as it is a library for the project
1023
		// Index the output location as it is a library for the project
1025
		IndexManager indexManager = JavaModelManager.getIndexManager();
1024
		IndexManager indexManager = JavaModelManager.getIndexManager();
1026
		indexManager.indexLibrary(new Path("/P1/bin"), project.getProject());
1025
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getWorkspaceRoot().findMember("/P1/bin"));
1026
		indexManager.indexPackageFragmentRoot(root);
1027
		waitUntilIndexesReady();
1027
		waitUntilIndexesReady();
1028
1028
1029
		// Search for all types
1029
		// Search for all types
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java (-18 / +18 lines)
Lines 63-72 Link Here
63
protected void setUp () throws Exception {
63
protected void setUp () throws Exception {
64
	super.setUp();
64
	super.setUp();
65
	this.resultCollector = new JavaSearchResultCollector();
65
	this.resultCollector = new JavaSearchResultCollector();
66
	this.resultCollector.showInsideDoc = false;
66
//	this.resultCollector.showInsideDoc = false;
67
	this.resultCollector.showAccuracy = true;
67
	this.resultCollector.showAccuracy(true);
68
	this.resultCollector.showSelection = true;
68
	this.resultCollector.showSelection();
69
	this.resultCollector.showOffset = true;
69
	this.resultCollector.showOffset();
70
}
70
}
71
71
72
static {
72
static {
Lines 112-119 Link Here
112
		"----------\n",
112
		"----------\n",
113
		problemRequestor.problems.toString()
113
		problemRequestor.problems.toString()
114
	);
114
	);
115
	this.resultCollector.showSelection = true;
115
	this.resultCollector.showSelection();
116
	this.resultCollector.showOffset = true;
116
	this.resultCollector.showOffset();
117
	return this.workingCopies[0].getType("Fields").getField("field");
117
	return this.workingCopies[0].getType("Fields").getField("field");
118
}
118
}
119
public void testFieldRef() throws CoreException {
119
public void testFieldRef() throws CoreException {
Lines 193-200 Link Here
193
		"----------\n",
193
		"----------\n",
194
		problemRequestor.problems.toString()
194
		problemRequestor.problems.toString()
195
	);
195
	);
196
	this.resultCollector.showSelection = true;
196
	this.resultCollector.showSelection();
197
	this.resultCollector.showOffset = true;
197
	this.resultCollector.showOffset();
198
	return this.workingCopies[0].getType("Methods").getMethod("method", new String[0]);
198
	return this.workingCopies[0].getType("Methods").getMethod("method", new String[0]);
199
}
199
}
200
public void testMethodRef() throws CoreException {
200
public void testMethodRef() throws CoreException {
Lines 574-581 Link Here
574
		"----------\n",
574
		"----------\n",
575
		problemRequestor.problems.toString()
575
		problemRequestor.problems.toString()
576
	);
576
	);
577
	this.resultCollector.showSelection = true;
577
	this.resultCollector.showSelection();
578
	this.resultCollector.showOffset = true;
578
	this.resultCollector.showOffset();
579
}
579
}
580
public void testTypeRefAll_Allocation() throws CoreException {
580
public void testTypeRefAll_Allocation() throws CoreException {
581
	setUpTypeRefAll();
581
	setUpTypeRefAll();
Lines 749-756 Link Here
749
		"----------\n",
749
		"----------\n",
750
		problemRequestor.problems.toString()
750
		problemRequestor.problems.toString()
751
	);
751
	);
752
	this.resultCollector.showSelection = true;
752
	this.resultCollector.showSelection();
753
	this.resultCollector.showOffset = true;
753
	this.resultCollector.showOffset();
754
	return this.workingCopies[0].getType("Types");
754
	return this.workingCopies[0].getType("Types");
755
}
755
}
756
public void testTypeRefGeneric01() throws CoreException {
756
public void testTypeRefGeneric01() throws CoreException {
Lines 970-977 Link Here
970
		"----------\n",
970
		"----------\n",
971
		problemRequestor.problems.toString()
971
		problemRequestor.problems.toString()
972
	);
972
	);
973
	this.resultCollector.showSelection = true;
973
	this.resultCollector.showSelection();
974
	this.resultCollector.showOffset = true;
974
	this.resultCollector.showOffset();
975
	return this.workingCopies[0].getType("Types");
975
	return this.workingCopies[0].getType("Types");
976
}
976
}
977
public void testTypeRefGenericAll02() throws CoreException {
977
public void testTypeRefGenericAll02() throws CoreException {
Lines 1154-1161 Link Here
1154
		"----------\n",
1154
		"----------\n",
1155
		problemRequestor.problems.toString()
1155
		problemRequestor.problems.toString()
1156
	);
1156
	);
1157
	this.resultCollector.showSelection = true;
1157
	this.resultCollector.showSelection();
1158
	this.resultCollector.showOffset = true;
1158
	this.resultCollector.showOffset();
1159
}
1159
}
1160
public void testTypeRefGenericMethod_AllGenericFlags() throws CoreException {
1160
public void testTypeRefGenericMethod_AllGenericFlags() throws CoreException {
1161
	setUpTypeRefGenericMethod();
1161
	setUpTypeRefGenericMethod();
Lines 1279-1286 Link Here
1279
		"----------\n",
1279
		"----------\n",
1280
		problemRequestor.problems.toString()
1280
		problemRequestor.problems.toString()
1281
	);
1281
	);
1282
	this.resultCollector.showSelection = true;
1282
	this.resultCollector.showSelection();
1283
	this.resultCollector.showOffset = true;
1283
	this.resultCollector.showOffset();
1284
}
1284
}
1285
public void testTypeRefQualifiedAll_Allocation() throws CoreException {
1285
public void testTypeRefQualifiedAll_Allocation() throws CoreException {
1286
	setUpTypeRefQualifiedAll();
1286
	setUpTypeRefQualifiedAll();
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java (-23 / +23 lines)
Lines 96-102 Link Here
96
96
97
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2});
97
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2});
98
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
98
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
99
		resultCollector.showProject = true;
99
		resultCollector.showProject();
100
		IField field = wc1.getType("X").getField("BAR");
100
		IField field = wc1.getType("X").getField("BAR");
101
		SearchPattern pattern = SearchPattern.createPattern(field, ALL_OCCURRENCES);
101
		SearchPattern pattern = SearchPattern.createPattern(field, ALL_OCCURRENCES);
102
		new SearchEngine(new ICompilationUnit[] {wc1, wc2}).search(
102
		new SearchEngine(new ICompilationUnit[] {wc1, wc2}).search(
Lines 154-160 Link Here
154
		IMethod method = type.getMethod("foo", new String[] {});
154
		IMethod method = type.getMethod("foo", new String[] {});
155
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
155
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
156
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
156
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
157
		resultCollector.showProject = true;
157
		resultCollector.showProject();
158
		search(
158
		search(
159
			method,
159
			method,
160
			REFERENCES,
160
			REFERENCES,
Lines 209-215 Link Here
209
		IMethod method = type.getMethod("foo", new String[] {});
209
		IMethod method = type.getMethod("foo", new String[] {});
210
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
210
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
211
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
211
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
212
		resultCollector.showProject = true;
212
		resultCollector.showProject();
213
		search(
213
		search(
214
			method,
214
			method,
215
			REFERENCES,
215
			REFERENCES,
Lines 257-263 Link Here
257
		IMethod method = type.getMethod("foo", new String[] {});
257
		IMethod method = type.getMethod("foo", new String[] {});
258
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
258
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
259
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
259
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
260
		resultCollector.showProject = true;
260
		resultCollector.showProject();
261
		search(
261
		search(
262
			method,
262
			method,
263
			REFERENCES,
263
			REFERENCES,
Lines 334-341 Link Here
334
		IMethod method = type.getMethod("foo", new String[] {});
334
		IMethod method = type.getMethod("foo", new String[] {});
335
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
335
		IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
336
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
336
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
337
		resultCollector.showAccuracy = true;
337
		resultCollector.showAccuracy(true);
338
		resultCollector.showProject = true;
338
		resultCollector.showProject();
339
		search(
339
		search(
340
			method,
340
			method,
341
			REFERENCES,
341
			REFERENCES,
Lines 379-385 Link Here
379
379
380
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2});
380
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2});
381
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
381
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
382
		resultCollector.showProject = true;
382
		resultCollector.showProject();
383
		IMethod method = getCompilationUnit("/P1/p/I.java").getType("I").getMethod("method", new String[] {"QObject;"});
383
		IMethod method = getCompilationUnit("/P1/p/I.java").getType("I").getMethod("method", new String[] {"QObject;"});
384
		search(
384
		search(
385
			method,
385
			method,
Lines 418-424 Link Here
418
418
419
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2});
419
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2});
420
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
420
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
421
		resultCollector.showProject = true;
421
		resultCollector.showProject();
422
		IPackageFragment pkg = getPackage("/P1/p");
422
		IPackageFragment pkg = getPackage("/P1/p");
423
		search(
423
		search(
424
			pkg,
424
			pkg,
Lines 639-645 Link Here
639
639
640
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1});
640
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1});
641
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
641
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
642
		resultCollector.showProject = true;
642
		resultCollector.showProject();
643
		search(
643
		search(
644
			"Object",
644
			"Object",
645
			TYPE,
645
			TYPE,
Lines 653-659 Link Here
653
653
654
		scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2});
654
		scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2});
655
		resultCollector = new JavaSearchResultCollector();
655
		resultCollector = new JavaSearchResultCollector();
656
		resultCollector.showProject = true;
656
		resultCollector.showProject();
657
		search(
657
		search(
658
			"Object",
658
			"Object",
659
			TYPE,
659
			TYPE,
Lines 712-718 Link Here
712
		// search method declaration in workspace scope
712
		// search method declaration in workspace scope
713
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2});
713
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2});
714
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
714
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
715
		resultCollector.showProject = true;
715
		resultCollector.showProject();
716
		search(
716
		search(
717
			method,
717
			method,
718
			DECLARATIONS,
718
			DECLARATIONS,
Lines 725-731 Link Here
725
725
726
		// search method declaration in workspace scope with JDT-UI flags
726
		// search method declaration in workspace scope with JDT-UI flags
727
		resultCollector = new JavaSearchResultCollector();
727
		resultCollector = new JavaSearchResultCollector();
728
		resultCollector.showProject = true;
728
		resultCollector.showProject();
729
		search(
729
		search(
730
			method,
730
			method,
731
			UI_DECLARATIONS,
731
			UI_DECLARATIONS,
Lines 780-786 Link Here
780
		// search method declaration in project scope
780
		// search method declaration in project scope
781
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2});
781
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2});
782
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
782
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
783
		resultCollector.showProject = true;
783
		resultCollector.showProject();
784
		search(
784
		search(
785
			method,
785
			method,
786
			UI_DECLARATIONS,
786
			UI_DECLARATIONS,
Lines 857-864 Link Here
857
		// search method declaration in workspace scope
857
		// search method declaration in workspace scope
858
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2});
858
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2});
859
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
859
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
860
		resultCollector.showProject = true;
860
		resultCollector.showProject();
861
		resultCollector.showAccuracy = true;
861
		resultCollector.showAccuracy(true);
862
		search(method, REFERENCES, scope, resultCollector);
862
		search(method, REFERENCES, scope, resultCollector);
863
		assertSearchResults(
863
		assertSearchResults(
864
			"Unexpected references of method Test.getType()",
864
			"Unexpected references of method Test.getType()",
Lines 937-944 Link Here
937
		// Create scope and search
937
		// Create scope and search
938
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p1, p2 }, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.REFERENCED_PROJECTS);
938
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p1, p2 }, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.REFERENCED_PROJECTS);
939
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
939
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
940
		resultCollector.showProject = true;
940
		resultCollector.showProject();
941
		resultCollector.showAccuracy = true;
941
		resultCollector.showAccuracy(true);
942
		new SearchEngine().search(
942
		new SearchEngine().search(
943
			SearchPattern.createPattern("toString", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH),
943
			SearchPattern.createPattern("toString", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH),
944
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
944
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 965-972 Link Here
965
		// Create scope and search
965
		// Create scope and search
966
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p1, p2, p3 }, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.REFERENCED_PROJECTS);
966
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p1, p2, p3 }, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.REFERENCED_PROJECTS);
967
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
967
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
968
		resultCollector.showProject = true;
968
		resultCollector.showProject();
969
		resultCollector.showAccuracy = true;
969
		resultCollector.showAccuracy(true);
970
		new SearchEngine().search(
970
		new SearchEngine().search(
971
			SearchPattern.createPattern("toString", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH),
971
			SearchPattern.createPattern("toString", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH),
972
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
972
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 1258-1265 Link Here
1258
		SearchPattern leftPattern = SearchPattern.createPattern(typeA1, REFERENCES);
1258
		SearchPattern leftPattern = SearchPattern.createPattern(typeA1, REFERENCES);
1259
		SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
1259
		SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
1260
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
1260
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
1261
		resultCollector.showProject = true;
1261
		resultCollector.showProject();
1262
		resultCollector.showAccuracy = true;
1262
		resultCollector.showAccuracy(true);
1263
		new SearchEngine().search(
1263
		new SearchEngine().search(
1264
			pattern,
1264
			pattern,
1265
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
1265
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 1322-1329 Link Here
1322
		// search annotation type reference in P2 scope
1322
		// search annotation type reference in P2 scope
1323
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}, false/*don't include referenced projects*/);
1323
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}, false/*don't include referenced projects*/);
1324
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
1324
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
1325
		resultCollector.showProject = true;
1325
		resultCollector.showProject();
1326
		resultCollector.showAccuracy = true;
1326
		resultCollector.showAccuracy(true);
1327
		search(type, ANNOTATION_TYPE_REFERENCE, scope, resultCollector);
1327
		search(type, ANNOTATION_TYPE_REFERENCE, scope, resultCollector);
1328
		assertSearchResults(
1328
		assertSearchResults(
1329
			"Unexpected references of annotation type MyAnnot",
1329
			"Unexpected references of annotation type MyAnnot",
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (-21 / +85 lines)
Lines 24-29 Link Here
24
import org.eclipse.jdt.core.compiler.CharOperation;
24
import org.eclipse.jdt.core.compiler.CharOperation;
25
import org.eclipse.jdt.core.search.*;
25
import org.eclipse.jdt.core.search.*;
26
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
26
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
27
import org.eclipse.jdt.internal.core.Member;
27
import org.eclipse.jdt.internal.core.PackageFragment;
28
import org.eclipse.jdt.internal.core.PackageFragment;
28
//import org.eclipse.jdt.internal.core.ResolvedSourceMethod;
29
//import org.eclipse.jdt.internal.core.ResolvedSourceMethod;
29
//import org.eclipse.jdt.internal.core.ResolvedSourceType;
30
//import org.eclipse.jdt.internal.core.ResolvedSourceType;
Lines 47-68 Link Here
47
//	boolean discard;
48
//	boolean discard;
48
49
49
	/**
50
	/**
51
	 * Flags for the default search result collector
52
	 */
53
	static protected final int SHOW_ACCURACY		= 0x0001;
54
	static protected final int SHOW_SELECTION		= 0x0002;
55
	static protected final int SHOW_RULE					= 0x0004;
56
	static protected final int SHOW_INSIDE_DOC		= 0x0008;
57
	static protected final int SHOW_POTENTIAL		= 0x0010;
58
	static protected final int SHOW_PROJECT			= 0x0020;
59
	static protected final int SHOW_SYNTHETIC		= 0x0040;
60
	static protected final int SHOW_OFFSET				= 0x0080;
61
	static protected final int SHOW_ACCESS				= 0x0100;
62
	static protected final int SHOW_MATCH_KIND	= 0x0200;
63
	static protected final int SHOW_JAR_FILE			= 0x0400;
64
65
	/**
50
	 * Collects results as a string.
66
	 * Collects results as a string.
51
	 */
67
	 */
52
	public static class JavaSearchResultCollector extends SearchRequestor {
68
	public static class JavaSearchResultCollector extends SearchRequestor {
69
		int flags = SHOW_POTENTIAL; // default
53
		protected SearchMatch match;
70
		protected SearchMatch match;
54
		public StringBuffer results = new StringBuffer(), line;
71
		public StringBuffer results = new StringBuffer(), line;
55
		public boolean showAccuracy;
56
		public boolean showSelection;
57
		public boolean showRule;
58
		public boolean showInsideDoc;
59
		public boolean showPotential = true;
60
		public boolean showProject;
61
		public boolean showSynthetic;
62
		public boolean showOffset = false;
63
		public boolean showAccess = false;
64
		public int showFlavors = 0;
72
		public int showFlavors = 0;
65
		public boolean showMatchKind = false;
66
		public int count = 0;
73
		public int count = 0;
67
		List lines = new ArrayList();
74
		List lines = new ArrayList();
68
		boolean sorted;
75
		boolean sorted;
Lines 76-82 Link Here
76
			this.count++;
83
			this.count++;
77
			this.match = searchMatch;
84
			this.match = searchMatch;
78
			writeLine();
85
			writeLine();
79
			if (this.line != null && (this.match.getAccuracy() == SearchMatch.A_ACCURATE || this.showPotential)) {
86
			if (this.line != null && (this.match.getAccuracy() == SearchMatch.A_ACCURATE || (this.flags & SHOW_POTENTIAL) != 0)) {
80
				this.lines.add(this.line);
87
				this.lines.add(this.line);
81
			}
88
			}
82
		}
89
		}
Lines 88-100 Link Here
88
				IResource resource = this.match.getResource();
95
				IResource resource = this.match.getResource();
89
				IJavaElement element = getElement(this.match);
96
				IJavaElement element = getElement(this.match);
90
				this.line = new StringBuffer();
97
				this.line = new StringBuffer();
91
				if (this.showMatchKind) {
98
				if ((this.flags & SHOW_MATCH_KIND) != 0) {
92
					String matchClassName = this.match.getClass().getName();
99
					String matchClassName = this.match.getClass().getName();
93
					this.line.append(matchClassName.substring(matchClassName.lastIndexOf('.')+1));
100
					this.line.append(matchClassName.substring(matchClassName.lastIndexOf('.')+1));
94
					this.line.append(": ");
101
					this.line.append(": ");
95
				}
102
				}
96
				this.line.append(getPathString(resource, element));
103
				this.line.append(getPathString(resource, element));
97
				if (this.showProject) {
104
				if ((this.flags & SHOW_PROJECT) != 0) {
98
					IProject project = element.getJavaProject().getProject();
105
					IProject project = element.getJavaProject().getProject();
99
					this.line.append(" [in ");
106
					this.line.append(" [in ");
100
					this.line.append(project.getName());
107
					this.line.append(project.getName());
Lines 174-180 Link Here
174
					if (start == -1 || (contents != null && contents.length > 0)) { // retrieving attached source not implemented here
181
					if (start == -1 || (contents != null && contents.length > 0)) { // retrieving attached source not implemented here
175
						this.line.append(" [");
182
						this.line.append(" [");
176
						if (start > -1) {
183
						if (start > -1) {
177
							if (this.showSelection) {
184
							if ((this.flags & SHOW_SELECTION) != 0) {
178
								int lineStart1 = CharOperation.lastIndexOf('\n', contents, 0, start);
185
								int lineStart1 = CharOperation.lastIndexOf('\n', contents, 0, start);
179
								int lineStart2 = CharOperation.lastIndexOf('\r', contents, 0, start);
186
								int lineStart2 = CharOperation.lastIndexOf('\r', contents, 0, start);
180
								int lineStart = Math.max(lineStart1, lineStart2) + 1;
187
								int lineStart = Math.max(lineStart1, lineStart2) + 1;
Lines 182-188 Link Here
182
								this.line.append("§|");
189
								this.line.append("§|");
183
							}
190
							}
184
							this.line.append(CharOperation.subarray(contents, start, end));
191
							this.line.append(CharOperation.subarray(contents, start, end));
185
							if (this.showSelection) {
192
							if ((this.flags & SHOW_SELECTION) != 0) {
186
								this.line.append("|§");
193
								this.line.append("|§");
187
								int lineEnd1 = CharOperation.indexOf('\n', contents, end);
194
								int lineEnd1 = CharOperation.indexOf('\n', contents, end);
188
								int lineEnd2 = CharOperation.indexOf('\r', contents, end);
195
								int lineEnd2 = CharOperation.indexOf('\r', contents, end);
Lines 190-196 Link Here
190
								if (lineEnd == -1) lineEnd = contents.length;
197
								if (lineEnd == -1) lineEnd = contents.length;
191
								this.line.append(CharOperation.subarray(contents, end, lineEnd));
198
								this.line.append(CharOperation.subarray(contents, end, lineEnd));
192
							}
199
							}
193
							if (this.showOffset) {
200
							if ((this.flags & SHOW_OFFSET) != 0) {
194
								this.line.append('@');
201
								this.line.append('@');
195
								this.line.append(start);
202
								this.line.append(start);
196
							}
203
							}
Lines 200-209 Link Here
200
						this.line.append("]");
207
						this.line.append("]");
201
					}
208
					}
202
				}
209
				}
203
				if (this.showAccuracy) {
210
				if ((this.flags & SHOW_ACCURACY) != 0) {
204
					this.line.append(" ");
211
					this.line.append(" ");
205
					if (this.match.getAccuracy() == SearchMatch.A_ACCURATE) {
212
					if (this.match.getAccuracy() == SearchMatch.A_ACCURATE) {
206
						if (this.showRule) {
213
						if ((this.flags & SHOW_RULE) != 0) {
207
							if (this.match.isExact()) {
214
							if (this.match.isExact()) {
208
								this.line.append("EXACT_");
215
								this.line.append("EXACT_");
209
							} else if (this.match.isEquivalent()) {
216
							} else if (this.match.isEquivalent()) {
Lines 224-230 Link Here
224
						this.line.append("POTENTIAL_MATCH");
231
						this.line.append("POTENTIAL_MATCH");
225
					}
232
					}
226
				}
233
				}
227
				if (this.showInsideDoc) {
234
				if ((this.flags & SHOW_INSIDE_DOC) != 0) {
228
					this.line.append(" ");
235
					this.line.append(" ");
229
					if (this.match.isInsideDocComment()) {
236
					if (this.match.isInsideDocComment()) {
230
						this.line.append("INSIDE_JAVADOC");
237
						this.line.append("INSIDE_JAVADOC");
Lines 232-238 Link Here
232
						this.line.append("OUTSIDE_JAVADOC");
239
						this.line.append("OUTSIDE_JAVADOC");
233
					}
240
					}
234
				}
241
				}
235
				if (this.showSynthetic) {
242
				if ((this.flags & SHOW_SYNTHETIC) != 0) {
236
					if (this.match instanceof MethodReferenceMatch) {
243
					if (this.match instanceof MethodReferenceMatch) {
237
						MethodReferenceMatch methRef = (MethodReferenceMatch) this.match;
244
						MethodReferenceMatch methRef = (MethodReferenceMatch) this.match;
238
						if (methRef.isSynthetic()) {
245
						if (methRef.isSynthetic()) {
Lines 248-254 Link Here
248
						}
255
						}
249
					}
256
					}
250
				}
257
				}
251
				if (this.showAccess) {
258
				if ((this.flags & SHOW_ACCESS) != 0) {
252
					if (this.match instanceof FieldReferenceMatch) {
259
					if (this.match instanceof FieldReferenceMatch) {
253
						FieldReferenceMatch fieldRef = (FieldReferenceMatch) this.match;
260
						FieldReferenceMatch fieldRef = (FieldReferenceMatch) this.match;
254
						if (fieldRef.isReadAccess()) {
261
						if (fieldRef.isReadAccess()) {
Lines 277-282 Link Here
277
		private boolean showSuperInvocation() {
284
		private boolean showSuperInvocation() {
278
			return (this.showFlavors & PatternLocator.SUPER_INVOCATION_FLAVOR) != 0;
285
			return (this.showFlavors & PatternLocator.SUPER_INVOCATION_FLAVOR) != 0;
279
		}
286
		}
287
		public void showAccess() {
288
			this.flags |= SHOW_ACCESS;
289
		}
290
		public void showAccuracy(boolean on) {
291
			if (on) {
292
				this.flags |= SHOW_ACCURACY;
293
			} else {
294
				this.flags &= ~SHOW_ACCURACY;
295
			}
296
		}
297
		public void showInsideDoc() {
298
			this.flags |= SHOW_INSIDE_DOC;
299
		}
300
		public void showJarFile() {
301
			this.flags |= SHOW_JAR_FILE;
302
		}
303
		public void showMatchKind() {
304
			this.flags |= SHOW_MATCH_KIND;
305
		}
306
		public void showOffset() {
307
			this.flags |= SHOW_OFFSET;
308
		}
309
		public void showPotential(boolean on) {
310
			if (on) {
311
				this.flags |= SHOW_POTENTIAL;
312
			} else {
313
				this.flags &= ~SHOW_POTENTIAL;
314
			}
315
		}
316
		public void showProject() {
317
			this.flags |= SHOW_PROJECT;
318
		}
319
		public void showRule() {
320
			this.flags |= SHOW_RULE;
321
		}
322
		public void showSelection() {
323
			this.flags |= SHOW_SELECTION;
324
		}
325
		public void showSynthetic() {
326
			this.flags |= SHOW_SYNTHETIC;
327
		}
280
		protected void append(IAnnotation annotation) throws JavaModelException {
328
		protected void append(IAnnotation annotation) throws JavaModelException {
281
			this.line.append("@");
329
			this.line.append("@");
282
			this.line.append(annotation.getElementName());
330
			this.line.append(annotation.getElementName());
Lines 405-410 Link Here
405
			String pathString;
453
			String pathString;
406
			if (resource != null) {
454
			if (resource != null) {
407
				IPath path = resource.getProjectRelativePath();
455
				IPath path = resource.getProjectRelativePath();
456
				if ((this.flags & SHOW_JAR_FILE) != 0 && element instanceof Member) {
457
					IPackageFragmentRoot pkgFragmentRoot = null;
458
					try {
459
		                pkgFragmentRoot = element.getJavaProject().findPackageFragmentRoot(resource.getFullPath());
460
	                } catch (JavaModelException e) {
461
		                // ignore
462
	                }
463
					if (pkgFragmentRoot != null && pkgFragmentRoot.isArchive()) {
464
						if (pkgFragmentRoot.isExternal()) {
465
							pathString = pkgFragmentRoot.getPath().toOSString();
466
						} else {
467
							pathString = path.toString();
468
						}
469
						return pathString + "|" + ((Member)element).getTypeRoot().getElementName();
470
					}
471
				}
408
				if (path.segmentCount() == 0) {
472
				if (path.segmentCount() == 0) {
409
					IJavaElement root = element;
473
					IJavaElement root = element;
410
					while (root != null && !(root instanceof IPackageFragmentRoot)) {
474
					while (root != null && !(root instanceof IPackageFragmentRoot)) {
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchGenericTypeTests.java (-2 / +2 lines)
Lines 47-54 Link Here
47
47
48
	protected void setUp () throws Exception {
48
	protected void setUp () throws Exception {
49
		super.setUp();
49
		super.setUp();
50
		this.resultCollector.showAccuracy = true;
50
		this.resultCollector.showAccuracy(true);
51
		this.resultCollector.showRule = true;
51
		this.resultCollector.showRule();
52
	}
52
	}
53
53
54
	/*
54
	/*
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java (-11 / +11 lines)
Lines 43-50 Link Here
43
		super.setUp();
43
		super.setUp();
44
		this.originalOptions = JAVA_PROJECT.getOptions(true);
44
		this.originalOptions = JAVA_PROJECT.getOptions(true);
45
		JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
45
		JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
46
		this.resultCollector.showAccuracy = true;
46
		this.resultCollector.showAccuracy(true);
47
		this.resultCollector.showInsideDoc = true;
47
		this.resultCollector.showInsideDoc();
48
	}
48
	}
49
	/* (non-Javadoc)
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#tearDownSuite()
50
	 * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#tearDownSuite()
Lines 857-864 Link Here
857
	 */
857
	 */
858
	public void testBug54962() throws CoreException {
858
	public void testBug54962() throws CoreException {
859
		setJavadocOptions();
859
		setJavadocOptions();
860
		this.resultCollector.showInsideDoc = true;
860
		this.resultCollector.showInsideDoc();
861
		this.resultCollector.showSelection = true;
861
		this.resultCollector.showSelection();
862
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "j6", "Bug54962.java").getPackageDeclaration("j6");
862
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "j6", "Bug54962.java").getPackageDeclaration("j6");
863
		search(packDecl, REFERENCES, getJavaSearchScope());
863
		search(packDecl, REFERENCES, getJavaSearchScope());
864
		assertSearchResults(
864
		assertSearchResults(
Lines 871-878 Link Here
871
	//	TODO (frederic) should no longer get POTENTIAL after 196200 got fixed
871
	//	TODO (frederic) should no longer get POTENTIAL after 196200 got fixed
872
	public void testBug54962qualified() throws CoreException {
872
	public void testBug54962qualified() throws CoreException {
873
		setJavadocOptions();
873
		setJavadocOptions();
874
		this.resultCollector.showInsideDoc = true;
874
		this.resultCollector.showInsideDoc();
875
		this.resultCollector.showSelection = true;
875
		this.resultCollector.showSelection();
876
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "j7.qua.li.fied", "Bug54962a.java").getPackageDeclaration("j7.qua.li.fied");
876
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "j7.qua.li.fied", "Bug54962a.java").getPackageDeclaration("j7.qua.li.fied");
877
		search(packDecl, REFERENCES, getJavaSearchScope());
877
		search(packDecl, REFERENCES, getJavaSearchScope());
878
		assertSearchResults(
878
		assertSearchResults(
Lines 889-895 Link Here
889
	 */
889
	 */
890
	public void testBug71267() throws CoreException {
890
	public void testBug71267() throws CoreException {
891
		setJavadocOptions();
891
		setJavadocOptions();
892
		this.resultCollector.showInsideDoc = true;
892
		this.resultCollector.showInsideDoc();
893
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267");
893
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267");
894
		search(packDecl, REFERENCES, getJavaSearchScope());
894
		search(packDecl, REFERENCES, getJavaSearchScope());
895
		assertSearchResults(
895
		assertSearchResults(
Lines 900-906 Link Here
900
	}
900
	}
901
	public void testBug71267qualified() throws CoreException {
901
	public void testBug71267qualified() throws CoreException {
902
		setJavadocOptions();
902
		setJavadocOptions();
903
		this.resultCollector.showInsideDoc = true;
903
		this.resultCollector.showInsideDoc();
904
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267.q71267", "Test.java").getPackageDeclaration("p71267.q71267");
904
		IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267.q71267", "Test.java").getPackageDeclaration("p71267.q71267");
905
		search(packDecl, REFERENCES, getJavaSearchScope());
905
		search(packDecl, REFERENCES, getJavaSearchScope());
906
		assertSearchResults(
906
		assertSearchResults(
Lines 918-924 Link Here
918
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83285"
918
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83285"
919
	 */
919
	 */
920
	public void testBug83285() throws CoreException {
920
	public void testBug83285() throws CoreException {
921
		this.resultCollector.showRule = true;
921
		this.resultCollector.showRule();
922
		this.workingCopies = new ICompilationUnit[1];
922
		this.workingCopies = new ICompilationUnit[1];
923
		this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java",
923
		this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java",
924
			"package b83285;\n" +
924
			"package b83285;\n" +
Lines 941-947 Link Here
941
		);
941
		);
942
	}
942
	}
943
	public void testBug83285a() throws CoreException {
943
	public void testBug83285a() throws CoreException {
944
		this.resultCollector.showRule = true;
944
		this.resultCollector.showRule();
945
		this.workingCopies = new ICompilationUnit[1];
945
		this.workingCopies = new ICompilationUnit[1];
946
		this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java",
946
		this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java",
947
			"package b83285;\n" +
947
			"package b83285;\n" +
Lines 974-980 Link Here
974
		);
974
		);
975
	}
975
	}
976
	public void testBug83285b() throws CoreException {
976
	public void testBug83285b() throws CoreException {
977
		this.resultCollector.showRule = true;
977
		this.resultCollector.showRule();
978
		this.workingCopies = new ICompilationUnit[1];
978
		this.workingCopies = new ICompilationUnit[1];
979
		this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java",
979
		this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java",
980
			"package b83285;\n" +
980
			"package b83285;\n" +
(-)model/org/eclipse/jdt/internal/core/SourceMapper.java (-1 / +112 lines)
Lines 934-940 Link Here
934
	}
934
	}
935
935
936
936
937
938
	/**
937
	/**
939
	 * Returns the SourceRange for the name of the given element, or
938
	 * Returns the SourceRange for the name of the given element, or
940
	 * {-1, -1} if no source range is known for the name of the element.
939
	 * {-1, -1} if no source range is known for the name of the element.
Lines 1327-1330 Link Here
1327
		return false;
1326
		return false;
1328
	}
1327
	}
1329
1328
1329
	//***************************************************************
1330
1331
	/**
1332
	 * Locates and returns source code for the given (binary) type, in this
1333
	 * SourceMapper's ZIP file, or returns <code>null</code> if source
1334
	 * code cannot be found.
1335
	 */
1336
	public Object findSourceFile(IType type, IBinaryType info) {
1337
		if (!type.isBinary()) {
1338
			return null;
1339
		}
1340
		String simpleSourceFileName = ((BinaryType) type).getSourceFileName(info);
1341
		if (simpleSourceFileName == null) {
1342
			return null;
1343
		}
1344
		return findSourceFile(type, simpleSourceFileName);
1345
	}
1346
1347
	/**
1348
	 * Locates and returns source code for the given (binary) type, in this
1349
	 * SourceMapper's ZIP file, or returns <code>null</code> if source
1350
	 * code cannot be found.
1351
	 * The given simpleSourceFileName is the .java file name (without the enclosing
1352
	 * folder) used to create the given type (e.g. "A.java" for x/y/A$Inner.class)
1353
	 */
1354
	public Object findSourceFile(IType type, String simpleSourceFileName) {
1355
		long time = 0;
1356
		if (VERBOSE) {
1357
			time = System.currentTimeMillis();
1358
		}
1359
		PackageFragment pkgFrag = (PackageFragment) type.getPackageFragment();
1360
		String name = org.eclipse.jdt.internal.core.util.Util.concatWith(pkgFrag.names, simpleSourceFileName, '/');
1361
1362
		Object sourceFile = null;
1363
1364
		if (this.rootPath != null) {
1365
			sourceFile = getSourceFileForRootPath(this.rootPath, name);
1366
		}
1367
1368
		if (sourceFile == null) {
1369
			computeAllRootPaths(type);
1370
			if (this.rootPaths != null) {
1371
				loop: for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) {
1372
					String currentRootPath = (String) iterator.next();
1373
					if (!currentRootPath.equals(this.rootPath)) {
1374
						sourceFile = getSourceFileForRootPath(currentRootPath, name);
1375
						if (sourceFile != null) {
1376
							// remember right root path
1377
							this.rootPath = currentRootPath;
1378
							break loop;
1379
						}
1380
					}
1381
				}
1382
			}
1383
		}
1384
		if (VERBOSE) {
1385
			System.out.println("spent " + (System.currentTimeMillis() - time) + "ms for " + type.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
1386
		}
1387
		return sourceFile;
1388
	}
1389
1390
	private Object getSourceFileForRootPath(String currentRootPath, String name) {
1391
		String newFullName;
1392
		if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) {
1393
			if (currentRootPath.endsWith("/")) { //$NON-NLS-1$
1394
				newFullName = currentRootPath + name;
1395
			} else {
1396
				newFullName = currentRootPath + '/' + name;
1397
			}
1398
		} else {
1399
			newFullName = name;
1400
		}
1401
		return getSourceFile(newFullName);
1402
	}
1403
1404
	private Object getSourceFile(String fullName) {
1405
		Object target = JavaModel.getTarget(this.sourcePath, true);
1406
		if (target instanceof IContainer) {
1407
			IResource res = ((IContainer)target).findMember(fullName);
1408
			if (res instanceof IFile) {
1409
				return res;
1410
			}
1411
		} else {
1412
			// try to get the entry
1413
			ZipEntry entry = null;
1414
			ZipFile zip = null;
1415
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1416
			try {
1417
				zip = manager.getZipFile(this.sourcePath);
1418
				entry = zip.getEntry(fullName);
1419
				if (entry != null) {
1420
					return entry;
1421
				}
1422
			} catch (CoreException e) {
1423
				return null;
1424
			} finally {
1425
				manager.closeZipFile(zip); // handle null case
1426
			}
1427
		}
1428
		return null;
1429
	}
1430
	
1431
	public ZipFile getSourceZipFile() {
1432
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
1433
		try {
1434
			return manager.getZipFile(this.sourcePath);
1435
		} catch (CoreException e) {
1436
			// ignore
1437
		}
1438
		return null;		
1439
	}
1440
	
1330
}
1441
}
(-)model/org/eclipse/jdt/internal/core/ClasspathChange.java (-7 / +21 lines)
Lines 457-462 Link Here
457
457
458
		int newLength = newResolvedClasspath.length;
458
		int newLength = newResolvedClasspath.length;
459
		int oldLength = this.oldResolvedClasspath.length;
459
		int oldLength = this.oldResolvedClasspath.length;
460
		
461
		// First, look at removed classpath entries
460
		for (int i = 0; i < oldLength; i++) {
462
		for (int i = 0; i < oldLength; i++) {
461
			int index = classpathContains(newResolvedClasspath, this.oldResolvedClasspath[i]);
463
			int index = classpathContains(newResolvedClasspath, this.oldResolvedClasspath[i]);
462
			if (index == -1) {
464
			if (index == -1) {
Lines 487-506 Link Here
487
			}
489
			}
488
		}
490
		}
489
491
492
		// Then, look at created or changed classpath entries
490
		for (int i = 0; i < newLength; i++) {
493
		for (int i = 0; i < newLength; i++) {
491
			int index = classpathContains(this.oldResolvedClasspath, newResolvedClasspath[i]);
494
			IClasspathEntry entry = newResolvedClasspath[i];
495
			int index = classpathContains(this.oldResolvedClasspath, entry);
492
			if (index == -1) {
496
			if (index == -1) {
493
				// remote projects are not indexed in this project
497
				// remote projects are not indexed in this project
494
				if (newResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
498
				if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT){
495
					continue;
499
					continue;
496
				}
500
				}
497
501
498
				// Request indexing
502
				// Request indexing for the removed classpath entry
499
				int entryKind = newResolvedClasspath[i].getEntryKind();
503
				int entryKind = entry.getEntryKind();
500
				switch (entryKind) {
504
				switch (entryKind) {
501
					case IClasspathEntry.CPE_LIBRARY:
505
					case IClasspathEntry.CPE_LIBRARY:
502
						boolean pathHasChanged = true;
506
						boolean pathHasChanged = true;
503
						IPath newPath = newResolvedClasspath[i].getPath();
507
						IPath newPath = entry.getPath();
504
						for (int j = 0; j < oldLength; j++) {
508
						for (int j = 0; j < oldLength; j++) {
505
							IClasspathEntry oldEntry = this.oldResolvedClasspath[j];
509
							IClasspathEntry oldEntry = this.oldResolvedClasspath[j];
506
							if (oldEntry.getPath().equals(newPath)) {
510
							if (oldEntry.getPath().equals(newPath)) {
Lines 509-519 Link Here
509
							}
513
							}
510
						}
514
						}
511
						if (pathHasChanged) {
515
						if (pathHasChanged) {
512
							indexManager.indexLibrary(newPath, this.project.getProject());
516
							indexManager.indexLibrary(entry, this.project);
513
						}
517
						}
514
						break;
518
						break;
515
					case IClasspathEntry.CPE_SOURCE:
519
					case IClasspathEntry.CPE_SOURCE:
516
						IClasspathEntry entry = newResolvedClasspath[i];
517
						IPath path = entry.getPath();
520
						IPath path = entry.getPath();
518
						char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
521
						char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
519
						char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
522
						char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
Lines 521-526 Link Here
521
						break;
524
						break;
522
				}
525
				}
523
			}
526
			}
527
			// since bug 12044, source attached are indexed instead of class files
528
			// hence needs to verify whether the source attachment has changed
529
			else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
530
				IPath srcPath = entry.getSourceAttachmentPath();
531
				IPath oldSrcPath = this.oldResolvedClasspath[index].getSourceAttachmentPath();
532
				if (srcPath == null && oldSrcPath != null) {
533
					indexManager.removeIndex(entry.getPath());
534
				} else if (srcPath != null && !srcPath.equals(oldSrcPath)) {
535
					indexManager.indexLibrary(entry, this.project);
536
				}
537
			}
524
		}
538
		}
525
	}
539
	}
526
540
(-)model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java (+18 lines)
Lines 573-579 Link Here
573
 */
573
 */
574
public IPath getSourceAttachmentPath() throws JavaModelException {
574
public IPath getSourceAttachmentPath() throws JavaModelException {
575
	if (getKind() != K_BINARY) return null;
575
	if (getKind() != K_BINARY) return null;
576
	return sourceAttachmentPath();
577
}
576
578
579
/**
580
 * @see IPackageFragmentRoot#getSourceAttachmentRootPath()
581
 * 	Returns the same result but without opening the package fragment root.
582
 * 	However, no verification is done on the package fragment root kind, hence
583
 * 	provides an unpredictable result if it is not a {@link IPackageFragmentRoot#K_BINARY}.
584
 */
585
public IPath sourceAttachmentPath() throws JavaModelException {
577
	// 1) look source attachment property (set iff attachSource(...) was called
586
	// 1) look source attachment property (set iff attachSource(...) was called
578
	IPath path = getPath();
587
	IPath path = getPath();
579
	String serverPathString= Util.getSourceAttachmentProperty(path);
588
	String serverPathString= Util.getSourceAttachmentProperty(path);
Lines 618-624 Link Here
618
 */
627
 */
619
public IPath getSourceAttachmentRootPath() throws JavaModelException {
628
public IPath getSourceAttachmentRootPath() throws JavaModelException {
620
	if (getKind() != K_BINARY) return null;
629
	if (getKind() != K_BINARY) return null;
630
	return sourceAttachmentRootPath();
631
}
621
632
633
/**
634
 * @see IPackageFragmentRoot#getSourceAttachmentRootPath()
635
 * 	Returns the same result but without opening the package fragment root.
636
 * 	However, no verification is done on the package fragment root kind, hence
637
 * 	provides an unpredictable result if it is not a {@link IPackageFragmentRoot#K_BINARY}.
638
 */
639
public IPath sourceAttachmentRootPath() throws JavaModelException {
622
	// 1) look source attachment property (set iff attachSource(...) was called
640
	// 1) look source attachment property (set iff attachSource(...) was called
623
	IPath path = getPath();
641
	IPath path = getPath();
624
	String serverPathString= Util.getSourceAttachmentProperty(path);
642
	String serverPathString= Util.getSourceAttachmentProperty(path);
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-6 / +7 lines)
Lines 862-869 Link Here
862
				continue;
862
				continue;
863
			}
863
			}
864
			for (int j = 0; j < entries.length; j++){
864
			for (int j = 0; j < entries.length; j++){
865
				if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
865
				IClasspathEntry entry = entries[j];
866
					IPath entryPath = entries[j].getPath();
866
				if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
867
					IPath entryPath = entry.getPath();
867
868
868
					if (!archivePathsToRefresh.contains(entryPath)) continue; // not supposed to be refreshed
869
					if (!archivePathsToRefresh.contains(entryPath)) continue; // not supposed to be refreshed
869
870
Lines 902-908 Link Here
902
									// first remove the index so that it is forced to be re-indexed
903
									// first remove the index so that it is forced to be re-indexed
903
									this.manager.indexManager.removeIndex(entryPath);
904
									this.manager.indexManager.removeIndex(entryPath);
904
									// then index the jar
905
									// then index the jar
905
									this.manager.indexManager.indexLibrary(entryPath, project.getProject());
906
									this.manager.indexManager.indexLibrary(entry, javaProject);
906
								} else {
907
								} else {
907
									externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
908
									externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
908
								}
909
								}
Lines 913-919 Link Here
913
									externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED);
914
									externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED);
914
									this.state.getExternalLibTimeStamps().put(entryPath, new Long(newTimeStamp));
915
									this.state.getExternalLibTimeStamps().put(entryPath, new Long(newTimeStamp));
915
									// index the new jar
916
									// index the new jar
916
									this.manager.indexManager.indexLibrary(entryPath, project.getProject());
917
									this.manager.indexManager.indexLibrary(entry, javaProject);
917
								}
918
								}
918
							}
919
							}
919
						} else { // internal JAR
920
						} else { // internal JAR
Lines 2503-2515 Link Here
2503
					switch (delta.getKind()) {
2504
					switch (delta.getKind()) {
2504
						case IResourceDelta.ADDED:
2505
						case IResourceDelta.ADDED:
2505
							// index the new jar
2506
							// index the new jar
2506
							indexManager.indexLibrary(jarPath, root.getJavaProject().getProject());
2507
							indexManager.indexPackageFragmentRoot(root);
2507
							break;
2508
							break;
2508
						case IResourceDelta.CHANGED:
2509
						case IResourceDelta.CHANGED:
2509
							// first remove the index so that it is forced to be re-indexed
2510
							// first remove the index so that it is forced to be re-indexed
2510
							indexManager.removeIndex(jarPath);
2511
							indexManager.removeIndex(jarPath);
2511
							// then index the jar
2512
							// then index the jar
2512
							indexManager.indexLibrary(jarPath, root.getJavaProject().getProject());
2513
							indexManager.indexPackageFragmentRoot(root);
2513
							break;
2514
							break;
2514
						case IResourceDelta.REMOVED:
2515
						case IResourceDelta.REMOVED:
2515
							// the jar was physically removed: remove the index
2516
							// the jar was physically removed: remove the index
(-)search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java (-1 / +1 lines)
Lines 77-83 Link Here
77
					if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(projectPath)) {
77
					if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(projectPath)) {
78
						// the project is also a library folder (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89815)
78
						// the project is also a library folder (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89815)
79
						// ensure a job exists to index it as a binary folder
79
						// ensure a job exists to index it as a binary folder
80
						this.manager.indexLibrary(projectPath, this.project);
80
						this.manager.indexLibrary(entry, javaProject);
81
						return true;
81
						return true;
82
					}
82
					}
83
				}
83
				}
(-)search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java (-160 / +369 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.indexing;
11
package org.eclipse.jdt.internal.core.search.indexing;
12
12
13
import java.io.File;
14
import java.io.IOException;
13
import java.io.IOException;
15
import java.net.URI;
16
import java.util.Enumeration;
14
import java.util.Enumeration;
15
import java.util.Map;
17
import java.util.zip.ZipEntry;
16
import java.util.zip.ZipEntry;
18
import java.util.zip.ZipFile;
17
import java.util.zip.ZipFile;
19
18
Lines 22-192 Link Here
22
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.jdt.core.IClasspathEntry;
25
import org.eclipse.jdt.core.IJavaElement;
26
import org.eclipse.jdt.core.IJavaProject;
27
import org.eclipse.jdt.core.IPackageFragment;
28
import org.eclipse.jdt.core.IPackageFragmentRoot;
29
import org.eclipse.jdt.core.IType;
30
import org.eclipse.jdt.core.JavaCore;
31
import org.eclipse.jdt.core.JavaModelException;
32
import org.eclipse.jdt.core.compiler.CharOperation;
25
import org.eclipse.jdt.core.search.IJavaSearchScope;
33
import org.eclipse.jdt.core.search.IJavaSearchScope;
26
import org.eclipse.jdt.core.search.SearchEngine;
34
import org.eclipse.jdt.core.search.SearchEngine;
27
import org.eclipse.jdt.core.search.SearchParticipant;
35
import org.eclipse.jdt.core.search.SearchParticipant;
28
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
36
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
37
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
29
import org.eclipse.jdt.internal.compiler.util.Util;
38
import org.eclipse.jdt.internal.compiler.util.Util;
39
import org.eclipse.jdt.internal.core.BinaryType;
30
import org.eclipse.jdt.internal.core.JavaModelManager;
40
import org.eclipse.jdt.internal.core.JavaModelManager;
41
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
42
import org.eclipse.jdt.internal.core.SourceMapper;
31
import org.eclipse.jdt.internal.core.index.Index;
43
import org.eclipse.jdt.internal.core.index.Index;
32
import org.eclipse.jdt.internal.core.search.JavaSearchDocument;
44
import org.eclipse.jdt.internal.core.search.JavaSearchDocument;
33
import org.eclipse.jdt.internal.core.search.processing.JobManager;
45
import org.eclipse.jdt.internal.core.search.processing.JobManager;
46
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject;
34
47
35
class AddJarFileToIndex extends IndexRequest {
48
class AddJarFileToIndex extends IndexRequest {
36
49
37
	private static final char JAR_SEPARATOR = IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR.charAt(0);
50
	private static final char JAR_SEPARATOR = IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR.charAt(0);
38
	IFile resource;
51
	IFile resource;
52
	SourceMapper sourceMapper;
53
	IPath sourcePath;
54
	IJavaProject javaProject;
55
	IPackageFragmentRoot packageFragmentRoot;
56
	private HashtableOfArrayToObject packageHandles = new HashtableOfArrayToObject();
57
58
public AddJarFileToIndex(IFile resource, IndexManager manager) {
59
	super(resource.getFullPath(), manager);
60
	this.resource = resource;
61
}
62
public AddJarFileToIndex(IPath jarPath, IndexManager manager) {
63
	// external JAR scenario - no resource
64
	super(jarPath, manager);
65
}
66
67
private IType createTypeFromJar(String classFilePath) throws JavaModelException {
68
	String[] simpleNames = new Path(classFilePath).segments();
69
	String[] pkgName;
70
	int length = simpleNames.length-1;
71
	if (length > 0) {
72
		pkgName = new String[length];
73
		System.arraycopy(simpleNames, 0, pkgName, 0, length);
74
	} else {
75
		pkgName = CharOperation.NO_STRINGS;
76
	}
77
	IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName);
78
	if (pkgFragment == null) {
79
		pkgFragment= ((PackageFragmentRoot)this.packageFragmentRoot).getPackageFragment(pkgName);
80
		this.packageHandles.put(pkgName, pkgFragment);
81
	}
82
	return pkgFragment.getClassFile(simpleNames[length]).getType();
83
}
39
84
40
	public AddJarFileToIndex(IFile resource, IndexManager manager) {
85
void setJavaProject(IJavaProject javaProject) {
41
		super(resource.getFullPath(), manager);
86
	this.javaProject = javaProject;
42
		this.resource = resource;
87
}
43
	}
88
44
	public AddJarFileToIndex(IPath jarPath, IndexManager manager) {
89
void setSourceMapper(IClasspathEntry classpathEntry) {
45
		// external JAR scenario - no resource
90
	this.sourcePath = classpathEntry.getSourceAttachmentPath();
46
		super(jarPath, manager);
91
	IPath rootPath = classpathEntry.getSourceAttachmentRootPath();
47
	}
92
	if (this.sourcePath != null) {
48
	public boolean equals(Object o) {
93
		Map options = this.javaProject == null
49
		if (o instanceof AddJarFileToIndex) {
94
			? JavaCore.getOptions()
50
			if (this.resource != null)
95
			: this.javaProject.getOptions(true);
51
				return this.resource.equals(((AddJarFileToIndex) o).resource);
96
		this.sourceMapper = new SourceMapper(
52
			if (this.containerPath != null)
97
			this.sourcePath ,
53
				return this.containerPath.equals(((AddJarFileToIndex) o).containerPath);
98
			rootPath == null ? null : rootPath.toOSString(),
99
			options);
100
	}
101
	if (this.javaProject != null) {
102
		IPackageFragmentRoot[] roots = this.javaProject.findPackageFragmentRoots(classpathEntry);
103
		if (roots != null && roots.length == 1) {
104
			this.packageFragmentRoot = roots[0];
54
		}
105
		}
55
		return false;
56
	}
106
	}
57
	public int hashCode() {
107
}
108
109
void setSourceMapper(IPackageFragmentRoot fragmentRoot) {
110
	this.packageFragmentRoot = fragmentRoot;
111
	if (this.javaProject == null) {
112
		this.javaProject = fragmentRoot.getJavaProject();
113
	}
114
	try {
115
		this.sourcePath = ((PackageFragmentRoot)fragmentRoot).sourceAttachmentPath();
116
		if (this.sourcePath == null) {
117
			this.sourcePath = fragmentRoot.getPath();
118
		}
119
		IPath rootPath = ((PackageFragmentRoot)fragmentRoot).sourceAttachmentRootPath();
120
		this.sourceMapper = new SourceMapper(
121
			this.sourcePath,
122
			rootPath == null ? null : rootPath.toOSString(),
123
			this.javaProject.getOptions(true));
124
	} catch (JavaModelException e) {
125
		// skip
126
	}
127
}
128
129
public boolean equals(Object o) {
130
	if (o instanceof AddJarFileToIndex) {
58
		if (this.resource != null)
131
		if (this.resource != null)
59
			return this.resource.hashCode();
132
			return this.resource.equals(((AddJarFileToIndex) o).resource);
60
		if (this.containerPath != null)
133
		if (this.containerPath != null)
61
			return this.containerPath.hashCode();
134
			return this.containerPath.equals(((AddJarFileToIndex) o).containerPath);
62
		return -1;
63
	}
135
	}
64
	public boolean execute(IProgressMonitor progressMonitor) {
136
	return false;
137
}
138
public int hashCode() {
139
	if (this.resource != null)
140
		return this.resource.hashCode();
141
	if (this.containerPath != null)
142
		return this.containerPath.hashCode();
143
	return -1;
144
}
145
public boolean execute(IProgressMonitor progressMonitor) {
65
146
66
		if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
147
	if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true;
67
148
149
	try {
150
		// if index is already cached, then do not perform any check
151
		// MUST reset the IndexManager if a jar file is changed
152
		Index index = this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/);
153
		if (index != null) {
154
			if (JobManager.VERBOSE)
155
				org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$
156
			return true;
157
		}
158
159
		index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
160
		if (index == null) {
161
			if (JobManager.VERBOSE)
162
				org.eclipse.jdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$
163
			return true;
164
		}
165
		ReadWriteMonitor monitor = index.monitor;
166
		if (monitor == null) {
167
			if (JobManager.VERBOSE)
168
				org.eclipse.jdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$
169
			return true; // index got deleted since acquired
170
		}
171
		index.separator = JAR_SEPARATOR;
172
		ZipFile zip = null;
173
		ZipFile sourceZip = null;
174
		JavaModelManager modelManager = JavaModelManager.getJavaModelManager();
175
		modelManager.cacheZipFiles();
68
		try {
176
		try {
69
			// if index is already cached, then do not perform any check
177
			// this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the
70
			// MUST reset the IndexManager if a jar file is changed
178
			// local file system
71
			Index index = this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/);
179
			Path zipFilePath = null;
72
			if (index != null) {
180
73
				if (JobManager.VERBOSE)
181
			monitor.enterWrite(); // ask permission to write
74
					org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$
182
			if (this.resource != null) {
75
				return true;
183
				IPath resourcePath = this.resource.getFullPath();
76
			}
184
				if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
185
					System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + resourcePath); //$NON-NLS-1$	//$NON-NLS-2$
186
				}
187
				try {
188
					zip = modelManager.getZipFile(resourcePath);
189
				} catch (CoreException ce) {
190
					if (JobManager.VERBOSE) {
191
						org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + resourcePath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
192
						ce.printStackTrace();
193
					}
194
					return false;
195
				}
196
				zipFilePath = (Path) resourcePath.makeRelative();
197
				// absolute path relative to the workspace
77
198
78
			index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
199
				// Get package fragment root if not already stored
79
			if (index == null) {
200
				if (this.packageFragmentRoot == null) {
80
				if (JobManager.VERBOSE)
201
					IJavaElement javaElement = JavaCore.create(this.resource, this.javaProject);
81
					org.eclipse.jdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$
202
					if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT) {
82
				return true;
203
						this.packageFragmentRoot = (IPackageFragmentRoot) javaElement;
204
					}
205
				}
206
			} else {
207
				if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
208
					System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$	//$NON-NLS-2$
209
				}
210
				try {
211
					zip = modelManager.getZipFile(this.containerPath);
212
				} catch (CoreException ce) {
213
					if (JobManager.VERBOSE) {
214
						org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
215
						ce.printStackTrace();
216
					}
217
					return false;
218
				}
219
				zipFilePath = (Path) this.containerPath;
220
				// path is already canonical since coming from a library classpath entry
83
			}
221
			}
84
			ReadWriteMonitor monitor = index.monitor;
222
85
			if (monitor == null) {
223
			if (this.isCancelled) {
86
				if (JobManager.VERBOSE)
224
				if (JobManager.VERBOSE)
87
					org.eclipse.jdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$
225
					org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
88
				return true; // index got deleted since acquired
226
				return false;
89
			}
227
			}
90
			index.separator = JAR_SEPARATOR;
228
91
			ZipFile zip = null;
229
			if (JobManager.VERBOSE)
92
			try {
230
				org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$
93
				// this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the
231
			long initialTime = System.currentTimeMillis();
94
				// local file system
232
95
				Path zipFilePath = null;
233
			String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$
96
234
			if (paths != null) {
97
				monitor.enterWrite(); // ask permission to write
235
				int max = paths.length;
98
				if (this.resource != null) {
236
				/* check integrity of the existing index file
99
					URI location = this.resource.getLocationURI();
237
				 * if the length is equal to 0, we want to index the whole jar again
100
					if (location == null) return false;
238
				 * If not, then we want to check that there is no missing entry, if
101
					if (JavaModelManager.ZIP_ACCESS_VERBOSE)
239
				 * one entry is missing then we recreate the index
102
						System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$	//$NON-NLS-2$
240
				 */
103
					File file = null;
241
				String EXISTS = "OK"; //$NON-NLS-1$
104
					try {
242
				String DELETED = "DELETED"; //$NON-NLS-1$
105
						file = org.eclipse.jdt.internal.core.util.Util.toLocalFile(location, progressMonitor);
243
				SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
106
					} catch (CoreException e) {
244
				for (int i = 0; i < max; i++)
107
						if (JobManager.VERBOSE) {
245
					indexedFileNames.put(paths[i], DELETED);
108
							org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
246
				for (Enumeration e = zip.entries(); e.hasMoreElements();) {
109
							e.printStackTrace();
247
					// iterate each entry to index it
248
					ZipEntry ze = (ZipEntry) e.nextElement();
249
					String zipEntryName = ze.getName();
250
					if (Util.isClassFileName(zipEntryName))
251
						indexedFileNames.put(zipEntryName, EXISTS);
252
				}
253
				boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added
254
				if (!needToReindex) {
255
					Object[] valueTable = indexedFileNames.valueTable;
256
					for (int i = 0, l = valueTable.length; i < l; i++) {
257
						if (valueTable[i] == DELETED) {
258
							needToReindex = true; // a file was deleted so re-index
259
							break;
110
						}
260
						}
111
					}
261
					}
112
					if (file == null) {
262
					if (!needToReindex) {
113
						if (JobManager.VERBOSE)
263
						if (JobManager.VERBOSE)
114
							org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$
264
							org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$
115
						return false;
265
							+ zip.getName() + " (" //$NON-NLS-1$
266
							+ (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
267
						this.manager.saveIndex(index); // to ensure its placed into the saved state
268
						return true;
116
					}
269
					}
117
					zip = new ZipFile(file);
118
					zipFilePath = (Path) this.resource.getFullPath().makeRelative();
119
					// absolute path relative to the workspace
120
				} else {
121
					if (JavaModelManager.ZIP_ACCESS_VERBOSE)
122
						System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$	//$NON-NLS-2$
123
					// external file -> it is ok to use toFile()
124
					zip = new ZipFile(this.containerPath.toFile());
125
					zipFilePath = (Path) this.containerPath;
126
					// path is already canonical since coming from a library classpath entry
127
				}
128
129
				if (this.isCancelled) {
130
					if (JobManager.VERBOSE)
131
						org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
132
					return false;
133
				}
270
				}
271
			}
134
272
135
				if (JobManager.VERBOSE)
273
			// Index the jar for the first time or reindex the jar in case the previous index file has been corrupted
136
					org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$
274
			// index already existed: recreate it so that we forget about previous entries
137
				long initialTime = System.currentTimeMillis();
275
			SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
276
			index = this.manager.recreateIndex(this.containerPath);
277
			if (index == null) {
278
				// failed to recreate index, see 73330
279
				this.manager.removeIndex(this.containerPath);
280
				return false;
281
			}
282
			index.separator = JAR_SEPARATOR;
138
283
139
				String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$
284
			if (this.sourcePath != null) {
140
				if (paths != null) {
285
				index.sourcePath = this.sourcePath.toString();
141
					int max = paths.length;
286
				try {
142
					/* check integrity of the existing index file
287
					sourceZip = modelManager.getZipFile(this.sourcePath);	
143
					 * if the length is equal to 0, we want to index the whole jar again
288
				} catch (CoreException ce) {
144
					 * If not, then we want to check that there is no missing entry, if
289
					// ignore
145
					 * one entry is missing then we recreate the index
290
				}
146
					 */
291
			}
147
					String EXISTS = "OK"; //$NON-NLS-1$
292
			// Need a special way to get sources when they are in the jar itself
148
					String DELETED = "DELETED"; //$NON-NLS-1$
293
			if (zip != null && zip == sourceZip) {
149
					SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
294
				ZipEntry[] zipEntries = new ZipEntry[10];
150
					for (int i = 0; i < max; i++)
295
				int stackPtr = -1;
151
						indexedFileNames.put(paths[i], DELETED);
296
				String previousFileName = null;
152
					for (Enumeration e = zip.entries(); e.hasMoreElements();) {
297
				for (Enumeration e = zip.entries(); e.hasMoreElements();) {
153
						// iterate each entry to index it
298
					if (this.isCancelled) {
154
						ZipEntry ze = (ZipEntry) e.nextElement();
299
						if (JobManager.VERBOSE)
155
						String zipEntryName = ze.getName();
300
							org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
156
						if (Util.isClassFileName(zipEntryName))
301
						return false;
157
							indexedFileNames.put(zipEntryName, EXISTS);
158
					}
302
					}
159
					boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added
303
160
					if (!needToReindex) {
304
					// iterate each entry to index it
161
						Object[] valueTable = indexedFileNames.valueTable;
305
					ZipEntry ze = (ZipEntry) e.nextElement();
162
						for (int i = 0, l = valueTable.length; i < l; i++) {
306
					String zeName = ze.getName();
163
							if (valueTable[i] == DELETED) {
307
					if (Util.isClassFileName(zeName)) {
164
								needToReindex = true; // a file was deleted so re-index
308
						String fileName = zeName.substring(0, zeName.length()-SuffixConstants.SUFFIX_CLASS.length);
165
								break;
309
						if (previousFileName != null && !(previousFileName.startsWith(fileName) && previousFileName.charAt(fileName.length()) == '$')) {
310
							// no source was found for previous class file name => index it now and all member classes as well
311
							while (stackPtr >= 0) {
312
								ZipEntry previousEntry = zipEntries[stackPtr--];
313
								String previousEntryName = previousEntry.getName();
314
								if (!previousEntryName.startsWith(previousFileName) && previousEntryName.charAt(fileName.length()) != '$') break;
315
								final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(previousEntry, zip);
316
								JavaSearchDocument searchDocument = new JavaSearchDocument(previousEntry, zipFilePath, classFileBytes, participant);
317
								this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
166
							}
318
							}
167
						}
319
						}
168
						if (!needToReindex) {
320
						previousFileName = fileName;
169
							if (JobManager.VERBOSE)
321
170
								org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$
322
						int length = zipEntries.length;
171
								+ zip.getName() + " (" //$NON-NLS-1$
323
						if (++stackPtr == length) {
172
								+ (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
324
							// resize (should seldom occur as happen only when local class depth is over 10!
173
							this.manager.saveIndex(index); // to ensure its placed into the saved state
325
							System.arraycopy(zipEntries, 0, zipEntries = new ZipEntry[length + (length>>1)], 0, length);
174
							return true;
175
						}
326
						}
327
						zipEntries[stackPtr] = ze;
328
					}
329
					else if (Util.isJavaFileName(zeName) && zeName.startsWith(previousFileName) && zeName.length() == (previousFileName.length()+SuffixConstants.SUFFIX_java.length)) {
330
						// this is the source file of previous class files => index it
331
						JavaSearchDocument searchDocument = new JavaSearchDocument(zipEntries[stackPtr], zipFilePath, ze, sourceZip, this.sourcePath, participant);
332
						this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
333
						stackPtr = -1; // flush entries stack
334
						previousFileName = null;
176
					}
335
					}
177
				}
336
				}
178
337
179
				// Index the jar for the first time or reindex the jar in case the previous index file has been corrupted
338
				// index remaining class files if any
180
				// index already existed: recreate it so that we forget about previous entries
339
				while (stackPtr >= 0) {
181
				SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
340
					ZipEntry previousEntry = zipEntries[stackPtr--];
182
				index = this.manager.recreateIndex(this.containerPath);
341
					final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(previousEntry, zip);
183
				if (index == null) {
342
					JavaSearchDocument searchDocument = new JavaSearchDocument(previousEntry, zipFilePath, classFileBytes, participant);
184
					// failed to recreate index, see 73330
343
					this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
185
					this.manager.removeIndex(this.containerPath);
186
					return false;
187
				}
344
				}
188
				index.separator = JAR_SEPARATOR;
345
			} else {
189
346
				IFile previousSourceFile = null;
347
				ZipEntry previousZipEntry = null;
348
				ZipEntry previousSourceZipEntry = null;
190
				for (Enumeration e = zip.entries(); e.hasMoreElements();) {
349
				for (Enumeration e = zip.entries(); e.hasMoreElements();) {
191
					if (this.isCancelled) {
350
					if (this.isCancelled) {
192
						if (JobManager.VERBOSE)
351
						if (JobManager.VERBOSE)
Lines 196-239 Link Here
196
355
197
					// iterate each entry to index it
356
					// iterate each entry to index it
198
					ZipEntry ze = (ZipEntry) e.nextElement();
357
					ZipEntry ze = (ZipEntry) e.nextElement();
199
					if (Util.isClassFileName(ze.getName())) {
358
					String zeName = ze.getName();
200
						final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
359
					if (Util.isClassFileName(zeName)) {
201
						JavaSearchDocument entryDocument = new JavaSearchDocument(ze, zipFilePath, classFileBytes, participant);
360
						IFile sourceFile = null;
202
						this.manager.indexDocument(entryDocument, participant, index, this.containerPath);
361
						ZipEntry sourceZipEntry = null;
362
363
						if (this.sourcePath != null) {
364
							IType type = null;
365
							try {
366
								if (this.packageFragmentRoot != null) {
367
									type = createTypeFromJar(zeName);
368
								}
369
							} catch (JavaModelException jme) {
370
								// ignore
371
							}
372
							if (type != null) {
373
								String sourceName = ((BinaryType) type).getSourceFileName(null);
374
								Object mappedSource = this.sourceMapper.findSourceFile(type, sourceName);
375
								if (mappedSource != null) {
376
									if (mappedSource instanceof IFile) {
377
										sourceFile = (IFile)mappedSource;
378
									} else {
379
										sourceZipEntry = (ZipEntry) mappedSource;
380
									}
381
								}
382
							}
383
						}
384
						if (sourceFile != null) {
385
							if (previousSourceFile != null && !sourceFile.equals(previousSourceFile)) {
386
								JavaSearchDocument searchDocument = new JavaSearchDocument(ze, zipFilePath, previousSourceFile, this.sourcePath, participant);
387
								this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
388
							}
389
							previousSourceFile = sourceFile;
390
						} else if (sourceZipEntry != null) {
391
							if (previousSourceZipEntry != null && !sourceZipEntry.getName().equals(previousSourceZipEntry.getName())) {
392
								JavaSearchDocument searchDocument = new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceZipEntry, sourceZip, this.sourcePath, participant);
393
								this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
394
							}
395
							previousSourceZipEntry = sourceZipEntry;
396
						} else {
397
							final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
398
							JavaSearchDocument searchDocument = new JavaSearchDocument(ze, zipFilePath, classFileBytes, participant);
399
							this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
400
						}
401
						previousZipEntry = ze;
203
					}
402
					}
204
				}
403
				}
205
				this.manager.saveIndex(index);
404
206
				if (JobManager.VERBOSE)
405
				// index the remaining source file/zip entry if any
207
					org.eclipse.jdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$
406
				if (previousZipEntry != null && (previousSourceFile != null || previousSourceZipEntry != null)) {
208
						+ zip.getName() + " (" //$NON-NLS-1$
407
					JavaSearchDocument searchDocument = previousSourceFile != null
209
						+ (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
408
						? new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceFile, this.sourcePath, participant)
210
			} finally {
409
						: new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceZipEntry, sourceZip, this.sourcePath, participant);
211
				if (zip != null) {
410
					this.manager.indexDocument(searchDocument, participant, index, this.containerPath);
212
					if (JavaModelManager.ZIP_ACCESS_VERBOSE)
411
				}
213
						System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + zip); //$NON-NLS-1$	//$NON-NLS-2$
214
					zip.close();
215
				}
216
				monitor.exitWrite(); // free write lock
217
			}
218
		} catch (IOException e) {
219
			if (JobManager.VERBOSE) {
220
				org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
221
				e.printStackTrace();
222
			}
412
			}
223
			this.manager.removeIndex(this.containerPath);
413
			this.manager.saveIndex(index);
224
			return false;
414
			if (JobManager.VERBOSE)
415
				org.eclipse.jdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$
416
					+ zip.getName() + " (" //$NON-NLS-1$
417
					+ (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
418
		} finally {
419
			modelManager.flushZipFiles();
420
//			if (zip != null) {
421
//				if (JavaModelManager.ZIP_ACCESS_VERBOSE)
422
//					System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + zip); //$NON-NLS-1$	//$NON-NLS-2$
423
//				zip.close();
424
//			}
425
			monitor.exitWrite(); // free write lock
225
		}
426
		}
226
		return true;
427
	} catch (IOException e) {
227
	}
428
		if (JobManager.VERBOSE) {
228
	public String getJobFamily() {
429
			org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
229
		if (this.resource != null)
430
			e.printStackTrace();
230
			return super.getJobFamily();
431
		}
231
		return this.containerPath.toOSString(); // external jar
432
		this.manager.removeIndex(this.containerPath);
232
	}
433
		return false;
233
	protected Integer updatedIndexState() {
234
		return IndexManager.REBUILDING_STATE;
235
	}
236
	public String toString() {
237
		return "indexing " + this.containerPath.toString(); //$NON-NLS-1$
238
	}
434
	}
435
	return true;
436
}
437
public String getJobFamily() {
438
	if (this.resource != null)
439
		return super.getJobFamily();
440
	return this.containerPath.toOSString(); // external jar
441
}
442
protected Integer updatedIndexState() {
443
	return IndexManager.REBUILDING_STATE;
444
}
445
public String toString() {
446
	return "indexing " + this.containerPath.toString(); //$NON-NLS-1$
447
}
239
}
448
}
(-)search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java (-1 / +16 lines)
Lines 27-32 Link Here
27
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
27
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
28
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
28
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
29
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
29
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
30
import org.eclipse.jdt.internal.core.search.JavaSearchDocument;
30
import org.eclipse.jdt.internal.core.util.Util;
31
import org.eclipse.jdt.internal.core.util.Util;
31
32
32
public class BinaryIndexer extends AbstractIndexer implements SuffixConstants {
33
public class BinaryIndexer extends AbstractIndexer implements SuffixConstants {
Lines 618-624 Link Here
618
			final byte[] contents = this.document.getByteContents();
619
			final byte[] contents = this.document.getByteContents();
619
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=107124
620
			// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=107124
620
			// contents can potentially be null if a IOException occurs while retrieving the contents
621
			// contents can potentially be null if a IOException occurs while retrieving the contents
621
			if (contents == null) return;
622
			if (contents == null) {
623
				// See if there's some source attached
624
				if (this.document instanceof JavaSearchDocument) {
625
					JavaSearchDocument javaSearchDocument = (JavaSearchDocument) this.document;
626
					if (javaSearchDocument.sourcePath != null) {
627
						char[] source = javaSearchDocument.getCharContents();
628
						if (source.length != 0) {
629
							// the source exists, then prefer to index it instead of the class file
630
							SourceIndexer sourceIndexer = new SourceIndexer(this.document);
631
							sourceIndexer.indexDocument();
632
						}
633
					}
634
				}
635
				return;
636
			}
622
			final String path = this.document.getPath();
637
			final String path = this.document.getPath();
623
			ClassFileReader reader = new ClassFileReader(contents, path == null ? null : path.toCharArray());
638
			ClassFileReader reader = new ClassFileReader(contents, path == null ? null : path.toCharArray());
624
639
(-)search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java (-1 / +47 lines)
Lines 380-386 Link Here
380
		for (int i = 0; i < entries.length; i++) {
380
		for (int i = 0; i < entries.length; i++) {
381
			IClasspathEntry entry= entries[i];
381
			IClasspathEntry entry= entries[i];
382
			if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
382
			if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
383
				indexLibrary(entry.getPath(), project);
383
				indexLibrary(entry, javaProject);
384
		}
384
		}
385
	} catch(JavaModelException e){ // cannot retrieve classpath info
385
	} catch(JavaModelException e){ // cannot retrieve classpath info
386
	}
386
	}
Lines 394-399 Link Here
394
 * Trigger addition of a library to an index
394
 * Trigger addition of a library to an index
395
 * Note: the actual operation is performed in background
395
 * Note: the actual operation is performed in background
396
 */
396
 */
397
public void indexLibrary(IClasspathEntry classpathEntry, IJavaProject requestingProject) {
398
399
	// Otherwise index it as a jar file
400
	IPath path = classpathEntry.getPath();
401
	IndexRequest request = indexLibraryRequest(path);
402
	if (request == null) 	return;
403
	if (request instanceof AddJarFileToIndex) {
404
		AddJarFileToIndex jarFileRequest = (AddJarFileToIndex) request;
405
		jarFileRequest.setJavaProject(requestingProject);
406
		jarFileRequest.setSourceMapper(classpathEntry);
407
	}
408
	if (!isJobWaiting(request)) {
409
		request(request);
410
	}
411
}
412
public void indexPackageFragmentRoot(IPackageFragmentRoot fragmentRoot) {
413
	IPath path = fragmentRoot.getPath();
414
	IndexRequest request = indexLibraryRequest(path);
415
	if (request == null) 	return;
416
	if (request instanceof AddJarFileToIndex) {
417
		AddJarFileToIndex jarFileRequest = (AddJarFileToIndex) request;
418
		jarFileRequest.setSourceMapper(fragmentRoot);
419
	}
420
	if (!isJobWaiting(request)) {
421
		request(request);
422
	}
423
}
424
private IndexRequest indexLibraryRequest(IPath path) {
425
	// requestingProject is no longer used to cancel jobs but leave it here just in case
426
	if (JavaCore.getPlugin() == null) return null;
427
428
	Object target = JavaModel.getTarget(path, true);
429
	IndexRequest request = null;
430
	if (target instanceof IFile) {
431
		request = new AddJarFileToIndex((IFile) target, this);
432
	} else if (target instanceof File) {
433
		request = new AddJarFileToIndex(path, this);
434
	} else if (target instanceof IContainer) {
435
		request = new IndexBinaryFolder((IContainer) target, this);
436
	}
437
	return request;
438
}
439
/**
440
 * Trigger addition of a library to an index
441
 * Note: the actual operation is performed in background
442
 */
397
public void indexLibrary(IPath path, IProject requestingProject) {
443
public void indexLibrary(IPath path, IProject requestingProject) {
398
	// requestingProject is no longer used to cancel jobs but leave it here just in case
444
	// requestingProject is no longer used to cancel jobs but leave it here just in case
399
	if (JavaCore.getPlugin() == null) return;
445
	if (JavaCore.getPlugin() == null) return;
(-)search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java (-3 / +16 lines)
Lines 105-111 Link Here
105
			int separatorIndex= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
105
			int separatorIndex= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
106
			type = separatorIndex == -1
106
			type = separatorIndex == -1
107
				? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
107
				? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
108
				: createTypeFromJar(path, separatorIndex);
108
				: createTypeFromJar(path, separatorIndex, new String(simpleTypeName), enclosingTypeNames); // need to provide simpleTypeName and enclosing type names when the type has been found in attached source!
109
		}
109
		}
110
		if (type != null) {
110
		if (type != null) {
111
			this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers));
111
			this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers));
Lines 114-120 Link Here
114
		// skip
114
		// skip
115
	}
115
	}
116
}
116
}
117
private IType createTypeFromJar(String resourcePath, int separatorIndex) throws JavaModelException {
117
private IType createTypeFromJar(String resourcePath, int separatorIndex, String simpleTypeName, char[][] enclosingTypeNames) throws JavaModelException {
118
	// path to a class file inside a jar
118
	// path to a class file inside a jar
119
	// Optimization: cache package fragment root handle and package handles
119
	// Optimization: cache package fragment root handle and package handles
120
	if (this.lastPkgFragmentRootPath == null
120
	if (this.lastPkgFragmentRootPath == null
Lines 143-149 Link Here
143
		pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName);
143
		pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName);
144
		this.packageHandles.put(pkgName, pkgFragment);
144
		this.packageHandles.put(pkgName, pkgFragment);
145
	}
145
	}
146
	return pkgFragment.getClassFile(simpleNames[length]).getType();
146
	String simpleName= simpleNames[length];
147
	IClassFile classFile= pkgFragment.getClassFile(simpleName);
148
	IType type = classFile.getType();
149
	int etnLength = enclosingTypeNames == null ? 0 : enclosingTypeNames.length;
150
	if (etnLength > 0) {
151
		if (etnLength > 0) {
152
			for (int i=1; i<etnLength; i++) {
153
				type = type.getType(new String(enclosingTypeNames[i]));
154
			}
155
			type = type.getType(simpleTypeName);
156
		}
157
	}
158
	return type;
159
//	return pkgFragment.getClassFile(simpleNames[length]).getType();
147
}
160
}
148
private IType createTypeFromPath(String resourcePath, String simpleTypeName, char[][] enclosingTypeNames) throws JavaModelException {
161
private IType createTypeFromPath(String resourcePath, String simpleTypeName, char[][] enclosingTypeNames) throws JavaModelException {
149
	// path to a file in a directory
162
	// path to a file in a directory
(-)search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java (-8 / +59 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search;
11
package org.eclipse.jdt.internal.core.search;
12
12
13
import java.io.IOException;
14
import java.util.zip.ZipEntry;
15
import java.util.zip.ZipFile;
16
13
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
Lines 26-32 Link Here
26
30
27
	private IFile file;
31
	private IFile file;
28
	protected byte[] byteContents;
32
	protected byte[] byteContents;
29
	protected char[] charContents;
33
	public char[] charContents;
34
	public ZipFile sourceZip;
35
	public ZipEntry sourceEntry;
36
	public IPath sourcePath;
30
37
31
	public JavaSearchDocument(String documentPath, SearchParticipant participant) {
38
	public JavaSearchDocument(String documentPath, SearchParticipant participant) {
32
		super(documentPath, participant);
39
		super(documentPath, participant);
Lines 35-43 Link Here
35
		super(zipFilePath + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + zipEntry.getName(), participant);
42
		super(zipFilePath + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + zipEntry.getName(), participant);
36
		this.byteContents = contents;
43
		this.byteContents = contents;
37
	}
44
	}
45
	public JavaSearchDocument(ZipEntry ze, Path zipFilePath, IFile file, IPath srcPath, SearchParticipant participant) {
46
		this(ze, zipFilePath, (byte[]) null, participant);
47
		this.file = file;
48
		this.sourcePath = srcPath;
49
	}
50
	public JavaSearchDocument(ZipEntry ze, Path zipFilePath, ZipEntry se, ZipFile zip, IPath srcPath, SearchParticipant participant) {
51
		this(ze, zipFilePath, (byte[]) null, participant);
52
		this.sourceEntry = se;
53
		this.sourceZip = zip;
54
		this.sourcePath = srcPath;
55
	}
38
56
39
	public byte[] getByteContents() {
57
	public byte[] getByteContents() {
40
		if (this.byteContents != null) return this.byteContents;
58
		if (this.byteContents != null) return this.byteContents;
59
		if (this.sourcePath != null) {
60
			// try to initialize source contents instead
61
			if (getCharContents() != null) return null;
62
		}
41
		try {
63
		try {
42
			return Util.getResourceContentsAsByteArray(getFile());
64
			return Util.getResourceContentsAsByteArray(getFile());
43
		} catch (JavaModelException e) {
65
		} catch (JavaModelException e) {
Lines 48-62 Link Here
48
		}
70
		}
49
	}
71
	}
50
	public char[] getCharContents() {
72
	public char[] getCharContents() {
51
		if (this.charContents != null) return this.charContents;
73
		if (this.charContents == null) {
52
		try {
74
			// The source may be found through an attachment
53
			return Util.getResourceContentsAsCharArray(getFile());
75
			if (this.sourcePath != null) {
54
		} catch (JavaModelException e) {
76
				// a zip entry in an attached source zip
55
			if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing
77
				if (this.sourceEntry != null) {
56
				e.printStackTrace();
78
					try {
79
						byte[] bytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(this.sourceEntry, this.sourceZip);
80
						if (bytes != null) {
81
							return this.charContents = org.eclipse.jdt.internal.compiler.util.Util.bytesToChar(bytes, null);
82
						}
83
					} catch (IOException e) {
84
						// ignore
85
					}
86
					this.sourceEntry = null; // avoid to read it again
87
					return null;
88
				}
89
				if (this.file != null) {
90
					try {
91
						return this.charContents = Util.getResourceContentsAsCharArray(this.file);
92
					} catch (JavaModelException e) {
93
						if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing
94
							e.printStackTrace();
95
						}
96
					}
97
					this.file = null; // avoid to read it again
98
					return null;
99
				}
100
			} else {
101
				try {
102
					return Util.getResourceContentsAsCharArray(getFile());
103
				} catch (JavaModelException e) {
104
					if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing
105
						e.printStackTrace();
106
					}
107
				}
57
			}
108
			}
58
			return null;
59
		}
109
		}
110
		return this.charContents;
60
	}
111
	}
61
	public String getEncoding() {
112
	public String getEncoding() {
62
		// Return the encoding of the associated file
113
		// Return the encoding of the associated file
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-1 / +6 lines)
Lines 2470-2476 Link Here
2470
	} else if (enclosingElement instanceof IMember) {
2470
	} else if (enclosingElement instanceof IMember) {
2471
	    IMember member = (IMember) parent;
2471
	    IMember member = (IMember) parent;
2472
		if (member.isBinary())  {
2472
		if (member.isBinary())  {
2473
			enclosingElement = ((IClassFile)this.currentPossibleMatch.openable).getType();
2473
			IType topLevelType = ((IClassFile)this.currentPossibleMatch.openable).getType();
2474
			if (type.name.equals(topLevelType.getElementName())) {
2475
				enclosingElement = topLevelType;
2476
			} else {
2477
				enclosingElement = topLevelType.getType(new String(type.name));
2478
			}
2474
		} else {
2479
		} else {
2475
			enclosingElement = member.getType(new String(type.name), occurrenceCount);
2480
			enclosingElement = member.getType(new String(type.name), occurrenceCount);
2476
		}
2481
		}
(-)search/org/eclipse/jdt/internal/core/index/Index.java (+4 lines)
Lines 29-34 Link Here
29
public class Index {
29
public class Index {
30
30
31
public String containerPath;
31
public String containerPath;
32
public String sourcePath;
32
public ReadWriteMonitor monitor;
33
public ReadWriteMonitor monitor;
33
34
34
// Separator to use after the container path
35
// Separator to use after the container path
Lines 102-107 Link Here
102
public String containerRelativePath(String documentPath) {
103
public String containerRelativePath(String documentPath) {
103
	int index = documentPath.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
104
	int index = documentPath.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
104
	if (index == -1) {
105
	if (index == -1) {
106
		if (this.sourcePath != null) {
107
			return documentPath;
108
		}
105
		index = this.containerPath.length();
109
		index = this.containerPath.length();
106
		if (documentPath.length() <= index)
110
		if (documentPath.length() <= index)
107
			throw new IllegalArgumentException("Document path " + documentPath + " must be relative to " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$
111
			throw new IllegalArgumentException("Document path " + documentPath + " must be relative to " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java (+1 lines)
Lines 655-660 Link Here
655
		if (jdkLib == null) {
655
		if (jdkLib == null) {
656
			throw new RuntimeException("Cannot set JRE_LIB classpath variable as the rt.jar lib was not found!!!");
656
			throw new RuntimeException("Cannot set JRE_LIB classpath variable as the rt.jar lib was not found!!!");
657
		}
657
		}
658
		JavaCore.setClasspathVariable("JRE_LIB", new Path(jdkLib), null);
658
659
659
		// Set classpaths (workaround bug 73253 Project references not set on project open)
660
		// Set classpaths (workaround bug 73253 Project references not set on project open)
660
		System.out.print("Set projects classpaths...");
661
		System.out.print("Set projects classpaths...");
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java (-1 / +1 lines)
Lines 245-251 Link Here
245
	/**
245
	/**
246
	 * Performance tests for search: Indexing one project (JDT/Core).
246
	 * Performance tests for search: Indexing one project (JDT/Core).
247
	 */
247
	 */
248
	public void testIndexingOneProject() throws CoreException {
248
	public void testONLY_IndexingOneProject() throws CoreException {
249
		tagAsSummary("Indexing JDT/Core project", true); // put in fingerprint
249
		tagAsSummary("Indexing JDT/Core project", true); // put in fingerprint
250
250
251
		// Warm-up
251
		// Warm-up

Return to bug 12044