Lines 13619-13623
Link Here
|
13619 |
JavaCore.setOptions(this.oldOptions); |
13619 |
JavaCore.setOptions(this.oldOptions); |
13620 |
} |
13620 |
} |
13621 |
} |
13621 |
} |
|
|
13622 |
/* |
13623 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=84720 |
13624 |
* to test that the methods with Boxed/unboxed return types get higher relevance than the ones that return void |
13625 |
*/ |
13626 |
public void testCompletionWithUnboxing() throws JavaModelException { |
13627 |
this.workingCopies = new ICompilationUnit[2]; |
13628 |
this.workingCopies[0] = getWorkingCopy( |
13629 |
"/Completion/src3/test/Test.java", |
13630 |
"package test;\n" + |
13631 |
"public class C {\n" + |
13632 |
"public void myMethod1(){}\n" + |
13633 |
"public void myMethod2(){}\n" + |
13634 |
"public int myMethod3(){return 0;}\n" + |
13635 |
"public Integer myMethod4(){return 0;}\n" + |
13636 |
"public void foo() {\n" + |
13637 |
" int i = myMeth \n" + |
13638 |
"}\n" + |
13639 |
"}"); |
13640 |
this.workingCopies[1] = getWorkingCopy( |
13641 |
"/Completion/src3/java/lang/Test.java", |
13642 |
"package java.lang;\n" + |
13643 |
"public class Integer {\n" + |
13644 |
"}"); |
13645 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
13646 |
|
13647 |
String str = this.workingCopies[0].getSource(); |
13648 |
String completeBehind = "= myMeth"; |
13649 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
13650 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
13651 |
|
13652 |
assertResults( |
13653 |
"myMethod1[METHOD_REF]{myMethod1(), Ltest.C;, ()V, myMethod1, null, " + |
13654 |
(R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13655 |
"myMethod2[METHOD_REF]{myMethod2(), Ltest.C;, ()V, myMethod2, null, " + |
13656 |
(R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13657 |
"myMethod4[METHOD_REF]{myMethod4(), Ltest.C;, ()Ljava.lang.Integer;, myMethod4, null, " + |
13658 |
(R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13659 |
"myMethod3[METHOD_REF]{myMethod3(), Ltest.C;, ()I, myMethod3, null, " + |
13660 |
(R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", |
13661 |
requestor.getResults()); |
13662 |
} |
13663 |
/* |
13664 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=84720 |
13665 |
* Additional tests for bug 84720 |
13666 |
*/ |
13667 |
public void testCompletionWithUnboxing_1() throws JavaModelException { |
13668 |
this.workingCopies = new ICompilationUnit[2]; |
13669 |
this.workingCopies[0] = getWorkingCopy( |
13670 |
"/Completion/src3/test/Test.java", |
13671 |
"package test;\n" + |
13672 |
"public class C {\n" + |
13673 |
"public void myMethod1(){}\n" + |
13674 |
"public void myMethod2(){}\n" + |
13675 |
"public int myMethod3(){return 0;}\n" + |
13676 |
"public Integer myMethod4(){return 0;}\n" + |
13677 |
"public void foo() {\n" + |
13678 |
" Integer i = myMeth \n" + |
13679 |
"}\n" + |
13680 |
"}"); |
13681 |
this.workingCopies[1] = getWorkingCopy( |
13682 |
"/Completion/src3/java/lang/Test.java", |
13683 |
"package java.lang;\n" + |
13684 |
"public class Integer {\n" + |
13685 |
"}"); |
13686 |
|
13687 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
13688 |
|
13689 |
String str = this.workingCopies[0].getSource(); |
13690 |
String completeBehind = "= myMeth"; |
13691 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
13692 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
13693 |
|
13694 |
assertResults( |
13695 |
"myMethod1[METHOD_REF]{myMethod1(), Ltest.C;, ()V, myMethod1, null, " + |
13696 |
(R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13697 |
"myMethod2[METHOD_REF]{myMethod2(), Ltest.C;, ()V, myMethod2, null, " + |
13698 |
(R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13699 |
"myMethod3[METHOD_REF]{myMethod3(), Ltest.C;, ()I, myMethod3, null, " + |
13700 |
(R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13701 |
"myMethod4[METHOD_REF]{myMethod4(), Ltest.C;, ()Ljava.lang.Integer;, myMethod4, null, " + |
13702 |
(R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", |
13703 |
requestor.getResults()); |
13704 |
} |
13705 |
/* |
13706 |
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=84720 |
13707 |
* Additional tests for bug 84720 |
13708 |
*/ |
13709 |
public void testCompletionWithUnboxing_2() throws JavaModelException { |
13710 |
this.workingCopies = new ICompilationUnit[2]; |
13711 |
this.workingCopies[0] = getWorkingCopy( |
13712 |
"/Completion/src3/test/Test.java", |
13713 |
"package test;\n" + |
13714 |
"public class C {\n" + |
13715 |
"int myVariable1 = 0;\n" + |
13716 |
"long myVariable2 = 0;\n" + |
13717 |
"boolean myVariable3 = false;\n" + |
13718 |
"Boolean myVariable4 = false;\n" + |
13719 |
"public void foo() {\n" + |
13720 |
" if(myVar \n" + |
13721 |
"}\n" + |
13722 |
"}"); |
13723 |
|
13724 |
this.workingCopies[1] = getWorkingCopy( |
13725 |
"/Completion/src3/java/lang/Test.java", |
13726 |
"package java.lang;\n" + |
13727 |
"public class Boolean {\n" + |
13728 |
"}"); |
13729 |
|
13730 |
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); |
13731 |
|
13732 |
String str = this.workingCopies[0].getSource(); |
13733 |
String completeBehind = "if(myVar"; |
13734 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
13735 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
13736 |
assertResults( |
13737 |
"myVariable1[FIELD_REF]{myVariable1, Ltest.C;, I, myVariable1, null, " + |
13738 |
(R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13739 |
"myVariable2[FIELD_REF]{myVariable2, Ltest.C;, J, myVariable2, null, " + |
13740 |
(R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13741 |
"myVariable4[FIELD_REF]{myVariable4, Ltest.C;, Ljava.lang.Boolean;, myVariable4, null, " + |
13742 |
(R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + |
13743 |
"myVariable3[FIELD_REF]{myVariable3, Ltest.C;, Z, myVariable3, null, " + |
13744 |
(R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", |
13745 |
requestor.getResults()); |
13746 |
} |
13622 |
|
13747 |
|
13623 |
} |
13748 |
} |