Bug 111618

Summary: [1.5][dom] Foreach statement shows extraneous semi column into debug variables view
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 M3   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Maxime Daniel CLA 2005-10-05 10:50:00 EDT
Build id: I20050923-1000

When debugging into code that parses Java source into a model, the following
statement:
for (Object o : i) {
  o.toString();
}
appears as follows when selecting the matching ForeachStatement instance into
the variables view of the debugger:
for (Object o; : i) {
  o.toString();
}
(note the extraneous ; after o).
This must be related to printStatement, which calls Statement.print, hence
gets the terminator whereas it should not.
Comment 1 Olivier Thomann CLA 2005-10-05 13:15:42 EDT
yes, this is related to the fact that Object o is considered as a local
declaration and therefore it is printed as a statement. We would need to change
the printStatement(...) implementation of the ForeachStatement not to use the
print method for the local declaration.
But this is for debugging purpose anyway, so is it really worth it?
Comment 2 Olivier Thomann CLA 2005-10-06 19:37:42 EDT
I'll fix it. We simply cannot use the print method for the local variable
declaration in the foreach.
Comment 3 Olivier Thomann CLA 2005-10-06 21:03:33 EDT
Fixed and released in HEAD.
Regression test added in
org.eclipse.jdt.core.tests.compiler.parser.DietRecoveryTest.test113.
Comment 4 David Audel CLA 2005-10-31 06:18:03 EST
Verified for 3.2 M3 using build I20051031-0010