Bug 28682

Summary: org.eclipse.jdt.core.dom.ForStatement's body position is incorrect
Product: [Eclipse Project] JDT Reporter: Kelvin <kelvin>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Kelvin CLA 2002-12-19 12:31:00 EST
test case :

   for (int i = 0; i < 10; i++)  // for 1
        for (int j = 0; j < 10; j++)  // for 2
            if (true) { }
   
   for (;;) ;  // for 3

code :
   String fileContent; // get the file content here
   ForStatement forstat = (ForStatement)node; // first for loop
   System.out.println("for statement:"+ forstat.toString()); 
   Statement body = forstat.getBody();
   System.out.println("body statement:"+ body.toString());
   System.out.println("body position:" +
                      fileContent.substring(body.getStartPosition() 
                        , body.getStartPosition()+body.getLength()));


   You will see the body position is incorrect, compare with the second println 
statement.
Comment 1 Olivier Thomann CLA 2003-01-07 13:52:43 EST
I reproduced the problem. The problem is located in the Parser class.
Comment 2 Olivier Thomann CLA 2003-01-07 16:44:01 EST
Fixed and released in 2.1 stream.
Regression tests added.
Comment 3 Olivier Thomann CLA 2003-01-07 16:46:14 EST
Changed milestone.
Comment 4 David Audel CLA 2003-02-07 12:09:39 EST
Verified.