Community
Participate
Working Groups
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.
I reproduced the problem. The problem is located in the Parser class.
Fixed and released in 2.1 stream. Regression tests added.
Changed milestone.
Verified.