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[] {"testBug306223"}; |
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 |
* |
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 |
"String test;\n" + |
11587 |
"void foo(String str) {\n" + |
11588 |
"this.test = str;\n" + |
11589 |
"}\n" + |
11590 |
"}\n" |
11591 |
); |
11592 |
this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b306223/MyAnnot.java", |
11593 |
"@interface MyAnnot {}\n"); |
11594 |
SearchPattern pattern = SearchPattern.createPattern( |
11595 |
"*", |
11596 |
ANNOTATION_TYPE, |
11597 |
REFERENCES, |
11598 |
EXACT_RULE); |
11599 |
new SearchEngine(this.workingCopies).search(pattern, |
11600 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11601 |
getJavaSearchWorkingCopiesScope(), |
11602 |
this.resultCollector, |
11603 |
null); |
11604 |
assertSearchResults( |
11605 |
"src/b306223/Test.java [b306223.MyAnnot] EXACT_MATCH\n" + |
11606 |
"src/b306223/Test.java b306223.TestAnnot [MyAnnot] EXACT_MATCH\n" + |
11607 |
"src/b306223/Test.java b306223.TestAnnot.annon [MyAnnot] EXACT_MATCH" |
11608 |
); |
11609 |
} |
11610 |
/** |
11611 |
* This ensures that using ANNOTATION_TYPE_REFERENCE as fine grain constant reports only |
11612 |
* annotations and not any other references to an annotation type |
11613 |
*/ |
11614 |
public void testBug306223b() throws CoreException { |
11615 |
this.workingCopies = new ICompilationUnit[2]; |
11616 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11617 |
"import b306223.MyAnnot;\n"+ |
11618 |
"@MyAnnot\n" + |
11619 |
"public class TestAnnot {\n" + |
11620 |
"MyAnnot annon;\n" + |
11621 |
"String test;\n" + |
11622 |
"void foo(String str) {\n" + |
11623 |
"this.test = str;\n" + |
11624 |
"}\n" + |
11625 |
"}\n" |
11626 |
); |
11627 |
this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b306223/MyAnnot.java", |
11628 |
"@interface MyAnnot {}\n"); |
11629 |
SearchPattern pattern = SearchPattern.createPattern( |
11630 |
"*", |
11631 |
ANNOTATION_TYPE, |
11632 |
REFERENCES|ANNOTATION_TYPE_REFERENCE, |
11633 |
EXACT_RULE); |
11634 |
new SearchEngine(this.workingCopies).search(pattern, |
11635 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11636 |
getJavaSearchWorkingCopiesScope(), |
11637 |
this.resultCollector, |
11638 |
null); |
11639 |
assertSearchResults( |
11640 |
"src/b306223/Test.java b306223.TestAnnot [MyAnnot] EXACT_MATCH" |
11641 |
); |
11642 |
} |
11643 |
|
11644 |
/** |
11645 |
* This test ensures that search for enum references does not report type references. |
11646 |
*/ |
11647 |
public void testBug306223c() throws CoreException { |
11648 |
this.workingCopies = new ICompilationUnit[1]; |
11649 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11650 |
"public class TestEnum {\n" + |
11651 |
" String foo(MyEnum e) {\n" + |
11652 |
" switch (e) {\n"+ |
11653 |
" case ONE:\n" + |
11654 |
" return \"1\";\n" + |
11655 |
" case TWO:\n" + |
11656 |
" return \"2\";\n" + |
11657 |
" default:\n" + |
11658 |
" return \"-1\";\n" + |
11659 |
" }\n" + |
11660 |
" }\n" + |
11661 |
" }\n" + |
11662 |
|
11663 |
"enum MyEnum {\n" + |
11664 |
" ONE, TWO\n" + |
11665 |
"}\n" |
11666 |
); |
11667 |
|
11668 |
SearchPattern pattern = SearchPattern.createPattern( |
11669 |
"*", |
11670 |
ENUM, |
11671 |
REFERENCES, |
11672 |
EXACT_RULE); |
11673 |
new SearchEngine(this.workingCopies).search(pattern, |
11674 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11675 |
getJavaSearchWorkingCopiesScope(), |
11676 |
this.resultCollector, |
11677 |
null); |
11678 |
assertSearchResults( |
11679 |
"src/b306223/Test.java String b306223.TestEnum.foo(MyEnum) [MyEnum] EXACT_MATCH" |
11680 |
); |
11681 |
} |
11682 |
/** |
11683 |
* This test ensures that a reference search of ANNOTATION_TYPE should report POTENTIAL_MATCH |
11684 |
* for unknown references types. |
11685 |
*/ |
11686 |
public void testBug306223d() throws CoreException { |
11687 |
this.workingCopies = new ICompilationUnit[1]; |
11688 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11689 |
"public class TestAnnot {\n" + |
11690 |
"Zork annon;\n" + |
11691 |
"}\n" |
11692 |
); |
11693 |
SearchPattern pattern = SearchPattern.createPattern( |
11694 |
"*", |
11695 |
ANNOTATION_TYPE, |
11696 |
REFERENCES, |
11697 |
EXACT_RULE); |
11698 |
new SearchEngine(this.workingCopies).search(pattern, |
11699 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11700 |
getJavaSearchWorkingCopiesScope(), |
11701 |
this.resultCollector, |
11702 |
null); |
11703 |
assertSearchResults( |
11704 |
"src/b306223/Test.java b306223.TestAnnot.annon [Zork] POTENTIAL_MATCH" |
11705 |
); |
11706 |
} |
11707 |
/** |
11708 |
* This test ensures that an ANNOTATION_TYPE reference search for a non-existing |
11709 |
* type does not report any other references |
11710 |
*/ |
11711 |
public void testBug306223e() throws CoreException { |
11712 |
this.workingCopies = new ICompilationUnit[1]; |
11713 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11714 |
"public class Test {\n" + |
11715 |
" Zork x;\n" + |
11716 |
"}\n" |
11717 |
); |
11718 |
SearchPattern pattern = SearchPattern.createPattern( |
11719 |
"abc", |
11720 |
ANNOTATION_TYPE, |
11721 |
REFERENCES, |
11722 |
EXACT_RULE); |
11723 |
new SearchEngine(this.workingCopies).search(pattern, |
11724 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11725 |
getJavaSearchWorkingCopiesScope(), |
11726 |
this.resultCollector, |
11727 |
null); |
11728 |
assertSearchResults(""); |
11729 |
} |
11730 |
/** |
11731 |
* This test ensures that a TYPE reference search reports EXACT_MATCH |
11732 |
* for missing types |
11733 |
*/ |
11734 |
public void testBug306223f() throws CoreException { |
11735 |
this.workingCopies = new ICompilationUnit[1]; |
11736 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11737 |
"public class Test {\n" + |
11738 |
" Zork x;\n" + |
11739 |
"}\n" |
11740 |
); |
11741 |
SearchPattern pattern = SearchPattern.createPattern( |
11742 |
"*", |
11743 |
TYPE, |
11744 |
REFERENCES, |
11745 |
EXACT_RULE); |
11746 |
new SearchEngine(this.workingCopies).search(pattern, |
11747 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11748 |
getJavaSearchWorkingCopiesScope(), |
11749 |
this.resultCollector, |
11750 |
null); |
11751 |
assertSearchResults( |
11752 |
"src/b306223/Test.java b306223.Test.x [Zork] EXACT_MATCH" |
11753 |
); |
11754 |
} |
11755 |
/** |
11756 |
* This test ensures that a TYPE reference search for a non-existing |
11757 |
* type does not report any other references |
11758 |
*/ |
11759 |
public void testBug306223g() throws CoreException { |
11760 |
this.workingCopies = new ICompilationUnit[1]; |
11761 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b306223/Test.java", |
11762 |
"public class Test {\n" + |
11763 |
" Zork x;\n" + |
11764 |
"}\n" |
11765 |
); |
11766 |
SearchPattern pattern = SearchPattern.createPattern( |
11767 |
"abc", |
11768 |
TYPE, |
11769 |
REFERENCES, |
11770 |
EXACT_RULE); |
11771 |
new SearchEngine(this.workingCopies).search(pattern, |
11772 |
new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, |
11773 |
getJavaSearchWorkingCopiesScope(), |
11774 |
this.resultCollector, |
11775 |
null); |
11776 |
assertSearchResults(""); |
11777 |
} |
11569 |
} |
11778 |
} |