Community
Participate
Working Groups
Sorry i don't have a simple test case to reproduce the problem 1) install build I20061114-1636 2) launch it 3) checkout org.eclipse.jdt.core v723 4) open org.eclipse.jdt.internal.compiler.ast.WhileStatement 5) add a breakpoint at the beginning of Parser#consumeStatementWhile() 6) add a breakpoint at the beginning of AssistParser#consumeToken(int) 7) disable all your breakpoints 8) launch the Eclipse of your worskspace in debug mode 9) create this compilation unit 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 } } 10) enable the breakpoint at Parser#consumeStatementWhile() 11) place the cursor inside 'callMe' invocation and code assist (ctrl+space) you hit the breakpoint at Parser#consumeStatementWhile() 12) enable the breakpoint at AssistParser#consumeToken(int) 13) do resume (F9) you hit the breakpoint at AssistParser#consumeToken(int) 14) do step over (F6) then you reach line 686 :"if(isFirst) {" 15) do step over (F6) then you reach line 692 :"if (isInsideMethod() || isInsideFieldInitialization() || isInsideAttributeValue()) {" 16) do step over (F6) then you reach line 693 :"switch (token) {" 17) do step over (F6) then you reach line 709 :"this.pushOnElementStack(K_SELECTOR, this.identifierPtr);" You should not reach the line 709, the value of 'token' is the value of TokenNameIdentifier and the only case of the switch contains TokenNameLPAREN. The position of the last step over is wrong. The code of line 709 doesn't seem to be executed but the debugger show this line.
Smaller test case: public class X { private static final int CONST_1 = 1; private static boolean foo() { return true; } public static void main(String[] args) { int token = 5; int previousToken = 7; if (foo()) { switch (token) { case 5 : switch (previousToken) { case CONST_1: if(token > -1) { bar(7); } break; } break; } } else { bar(8); } } private static void bar(int i) { if (i == 7) { System.out.println("FAILED"); //$NON-NLS-1$ } } } Stepping inside main goes to bar(7) even if this is never executed.
Created attachment 54133 [details] Proposed fix David, could you please try this patch?
Created attachment 54134 [details] Regression tests
I tried the patch and i still reproduce the problem.
Are you sure you rebuilt the project ?
I forgot to rebuild the project. I retry your patch.
The behavior have change but there is still a bug. Now the step 17 of my test case is 17) do step over (F6) then you reach line 713: "break;" instead of 17) do step over (F6) then you reach line 709: "this.pushOnElementStack(K_SELECTOR, this.identifierPtr);" The correct line should be 724.
I can reproduce the problem by replacing "int token = 5;" by "int token = 6;" in your test case.
(In reply to comment #7) > The correct line should be 724. There is no way I can get line 724. I think line 714 would be acceptable.
Created attachment 54196 [details] New patch
Created attachment 54197 [details] Updated regression tests
David, could you please confirm that this works better? I'll try it on my side as well.
Looks much better to me.
It works as you describe. The line 724 would be better but 714 is acceptable.
Released for 3.3M4.
Verified for 3.3M4 with I20061212-0010.