Community
Participate
Working Groups
Code completion doesn't work as expected in some cases. In the class below, content assistance is unavailable for the AnyClass methods. I've placed the AnyClass as an inner static class to simplify but it might as well be created as a separate class. Code completion however succeeds when I make any of the following changes: 1. When replacing the comparison operator ">" to a "<" in the if-statement. 2. Removing the paranthesis in the if-statement, ie changing "if (0 > (10))" to if "(0 > 10)" 3. or removing the LOOP_WHILE label. public class Test { public static class AnyClass { public static void callMe() { System.out.println("whatever"); } } public void method1() { LOOP_WHILE: while (true) { if (0 > (10)) { break LOOP_WHILE; } } AnyClass.callMe(); //code completion fails here } }
An exception occurs during code completion java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.buildMoreCompletionContext(CompletionParser.java:617) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.attachOrphanCompletionNode(CompletionParser.java:446) at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.updateRecoveryState(CompletionParser.java:3869) at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:10062) at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8902) at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1314) at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1167) at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:292) at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:255) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1930) at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:123) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:316) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:309)
Created attachment 54002 [details] Proposed fix
Released for 3.3 M4. Test added CompletionTests#testBug164311() Thanks for the test case which is the simplest test case to reproduce the bug. The labeled control statement and the '>' followed by a '(' are necessary to reproduce it.
Verified for 3.3M4 with I20061211-1119