### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java,v retrieving revision 1.173 diff -u -r1.173 CompletionParser.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 5 Mar 2007 18:49:20 -0000 1.173 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 7 Mar 2007 16:29:19 -0000 @@ -3427,6 +3427,24 @@ } keywords[count++]= Keywords.BREAK; keywords[count++]= Keywords.CASE; + + keywords[count++]= Keywords.ASSERT; + keywords[count++]= Keywords.DO; + keywords[count++]= Keywords.FOR; + keywords[count++]= Keywords.IF; + keywords[count++]= Keywords.RETURN; + keywords[count++]= Keywords.SWITCH; + keywords[count++]= Keywords.SYNCHRONIZED; + keywords[count++]= Keywords.THROW; + keywords[count++]= Keywords.TRY; + keywords[count++]= Keywords.WHILE; + + keywords[count++]= Keywords.FINAL; + keywords[count++]= Keywords.CLASS; + + if(isInsideLoop()) { + keywords[count++]= Keywords.CONTINUE; + } } } System.arraycopy(keywords, 0 , keywords = new char[count][], 0, count); #P org.eclipse.jdt.core.tests.model Index: workspace/Completion/src2/CompletionKeywordReturn5.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordReturn5.java diff -N workspace/Completion/src2/CompletionKeywordReturn5.java --- workspace/Completion/src2/CompletionKeywordReturn5.java 21 Jan 2003 10:24:05 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ -public class CompletionKeywordReturn5 { - void foo() { - # - if(re - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordContinue2.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordContinue2.java diff -N workspace/Completion/src2/CompletionKeywordContinue2.java --- workspace/Completion/src2/CompletionKeywordContinue2.java 21 Jan 2003 10:24:04 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ -public class CompletionKeywordContinue2 { - void foo() { - if(true) { - cont - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordReturn4.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordReturn4.java diff -N workspace/Completion/src2/CompletionKeywordReturn4.java --- workspace/Completion/src2/CompletionKeywordReturn4.java 21 Jan 2003 10:24:04 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ -public class CompletionKeywordReturn4 { - void foo() { - # - re - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordReturn1.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordReturn1.java diff -N workspace/Completion/src2/CompletionKeywordReturn1.java --- workspace/Completion/src2/CompletionKeywordReturn1.java 21 Jan 2003 10:24:05 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,5 +0,0 @@ -public class CompletionKeywordReturn1 { - void foo() { - re - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordContinue1.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordContinue1.java diff -N workspace/Completion/src2/CompletionKeywordContinue1.java --- workspace/Completion/src2/CompletionKeywordContinue1.java 21 Jan 2003 10:24:05 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,7 +0,0 @@ -public class CompletionKeywordContinue1 { - void foo() { - for(;;) { - { - cont - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordContinue3.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordContinue3.java diff -N workspace/Completion/src2/CompletionKeywordContinue3.java --- workspace/Completion/src2/CompletionKeywordContinue3.java 21 Jan 2003 10:24:05 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,8 +0,0 @@ -public class CompletionKeywordContinue3 { - void foo() { - # - for(;;) { - { - cont - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordContinue4.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordContinue4.java diff -N workspace/Completion/src2/CompletionKeywordContinue4.java --- workspace/Completion/src2/CompletionKeywordContinue4.java 21 Jan 2003 10:24:05 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,7 +0,0 @@ -public class CompletionKeywordContinue4 { - void foo() { - # - if(true) { - cont - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordReturn2.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordReturn2.java diff -N workspace/Completion/src2/CompletionKeywordReturn2.java --- workspace/Completion/src2/CompletionKeywordReturn2.java 21 Jan 2003 10:24:04 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,5 +0,0 @@ -public class CompletionKeywordReturn2 { - void foo() { - if(re - } -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordReturn6.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordReturn6.java diff -N workspace/Completion/src2/CompletionKeywordReturn6.java --- workspace/Completion/src2/CompletionKeywordReturn6.java 21 Jan 2003 10:24:04 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,4 +0,0 @@ -# -public class CompletionKeywordReturn6 { - re -} \ No newline at end of file Index: workspace/Completion/src2/CompletionKeywordReturn3.java =================================================================== RCS file: workspace/Completion/src2/CompletionKeywordReturn3.java diff -N workspace/Completion/src2/CompletionKeywordReturn3.java --- workspace/Completion/src2/CompletionKeywordReturn3.java 21 Jan 2003 10:24:04 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,3 +0,0 @@ -public class CompletionKeywordReturn3 { - re -} \ No newline at end of file Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.150 diff -u -r1.150 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 5 Mar 2007 17:31:17 -0000 1.150 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 7 Mar 2007 16:29:34 -0000 @@ -5294,57 +5294,121 @@ requestor.getResults()); } public void testCompletionKeywordContinue1() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue1.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordContinue1.java", + "public class CompletionKeywordContinue1 {\n" + + " void foo() {\n" + + " for(;;) {\n" + + " {\n" + + " cont\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "cont"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "cont"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( - "element:continue completion:continue relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), + assertResults( + "continue[KEYWORD]{continue, null, null, continue, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testCompletionKeywordContinue2() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue2.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordContinue2.java", + "public class CompletionKeywordContinue2 {\n" + + " void foo() {\n" + + " if(true) {\n" + + " cont\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "cont"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "cont"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( + assertResults( "", requestor.getResults()); } public void testCompletionKeywordContinue3() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue3.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordContinue3.java", + "public class CompletionKeywordContinue3 {\n" + + " void foo() {\n" + + " #\n" + + " for(;;) {\n" + + " {\n" + + " cont\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "cont"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "cont"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( - "element:continue completion:continue relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), + assertResults( + "continue[KEYWORD]{continue, null, null, continue, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testCompletionKeywordContinue4() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue4.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordContinue4.java", + "public class CompletionKeywordContinue4 {\n" + + " void foo() {\n" + + " #\n" + + " if(true) {\n" + + " cont\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "cont"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "cont"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( + assertResults( "", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=176364 +public void testCompletionKeywordContinue5() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;"+ + "public class Test {\n" + + " void foo() {\n" + + " for (int i = 0; i < 1; i++) {\n" + + " switch (i) {\n" + + " case 0:\n" + + " conti\n" + + " break;\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "conti"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "continue[KEYWORD]{continue, null, null, continue, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} public void testCompletionKeywordDefault1() throws JavaModelException { CompletionTestsRequestor requestor = new CompletionTestsRequestor(); ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault1.java"); @@ -7945,81 +8009,147 @@ requestor.getResults()); } public void testCompletionKeywordReturn1() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn1.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordReturn1.java", + "public class CompletionKeywordReturn1 {\n" + + " void foo() {\n" + + " re\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "re"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( - "element:return completion:return relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), + assertResults( + "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testCompletionKeywordReturn2() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn2.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordReturn2.java", + "public class CompletionKeywordReturn2 {\n" + + " void foo() {\n" + + " if(re\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "re"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( + assertResults( "", requestor.getResults()); } public void testCompletionKeywordReturn3() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn3.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordReturn3.java", + "public class CompletionKeywordReturn3 {\n" + + " re\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "re"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( - "", + assertResults( + "re[POTENTIAL_METHOD_DECLARATION]{re, LCompletionKeywordReturn3;, ()V, re, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testCompletionKeywordReturn4() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn4.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordReturn4.java", + "public class CompletionKeywordReturn4 {\n" + + " void foo() {\n" + + " #\n" + + " re\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "re"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( - "element:return completion:return relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), + assertResults( + "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testCompletionKeywordReturn5() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn5.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordReturn5.java", + "public class CompletionKeywordReturn5 {\n" + + " void foo() {\n" + + " #\n" + + " if(re\n" + + " }\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "re"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( + assertResults( "", requestor.getResults()); } public void testCompletionKeywordReturn6() throws JavaModelException { - CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn6.java"); + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src2/CompletionKeywordReturn6.java", + "#\n" + + "public class CompletionKeywordReturn6 {\n" + + " re\n" + + "}\n"); - String str = cu.getSource(); - String completeBehind = "re"; - int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); - cu.codeComplete(cursorLocation, requestor); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); - assertEquals( - "", + assertResults( + "re[POTENTIAL_METHOD_DECLARATION]{re, LCompletionKeywordReturn6;, ()V, re, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=176364 +public void testCompletionKeywordReturn7() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;"+ + "public class Test {\n" + + " void foo() {\n" + + " switch (i) {\n" + + " case 0:\n" + + " re\n" + + " }\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "re"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "return[KEYWORD]{return, null, null, return, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } public void testCompletionKeywordStatic1() throws JavaModelException {