Lines 60-65
Link Here
|
60 |
// Debug |
60 |
// Debug |
61 |
static { |
61 |
static { |
62 |
// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; |
62 |
// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; |
|
|
63 |
// TESTS_NAMES = new String[] {"testBug306223c"}; |
63 |
} |
64 |
} |
64 |
|
65 |
|
65 |
public JavaSearchBugsTests(String name) { |
66 |
public JavaSearchBugsTests(String name) { |
Lines 11566-11569
Link Here
|
11566 |
removeClasspathEntry(JAVA_PROJECT, new Path(libPath)); |
11567 |
removeClasspathEntry(JAVA_PROJECT, new Path(libPath)); |
11567 |
} |
11568 |
} |
11568 |
} |
11569 |
} |
|
|
11570 |
|
11571 |
/** |
11572 |
* @bug 306223: [search] Searching for annotation references report all type references |
11573 |
* @test Ensures the following - |
11574 |
* 1. Search for annotation references does not report type references |
11575 |
* 2. Search for annotation references even report a non-annotation references to an annotation type |
11576 |
* 3. Search for annotation references report an unknown reference as POTENTIAL_MATCH |
11577 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=306223" |
11578 |
*/ |
11579 |
public void testBug306223a() throws CoreException { |
11580 |
this.workingCopies = new ICompilationUnit[2]; |
11581 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11582 |
"import b306223.MyAnnot;\n"+ |
11583 |
"@MyAnnot\n" + |
11584 |
"public class TestAnnot {\n" + |
11585 |
"MyAnnot annon;\n" + |
11586 |
"Zork x;\n" + |
11587 |
"String test;\n" + |
11588 |
"void foo(String str) {\n" + |
11589 |
"this.test = str;\n" + |
11590 |
"}\n" + |
11591 |
"}\n" |
11592 |
); |
11593 |
this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b306223/MyAnnot.java", |
11594 |
"@interface MyAnnot {}\n"); |
11595 |
SearchPattern pattern = SearchPattern.createPattern( |
11596 |
"*", |
11597 |
ANNOTATION_TYPE, |
11598 |
REFERENCES, |
11599 |
EXACT_RULE); |
11600 |
new SearchEngine(this.workingCopies).search(pattern, |
11601 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11602 |
getJavaSearchWorkingCopiesScope(), |
11603 |
this.resultCollector, |
11604 |
null); |
11605 |
assertSearchResults( |
11606 |
"src/b306223/Test.java [b306223.MyAnnot] EXACT_MATCH\n" + |
11607 |
"src/b306223/Test.java b306223.TestAnnot [MyAnnot] EXACT_MATCH\n" + |
11608 |
"src/b306223/Test.java b306223.TestAnnot.annon [MyAnnot] EXACT_MATCH\n" + |
11609 |
"src/b306223/Test.java b306223.TestAnnot.x [Zork] POTENTIAL_MATCH" |
11610 |
); |
11611 |
} |
11612 |
/** |
11613 |
* This ensures that using ANNOTATION_TYPE_REFERENCE as fine grain constant reports only |
11614 |
* annotations and not any other references to an annotation type |
11615 |
*/ |
11616 |
public void testBug306223b() throws CoreException { |
11617 |
this.workingCopies = new ICompilationUnit[2]; |
11618 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11619 |
"import b306223.MyAnnot;\n"+ |
11620 |
"@MyAnnot\n" + |
11621 |
"public class TestAnnot {\n" + |
11622 |
"MyAnnot annon;\n" + |
11623 |
"String test;\n" + |
11624 |
"void foo(String str) {\n" + |
11625 |
"this.test = str;\n" + |
11626 |
"}\n" + |
11627 |
"}\n" |
11628 |
); |
11629 |
this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b306223/MyAnnot.java", |
11630 |
"@interface MyAnnot {}\n"); |
11631 |
SearchPattern pattern = SearchPattern.createPattern( |
11632 |
"*", |
11633 |
ANNOTATION_TYPE, |
11634 |
REFERENCES|ANNOTATION_TYPE_REFERENCE, |
11635 |
EXACT_RULE); |
11636 |
new SearchEngine(this.workingCopies).search(pattern, |
11637 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11638 |
getJavaSearchWorkingCopiesScope(), |
11639 |
this.resultCollector, |
11640 |
null); |
11641 |
assertSearchResults( |
11642 |
"src/b306223/Test.java b306223.TestAnnot [MyAnnot] EXACT_MATCH" |
11643 |
); |
11644 |
} |
11645 |
/** |
11646 |
* This ensures that search for enum references does not report type references. |
11647 |
*/ |
11648 |
public void testBug306223c() throws CoreException { |
11649 |
this.workingCopies = new ICompilationUnit[1]; |
11650 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11651 |
"public class TestEnum {\n" + |
11652 |
" String foo(MyEnum e) {\n" + |
11653 |
" switch (e) {\n"+ |
11654 |
" case ONE:\n" + |
11655 |
" return \"1\";\n" + |
11656 |
" case TWO:\n" + |
11657 |
" return \"2\";\n" + |
11658 |
" default:\n" + |
11659 |
" return \"-1\";\n" + |
11660 |
" }\n" + |
11661 |
" }\n" + |
11662 |
" }\n" + |
11663 |
|
11664 |
"enum MyEnum {\n" + |
11665 |
" ONE, TWO\n" + |
11666 |
"}\n" |
11667 |
); |
11668 |
|
11669 |
SearchPattern pattern = SearchPattern.createPattern( |
11670 |
"*", |
11671 |
ENUM, |
11672 |
REFERENCES, |
11673 |
EXACT_RULE); |
11674 |
new SearchEngine(this.workingCopies).search(pattern, |
11675 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11676 |
getJavaSearchWorkingCopiesScope(), |
11677 |
this.resultCollector, |
11678 |
null); |
11679 |
assertSearchResults( |
11680 |
"src/b306223/Test.java String b306223.TestEnum.foo(MyEnum) [MyEnum] EXACT_MATCH" |
11681 |
); |
11682 |
} |
11683 |
|
11569 |
} |
11684 |
} |