Lines 19627-19630
Link Here
|
19627 |
COMPLETION_PROJECT.setOptions(options); |
19627 |
COMPLETION_PROJECT.setOptions(options); |
19628 |
} |
19628 |
} |
19629 |
} |
19629 |
} |
|
|
19630 |
|
19631 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19632 |
// All the tests with the prefix test269493 are designed to offer coverage for all the changes that went |
19633 |
// into this fix. |
19634 |
public void test269493() throws JavaModelException { |
19635 |
this.workingCopies = new ICompilationUnit[1]; |
19636 |
this.workingCopies[0] = getWorkingCopy( |
19637 |
"/Completion/src/test/Test269493.java", |
19638 |
"package test;" + |
19639 |
"public class Test269493 {\n" + |
19640 |
" void foo() {\n" + |
19641 |
" for (int i = 0; i < 10; i++)\n" + |
19642 |
" ass\n" + |
19643 |
" }\n" + |
19644 |
"}\n" + |
19645 |
"}\n"); |
19646 |
|
19647 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19648 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19649 |
String str = this.workingCopies[0].getSource(); |
19650 |
String completeBehind = "ass"; |
19651 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19652 |
|
19653 |
// Save current compliance settings |
19654 |
Map options = COMPLETION_PROJECT.getOptions(true); |
19655 |
Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); |
19656 |
|
19657 |
try { |
19658 |
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); |
19659 |
COMPLETION_PROJECT.setOptions(options); |
19660 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19661 |
assertEquals( |
19662 |
"element:assert completion:assert relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19663 |
requestor.getResults()); |
19664 |
} finally { |
19665 |
// Restore compliance settings. |
19666 |
options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); |
19667 |
COMPLETION_PROJECT.setOptions(options); |
19668 |
} |
19669 |
} |
19670 |
|
19671 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19672 |
public void test269493b() throws JavaModelException { |
19673 |
this.workingCopies = new ICompilationUnit[1]; |
19674 |
this.workingCopies[0] = getWorkingCopy( |
19675 |
"/Completion/src/test/Test269493.java", |
19676 |
"package test;" + |
19677 |
"public class Test269493 {\n" + |
19678 |
" void foo() {\n" + |
19679 |
" for (int i = 0; i < 10; i++)\n" + |
19680 |
" ret\n" + |
19681 |
" }\n" + |
19682 |
"}\n" + |
19683 |
"}\n"); |
19684 |
|
19685 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19686 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19687 |
String str = this.workingCopies[0].getSource(); |
19688 |
String completeBehind = "ret"; |
19689 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19690 |
|
19691 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19692 |
assertEquals( |
19693 |
"element:return completion:return relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19694 |
requestor.getResults()); |
19695 |
} |
19696 |
|
19697 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19698 |
public void test269493c() throws JavaModelException { |
19699 |
this.workingCopies = new ICompilationUnit[1]; |
19700 |
this.workingCopies[0] = getWorkingCopy( |
19701 |
"/Completion/src/test/Test269493.java", |
19702 |
"package test;" + |
19703 |
"public class Test269493 {\n" + |
19704 |
" void foo() {\n" + |
19705 |
" for (int i = 0; i < 10; i++)\n" + |
19706 |
" bre\n" + |
19707 |
" }\n" + |
19708 |
"}\n" + |
19709 |
"}\n"); |
19710 |
|
19711 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19712 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19713 |
String str = this.workingCopies[0].getSource(); |
19714 |
String completeBehind = "bre"; |
19715 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19716 |
|
19717 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19718 |
assertEquals( |
19719 |
"element:break completion:break relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19720 |
requestor.getResults()); |
19721 |
} |
19722 |
|
19723 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19724 |
public void test269493d() throws JavaModelException { |
19725 |
this.workingCopies = new ICompilationUnit[1]; |
19726 |
this.workingCopies[0] = getWorkingCopy( |
19727 |
"/Completion/src/test/Test269493.java", |
19728 |
"package test;" + |
19729 |
"public class Test269493 {\n" + |
19730 |
" void foo() {\n" + |
19731 |
" for (int i = 0; i < 10; i++)\n" + |
19732 |
" cont\n" + |
19733 |
" }\n" + |
19734 |
"}\n" + |
19735 |
"}\n"); |
19736 |
|
19737 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19738 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19739 |
String str = this.workingCopies[0].getSource(); |
19740 |
String completeBehind = "cont"; |
19741 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19742 |
|
19743 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19744 |
assertEquals( |
19745 |
"element:continue completion:continue relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19746 |
requestor.getResults()); |
19747 |
} |
19748 |
|
19749 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19750 |
public void test269493e() throws JavaModelException { |
19751 |
this.workingCopies = new ICompilationUnit[1]; |
19752 |
this.workingCopies[0] = getWorkingCopy( |
19753 |
"/Completion/src/test/Test269493.java", |
19754 |
"package test;" + |
19755 |
"public class Test269493 {\n" + |
19756 |
" int foo(int p) {\n" + |
19757 |
" if (p == 0)\n" + |
19758 |
" return 0;\n" + |
19759 |
" else\n" + |
19760 |
" ret\n" + |
19761 |
" }\n" + |
19762 |
"}\n" + |
19763 |
"}\n"); |
19764 |
|
19765 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19766 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19767 |
String str = this.workingCopies[0].getSource(); |
19768 |
String completeBehind = "ret"; |
19769 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19770 |
|
19771 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19772 |
assertEquals( |
19773 |
"element:return completion:return relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19774 |
requestor.getResults()); |
19775 |
} |
19776 |
|
19777 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19778 |
public void test269493f() throws JavaModelException { |
19779 |
this.workingCopies = new ICompilationUnit[1]; |
19780 |
this.workingCopies[0] = getWorkingCopy( |
19781 |
"/Completion/src/test/Test269493.java", |
19782 |
"package test;" + |
19783 |
"public class Test269493 {\n" + |
19784 |
" int foo(int p) {\n" + |
19785 |
" if (p == 0)\n" + |
19786 |
" return 0;\n" + |
19787 |
" els\n" + |
19788 |
" }\n" + |
19789 |
"}\n" + |
19790 |
"}\n"); |
19791 |
|
19792 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19793 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19794 |
String str = this.workingCopies[0].getSource(); |
19795 |
String completeBehind = "els"; |
19796 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19797 |
|
19798 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19799 |
assertEquals( |
19800 |
"element:else completion:else relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), |
19801 |
requestor.getResults()); |
19802 |
} |
19803 |
|
19804 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19805 |
public void test269493g() throws JavaModelException { |
19806 |
this.workingCopies = new ICompilationUnit[1]; |
19807 |
this.workingCopies[0] = getWorkingCopy( |
19808 |
"/Completion/src/test/Test269493.java", |
19809 |
"package test;" + |
19810 |
"public class Test269493 {\n" + |
19811 |
" int foo(int p) {\n" + |
19812 |
" els\n" + |
19813 |
" }\n" + |
19814 |
"}\n" + |
19815 |
"}\n"); |
19816 |
|
19817 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19818 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19819 |
String str = this.workingCopies[0].getSource(); |
19820 |
String completeBehind = "els"; |
19821 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19822 |
|
19823 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19824 |
assertEquals("", |
19825 |
requestor.getResults()); |
19826 |
} |
19827 |
|
19828 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19829 |
public void test269493h() throws JavaModelException { |
19830 |
this.workingCopies = new ICompilationUnit[1]; |
19831 |
this.workingCopies[0] = getWorkingCopy( |
19832 |
"/Completion/src/test/Test269493.java", |
19833 |
"package test;" + |
19834 |
"public class Test269493 {\n" + |
19835 |
" int foo(int p) {\n" + |
19836 |
" if (p == 0)\n" + |
19837 |
" return 0;\n" + |
19838 |
" else\n" + |
19839 |
" els\n" + |
19840 |
" }\n" + |
19841 |
"}\n" + |
19842 |
"}\n"); |
19843 |
|
19844 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19845 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19846 |
String str = this.workingCopies[0].getSource(); |
19847 |
String completeBehind = "els"; |
19848 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19849 |
|
19850 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19851 |
assertEquals( |
19852 |
"", |
19853 |
requestor.getResults()); |
19854 |
} |
19855 |
|
19856 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block |
19857 |
public void test269493i() throws JavaModelException { |
19858 |
this.workingCopies = new ICompilationUnit[1]; |
19859 |
this.workingCopies[0] = getWorkingCopy( |
19860 |
"/Completion/src/test/Test269493.java", |
19861 |
"package test;" + |
19862 |
"public class Test269493 {\n" + |
19863 |
" int foo(int p) {\n" + |
19864 |
" if (p == 0) {\n" + |
19865 |
" return 0;\n" + |
19866 |
" }\n" + |
19867 |
" else\n" + |
19868 |
" els\n" + |
19869 |
" }\n" + |
19870 |
"}\n" + |
19871 |
"}\n"); |
19872 |
|
19873 |
CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); |
19874 |
requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. |
19875 |
String str = this.workingCopies[0].getSource(); |
19876 |
String completeBehind = "els"; |
19877 |
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); |
19878 |
|
19879 |
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); |
19880 |
assertEquals( |
19881 |
"", |
19882 |
requestor.getResults()); |
19883 |
} |
19884 |
|
19630 |
} |
19885 |
} |