Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 129967 Details for
Bug 269493
[assist] Keywords are not proposed in a for statement without block
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix & tests
patch.txt (text/plain), 14.60 KB, created by
Srikanth Sankaran
on 2009-03-26 10:51:51 EDT
(
hide
)
Description:
Proposed fix & tests
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2009-03-26 10:51:51 EDT
Size:
14.60 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >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.197 >diff -u -r1.197 CompletionTests.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 20 Mar 2009 10:39:24 -0000 1.197 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 26 Mar 2009 13:25:53 -0000 >@@ -19627,4 +19627,259 @@ > COMPLETION_PROJECT.setOptions(options); > } > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+// All the tests with the prefix test269493 are designed to offer coverage for all the changes that went >+// into this fix. >+public void test269493() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " void foo() {\n" + >+ " for (int i = 0; i < 10; i++)\n" + >+ " ass\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "ass"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ >+ // Save current compliance settings >+ Map options = COMPLETION_PROJECT.getOptions(true); >+ Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); >+ >+ try { >+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); >+ COMPLETION_PROJECT.setOptions(options); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertEquals( >+ "element:assert completion:assert relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), >+ requestor.getResults()); >+ } finally { >+ // Restore compliance settings. >+ options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); >+ COMPLETION_PROJECT.setOptions(options); >+ } >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493b() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " void foo() {\n" + >+ " for (int i = 0; i < 10; i++)\n" + >+ " ret\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "ret"; >+ 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), >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493c() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " void foo() {\n" + >+ " for (int i = 0; i < 10; i++)\n" + >+ " bre\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "bre"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertEquals( >+ "element:break completion:break relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493d() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " void foo() {\n" + >+ " for (int i = 0; i < 10; i++)\n" + >+ " cont\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ 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), >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493e() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " int foo(int p) {\n" + >+ " if (p == 0)\n" + >+ " return 0;\n" + >+ " else\n" + >+ " ret\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "ret"; >+ 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), >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493f() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " int foo(int p) {\n" + >+ " if (p == 0)\n" + >+ " return 0;\n" + >+ " els\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "els"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertEquals( >+ "element:else completion:else relevance:"+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED), >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493g() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " int foo(int p) {\n" + >+ " els\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "els"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertEquals("", >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493h() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " int foo(int p) {\n" + >+ " if (p == 0)\n" + >+ " return 0;\n" + >+ " else\n" + >+ " els\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "els"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertEquals( >+ "", >+ requestor.getResults()); >+} >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for loop without block >+public void test269493i() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test269493.java", >+ "package test;" + >+ "public class Test269493 {\n" + >+ " int foo(int p) {\n" + >+ " if (p == 0) {\n" + >+ " return 0;\n" + >+ " }\n" + >+ " else\n" + >+ " els\n" + >+ " }\n" + >+ "}\n" + >+ "}\n"); >+ >+ CompletionTestsRequestor requestor = new CompletionTestsRequestor(true /* ignore all proposal kinds */); >+ requestor.setIgnored(CompletionProposal.KEYWORD, false); // now enable only keywords. >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "els"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertEquals( >+ "", >+ requestor.getResults()); >+} >+ > } >Index: src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java,v >retrieving revision 1.10 >diff -u -r1.10 CompletionTestsRequestor.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java 27 Jun 2008 16:02:38 -0000 1.10 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java 26 Mar 2009 13:25:53 -0000 >@@ -32,6 +32,15 @@ > this.completionStart.addElement(String.valueOf(proposal.getReplaceStart())); > this.completionEnd.addElement(String.valueOf(proposal.getReplaceEnd())); > } >+ >+ public CompletionTestsRequestor(boolean ignoreAll) { >+ super(ignoreAll); >+ } >+ >+ public CompletionTestsRequestor() { >+ super(false); >+ } >+ > public void accept(CompletionProposal proposal) { > char[] typeName = null; > switch(proposal.getKind()) { >#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.203 >diff -u -r1.203 CompletionParser.java >--- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 20 Mar 2009 10:39:13 -0000 1.203 >+++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 26 Mar 2009 13:25:59 -0000 >@@ -3595,6 +3595,7 @@ > if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_CONTROL_STATEMENT_DELIMITER) { > popElement(K_CONTROL_STATEMENT_DELIMITER); > } >+ pushOnElementStack(K_CONTROL_STATEMENT_DELIMITER); > break; > case TokenNamewhile: > pushOnElementStack(K_BETWEEN_WHILE_AND_RIGHT_PAREN, this.bracketDepth); >@@ -4013,8 +4014,10 @@ > keywords[count++]= Keywords.THIS; > } > keywords[count++]= Keywords.NEW; >- >- if(kind == K_BLOCK_DELIMITER) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=269493: Keywords are not proposed in a for >+ // loop without block. Completion while at K_CONTROL_STATEMENT_DELIMITER case needs to handled >+ // similar to the K_BLOCK_DELIMITER with minor differences. >+ if(kind == K_BLOCK_DELIMITER || kind == K_CONTROL_STATEMENT_DELIMITER) { > if(this.canBeExplicitConstructor == YES) { > canBeExplicitConstructorCall = true; > } >@@ -4044,6 +4047,8 @@ > keywords[count++]= Keywords.FINALLY; > break; > } >+ } else if(this.previousKind == K_CONTROL_STATEMENT_DELIMITER && this.previousInfo == IF) { >+ keywords[count++]= Keywords.ELSE; > } > if(isInsideLoop()) { > keywords[count++]= Keywords.CONTINUE; >@@ -4341,6 +4346,7 @@ > case K_FIELD_INITIALIZER_DELIMITER : return false; > case K_SWITCH_LABEL : return true; > case K_BLOCK_DELIMITER : >+ case K_CONTROL_STATEMENT_DELIMITER: > switch(this.elementInfoStack[i]) { > case FOR : > case DO : >@@ -4360,6 +4366,7 @@ > case K_METHOD_DELIMITER : return false; > case K_FIELD_INITIALIZER_DELIMITER : return false; > case K_BLOCK_DELIMITER : >+ case K_CONTROL_STATEMENT_DELIMITER: > switch(this.elementInfoStack[i]) { > case FOR : > case DO : >@@ -4379,6 +4386,7 @@ > case K_METHOD_DELIMITER : return false; > case K_FIELD_INITIALIZER_DELIMITER : return false; > case K_BLOCK_DELIMITER : return false; >+ case K_CONTROL_STATEMENT_DELIMITER: return false; // FWIW > case K_INSIDE_RETURN_STATEMENT : return true; > } > i--;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 269493
:
129967
|
130200