Bug 102778 - Scrapbook page doesn't work with enhanced for statement
Summary: Scrapbook page doesn't work with enhanced for statement
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-05 15:40 EDT by Olivier Thomann CLA
Modified: 2005-09-26 12:53 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (2.27 KB, patch)
2005-07-05 15:45 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (3.87 KB, patch)
2005-07-05 16:01 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2005-07-05 15:40:46 EDT
Using 3.1, create a new java project.
Add a new scrapbook page that contains this source:
 
int[] tab = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9 };
int sum = 0;
for (int i : tab) {
	sum += i;
}
sum

You get an error about syntax error.
Comment 1 Olivier Thomann CLA 2005-07-05 15:42:15 EDT
Candidate for 3.1.1.
The code snippet parser is missing the consumeEnhancedForStatement() method.
If you remove the last line, you can execute the code.

The fix is trivial.
Comment 2 Olivier Thomann CLA 2005-07-05 15:43:27 EDT
Adding this method in the code snippet parser fixes the problem.

protected void consumeEnhancedForStatement() {
	super.consumeEnhancedForStatement();
	/* recovery */
	recordLastStatementIfNeeded();	
}
Comment 3 Olivier Thomann CLA 2005-07-05 15:45:26 EDT
Created attachment 24361 [details]
Proposed fix
Comment 4 Olivier Thomann CLA 2005-07-05 16:01:40 EDT
Created attachment 24363 [details]
Regression test
Comment 5 Philipe Mulet CLA 2005-07-06 09:35:45 EDT
Agreed
Comment 6 Olivier Thomann CLA 2005-07-06 17:20:31 EDT
Fixed and released in 3.1 maintenance stream.
Regression test added in org.eclipse.jdt.core.tests.eval.DebugEvaluationTest.test063
Comment 7 Jerome Lanneluc CLA 2005-08-09 12:52:16 EDT
Verified with 3.2 M1
Comment 8 David Audel CLA 2005-09-26 12:53:16 EDT
Verified using M20050923-1430 for 3.1.1