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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-9 / +51 lines)
Lines 9273-9284 Link Here
9273
	addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false);
9273
	addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false);
9274
	try {
9274
	try {
9275
		IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType();
9275
		IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType();
9276
		this.resultCollector.showMatchKind = true;
9276
		search(type, REFERENCES);
9277
		search(type, REFERENCES);
9277
		assertSearchResults(
9278
		assertSearchResults(
9278
			"lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + 
9279
			"TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + 
9279
			"lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9280
			"TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9280
			"lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + 
9281
			"TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + 
9281
			"lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH"
9282
			"TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH"
9282
		);
9283
		);
9283
	}
9284
	}
9284
	finally {
9285
	finally {
Lines 9292-9297 Link Here
9292
		SearchPattern rightPattern = SearchPattern.createPattern(type, REFERENCES);
9293
		SearchPattern rightPattern = SearchPattern.createPattern(type, REFERENCES);
9293
		SearchPattern leftPattern = SearchPattern.createPattern(type, DECLARATIONS);
9294
		SearchPattern leftPattern = SearchPattern.createPattern(type, DECLARATIONS);
9294
		SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
9295
		SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern);
9296
		this.resultCollector.showMatchKind = true;
9295
		new SearchEngine(workingCopies).search(
9297
		new SearchEngine(workingCopies).search(
9296
			pattern,
9298
			pattern,
9297
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
9299
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
Lines 9300-9310 Link Here
9300
			null
9302
			null
9301
		);
9303
		);
9302
		assertSearchResults(
9304
		assertSearchResults(
9303
			"lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + 
9305
			"TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + 
9304
			"lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9306
			"TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9305
			"lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + 
9307
			"TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + 
9306
			"lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" +
9308
			"TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" +
9307
			"lib/b211366.jar test.Bug [No source] EXACT_MATCH"
9309
			"TypeDeclarationMatch: lib/b211366.jar test.Bug [No source] EXACT_MATCH"
9310
		);
9311
	}
9312
	finally {
9313
		removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211366.jar"));
9314
	}
9315
}
9316
public void testBug211366_ComplexOrPattern() throws CoreException {
9317
	addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false);
9318
	try {
9319
		IType bType = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType();
9320
		SearchPattern leftPattern = SearchPattern.createOrPattern(
9321
			SearchPattern.createPattern("field", FIELD, DECLARATIONS, SearchPattern.R_CASE_SENSITIVE),
9322
			SearchPattern.createPattern(bType, REFERENCES));
9323
		SearchPattern rightPattern = SearchPattern.createOrPattern(
9324
			SearchPattern.createPattern("Member", TYPE, DECLARATIONS, SearchPattern.R_EXACT_MATCH),
9325
			SearchPattern.createOrPattern(
9326
				SearchPattern.createPattern("method", METHOD, DECLARATIONS, SearchPattern.R_EXACT_MATCH),
9327
				SearchPattern.createPattern("Bug", TYPE, REFERENCES, SearchPattern.R_EXACT_MATCH)));
9328
		IPackageFragmentRoot root = JAVA_PROJECT.getPackageFragmentRoot("/JavaSearchBugs/lib/b211366.jar");
9329
		this.resultCollector.sorted = true;
9330
		this.resultCollector.showMatchKind = true;
9331
		new SearchEngine(workingCopies).search(
9332
			SearchPattern.createOrPattern(leftPattern, rightPattern),
9333
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
9334
			SearchEngine.createJavaSearchScope(new IJavaElement[] { root }),
9335
			this.resultCollector,
9336
			null
9337
		);
9338
		assertSearchResults(
9339
			"FieldDeclarationMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + 
9340
			"MethodDeclarationMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + 
9341
			"TypeDeclarationMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9342
			"TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + 
9343
			"TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + 
9344
			"TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9345
			"TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + 
9346
			"TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + 
9347
			"TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + 
9348
			"TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + 
9349
			"TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH"
9308
		);
9350
		);
9309
	}
9351
	}
9310
	finally {
9352
	finally {
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (-1 / +8 lines)
Lines 61-66 Link Here
61
		public boolean showSynthetic;
61
		public boolean showSynthetic;
62
		public boolean showOffset = false;
62
		public boolean showOffset = false;
63
		public int showFlavors = 0;
63
		public int showFlavors = 0;
64
		public boolean showMatchKind = false;
64
		public int count = 0;
65
		public int count = 0;
65
		List lines = new ArrayList();
66
		List lines = new ArrayList();
66
		boolean sorted;
67
		boolean sorted;
Lines 85-91 Link Here
85
			try {
86
			try {
86
				IResource resource = match.getResource();
87
				IResource resource = match.getResource();
87
				IJavaElement element = getElement(match);
88
				IJavaElement element = getElement(match);
88
				line = new StringBuffer(getPathString(resource, element));
89
				line = new StringBuffer();
90
				if (this.showMatchKind) {
91
					String matchClassName = this.match.getClass().getName();
92
					line.append(matchClassName.substring(matchClassName.lastIndexOf('.')+1));
93
					line.append(": ");
94
				}
95
				line.append(getPathString(resource, element));
89
				if (this.showProject) {
96
				if (this.showProject) {
90
					IProject project = element.getJavaProject().getProject();
97
					IProject project = element.getJavaProject().getProject();
91
					line.append(" [in ");
98
					line.append(" [in ");
(-)search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java (-3 / +6 lines)
Lines 329-335 Link Here
329
	BinaryTypeBinding binaryTypeBinding = null;
329
	BinaryTypeBinding binaryTypeBinding = null;
330
	if (checkAnnotations(typeReferencePattern, annotations, binaryType.getTagBits())) {
330
	if (checkAnnotations(typeReferencePattern, annotations, binaryType.getTagBits())) {
331
		classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey());
331
		classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey());
332
		locator.reportBinaryMemberDeclaration(null, classFileBinaryType, null, binaryType, SearchMatch.A_ACCURATE);
332
		SearchMatch match = new TypeReferenceMatch(classFileBinaryType, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
333
		locator.report(match);
333
	}
334
	}
334
335
335
	// Look for references in methods annotations
336
	// Look for references in methods annotations
Lines 342-348 Link Here
342
					IMethod methodHandle = classFileBinaryType.getMethod(
343
					IMethod methodHandle = classFileBinaryType.getMethod(
343
						new String(method.isConstructor() ? binaryTypeBinding.compoundName[binaryTypeBinding.compoundName.length-1] : method.getSelector()),
344
						new String(method.isConstructor() ? binaryTypeBinding.compoundName[binaryTypeBinding.compoundName.length-1] : method.getSelector()),
344
						CharOperation.toStrings(Signature.getParameterTypes(convertClassFileFormat(method.getMethodDescriptor()))));
345
						CharOperation.toStrings(Signature.getParameterTypes(convertClassFileFormat(method.getMethodDescriptor()))));
345
					locator.reportBinaryMemberDeclaration(null, methodHandle, null, binaryType, SearchMatch.A_ACCURATE);
346
					SearchMatch match = new TypeReferenceMatch(methodHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
347
					locator.report(match);
346
			}
348
			}
347
		}
349
		}
348
	}
350
	}
Lines 354-360 Link Here
354
			FieldInfo field = fields[i];
356
			FieldInfo field = fields[i];
355
			if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) {
357
			if (checkAnnotations(typeReferencePattern, field.getAnnotations(), field.getTagBits())) {
356
					IField fieldHandle = classFileBinaryType.getField(new String(field.getName()));
358
					IField fieldHandle = classFileBinaryType.getField(new String(field.getName()));
357
					locator.reportBinaryMemberDeclaration(null, fieldHandle, null, binaryType, SearchMatch.A_ACCURATE);
359
					SearchMatch match = new TypeReferenceMatch(fieldHandle, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource);
360
					locator.report(match);
358
			}
361
			}
359
		}
362
		}
360
	}
363
	}

Return to bug 211366