Lines 24-29
Link Here
|
24 |
* Tests the Java search engine accross multiple projects. |
24 |
* Tests the Java search engine accross multiple projects. |
25 |
*/ |
25 |
*/ |
26 |
public class JavaSearchMultipleProjectsTests extends ModifyingResourceTests implements IJavaSearchConstants { |
26 |
public class JavaSearchMultipleProjectsTests extends ModifyingResourceTests implements IJavaSearchConstants { |
|
|
27 |
private final static int UI_DECLARATIONS = DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE; |
27 |
public JavaSearchMultipleProjectsTests(String name) { |
28 |
public JavaSearchMultipleProjectsTests(String name) { |
28 |
super(name); |
29 |
super(name); |
29 |
} |
30 |
} |
Lines 664-667
Link Here
|
664 |
deleteProject("P2"); |
665 |
deleteProject("P2"); |
665 |
} |
666 |
} |
666 |
} |
667 |
} |
|
|
668 |
|
669 |
/** |
670 |
* Bug 151189: [search] Declaration search does not find all matches |
671 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=151189" |
672 |
*/ |
673 |
public void testBug151189_Workspace() throws CoreException { |
674 |
try { |
675 |
// setup project P1 |
676 |
/*IJavaProject p1 = */createJavaProject("P1"); |
677 |
createFolder("/P1/pack"); |
678 |
createFile( |
679 |
"/P1/pack/Declaration.java", |
680 |
"package pack;\n" + |
681 |
"public class Declaration implements Interface {\n" + |
682 |
" public void doOperation(int val) {}\n" + |
683 |
"}\n" |
684 |
); |
685 |
createFile( |
686 |
"/P1/pack/Interface.java", |
687 |
"package pack;\n" + |
688 |
"public interface Interface {\n" + |
689 |
" void doOperation(int val);\n" + |
690 |
"}\n" |
691 |
); |
692 |
|
693 |
// setup project P2 |
694 |
createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, ""); |
695 |
createFolder("/P2/test"); |
696 |
createFile( |
697 |
"/P2/test/Declaration_bis.java", |
698 |
"package test;\n" + |
699 |
"import pack.Interface;\n" + |
700 |
"public class Declaration_bis implements Interface {\n" + |
701 |
" public void doOperation(int val) {}\n" + |
702 |
"}\n" |
703 |
); |
704 |
|
705 |
// Get method |
706 |
IMethod method = getCompilationUnit("/P2/test/Declaration_bis.java").getType("Declaration_bis").getMethod("doOperation", new String[] {"I"}); |
707 |
|
708 |
// search method declaration in workspace scope |
709 |
IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2}); |
710 |
JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); |
711 |
resultCollector.showProject = true; |
712 |
search( |
713 |
method, |
714 |
DECLARATIONS, |
715 |
scope, |
716 |
resultCollector); |
717 |
assertSearchResults( |
718 |
"Unexpected declarations of method test.Declaration_bis.doOperation(int)", |
719 |
"test/Declaration_bis.java [in P2] void test.Declaration_bis.doOperation(int) [doOperation]", |
720 |
resultCollector); |
721 |
|
722 |
// search method declaration in workspace scope with JDT-UI flags |
723 |
resultCollector = new JavaSearchResultCollector(); |
724 |
resultCollector.showProject = true; |
725 |
search( |
726 |
method, |
727 |
UI_DECLARATIONS, |
728 |
scope, |
729 |
resultCollector); |
730 |
assertSearchResults( |
731 |
"Unexpected declarations of method test.Declaration_bis.doOperation(int)", |
732 |
"pack/Declaration.java [in P1] void pack.Declaration.doOperation(int) [doOperation]\n" + |
733 |
"pack/Interface.java [in P1] void pack.Interface.doOperation(int) [doOperation]\n" + |
734 |
"test/Declaration_bis.java [in P2] void test.Declaration_bis.doOperation(int) [doOperation]", |
735 |
resultCollector); |
736 |
} finally { |
737 |
deleteProject("P1"); |
738 |
deleteProject("P2"); |
739 |
} |
740 |
} |
741 |
public void testBug151189_Project() throws CoreException { |
742 |
try { |
743 |
// setup project P1 |
744 |
createJavaProject("P1"); |
745 |
createFolder("/P1/pack"); |
746 |
createFile( |
747 |
"/P1/pack/Declaration.java", |
748 |
"package pack;\n" + |
749 |
"public class Declaration implements Interface {\n" + |
750 |
" public void doOperation(int val) {}\n" + |
751 |
"}\n" |
752 |
); |
753 |
createFile( |
754 |
"/P1/pack/Interface.java", |
755 |
"package pack;\n" + |
756 |
"public interface Interface {\n" + |
757 |
" void doOperation(int val);\n" + |
758 |
"}\n" |
759 |
); |
760 |
|
761 |
// setup project P2 |
762 |
IJavaProject p2 = createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, ""); |
763 |
createFolder("/P2/test"); |
764 |
createFile( |
765 |
"/P2/test/Declaration_bis.java", |
766 |
"package test;\n" + |
767 |
"import pack.Interface;\n" + |
768 |
"public class Declaration_bis implements Interface {\n" + |
769 |
" public void doOperation(int val) {}\n" + |
770 |
"}\n" |
771 |
); |
772 |
|
773 |
// Get method |
774 |
IMethod method = getCompilationUnit("/P2/test/Declaration_bis.java").getType("Declaration_bis").getMethod("doOperation", new String[] {"I"}); |
775 |
|
776 |
// search method declaration in workspace scope |
777 |
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}); |
778 |
JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); |
779 |
resultCollector.showProject = true; |
780 |
search( |
781 |
method, |
782 |
UI_DECLARATIONS, |
783 |
scope, |
784 |
resultCollector); |
785 |
assertSearchResults( |
786 |
"Unexpected declarations of method test.Declaration_bis.doOperation(int)", |
787 |
"pack/Declaration.java [in P1] void pack.Declaration.doOperation(int) [doOperation]\n" + |
788 |
"pack/Interface.java [in P1] void pack.Interface.doOperation(int) [doOperation]\n" + |
789 |
"test/Declaration_bis.java [in P2] void test.Declaration_bis.doOperation(int) [doOperation]", |
790 |
resultCollector); |
791 |
} finally { |
792 |
deleteProject("P1"); |
793 |
deleteProject("P2"); |
794 |
} |
795 |
} |
667 |
} |
796 |
} |