Lines 12844-12849
Link Here
|
12844 |
JavaCore.setOptions(oldOptions); |
12844 |
JavaCore.setOptions(oldOptions); |
12845 |
} |
12845 |
} |
12846 |
} |
12846 |
} |
|
|
12847 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=178982 |
12848 |
public void testONLY_FavoriteImports032() throws JavaModelException { |
12849 |
this.oldOptions = JavaCore.getOptions(); |
12850 |
|
12851 |
try { |
12852 |
Hashtable options = new Hashtable(this.oldOptions); |
12853 |
options.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.ENABLED); |
12854 |
JavaCore.setOptions(options); |
12855 |
|
12856 |
this.workingCopies = new ICompilationUnit[3]; |
12857 |
this.workingCopies[0] = getWorkingCopy( |
12858 |
"/Completion/src3/test/Test.java", |
12859 |
"package test;\n" + |
12860 |
"public class Test extends Test2 {\n" + |
12861 |
" public void method() {\n" + |
12862 |
" int zelement1\n" + |
12863 |
" float zelement2\n" + |
12864 |
" double zelement3\n" + |
12865 |
" foo(0, zelement);\n" + |
12866 |
" }\n" + |
12867 |
"}"); |
12868 |
|
12869 |
this.workingCopies[1] = getWorkingCopy( |
12870 |
"/Completion/src3/test/Test2.java", |
12871 |
"package test;\n" + |
12872 |
"public class Test2 {\n" + |
12873 |
" public void foo(double i, double j) {}\n" + |
12874 |
" public void foo(float i, float j) {}\n" + |
12875 |
" public void foo(int i, int j) {}\n" + |
12876 |
"}"); |
12877 |
|
12878 |
this.workingCopies[2] = getWorkingCopy( |
12879 |
"/Completion/src3/test/p/ZZZ.java", |
12880 |
"package test.p;\n" + |
12881 |
"public class ZZZ {\n" + |
12882 |
" public static int zelement4(){}\n" + |
12883 |
" public static float zelement5(){}\n" + |
12884 |
" public static double zelement6(){}\n" + |
12885 |
"}"); |
12886 |
|
12887 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true); |
12888 |
requestor.allowAllRequiredProposals(); |
12889 |
requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); |
12890 |
|
12891 |
String str = this.workingCopies[0].getSource(); |
12892 |
String completeBehind = "zelement"; |
12893 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
12894 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
12895 |
|
12896 |
int relevance1 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED; |
12897 |
int relevance2 = R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED; |
12898 |
int start1 = str.lastIndexOf("zelement") + "".length(); |
12899 |
int end1 = start1 + "zelement".length(); |
12900 |
int start2 = str.lastIndexOf("public class"); |
12901 |
int end2 = start2 + "".length(); |
12902 |
assertResults( |
12903 |
"zelement4[METHOD_REF]{zelement4(), Ltest.p.ZZZ;, ()I, zelement4, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" + |
12904 |
" zelement4[METHOD_IMPORT]{import static test.p.ZZZ.zelement4;\n, Ltest.p.ZZZ;, ()I, zelement4, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+ |
12905 |
"zelement5[METHOD_REF]{zelement5(), Ltest.p.ZZZ;, ()F, zelement5, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" + |
12906 |
" zelement5[METHOD_IMPORT]{import static test.p.ZZZ.zelement5;\n, Ltest.p.ZZZ;, ()F, zelement5, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+ |
12907 |
"zelement6[METHOD_REF]{zelement6(), Ltest.p.ZZZ;, ()D, zelement6, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" + |
12908 |
" zelement6[METHOD_IMPORT]{import static test.p.ZZZ.zelement6;\n, Ltest.p.ZZZ;, ()D, zelement6, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+ |
12909 |
"zelement1[LOCAL_VARIABLE_REF]{zelement1, null, I, zelement1, null, ["+start1+", "+end1+"], "+(relevance2)+"}\n" + |
12910 |
"zelement2[LOCAL_VARIABLE_REF]{zelement2, null, F, zelement2, null, ["+start1+", "+end1+"], "+(relevance2)+"}\n" + |
12911 |
"zelement3[LOCAL_VARIABLE_REF]{zelement3, null, D, zelement3, null, ["+start1+", "+end1+"], "+(relevance2)+"}", |
12912 |
requestor.getResults()); |
12913 |
} finally { |
12914 |
JavaCore.setOptions(oldOptions); |
12915 |
} |
12916 |
} |
12847 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162865 |
12917 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162865 |
12848 |
public void testNameWithUnresolvedReferences001() throws JavaModelException { |
12918 |
public void testNameWithUnresolvedReferences001() throws JavaModelException { |
12849 |
this.workingCopies = new ICompilationUnit[2]; |
12919 |
this.workingCopies = new ICompilationUnit[2]; |