Bug 203579 - [dom] Length of VariableDeclarationFragment is not the same inside a 'for' initialisation
Summary: [dom] Length of VariableDeclarationFragment is not the same inside a 'for' in...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 199668
  Show dependency tree
 
Reported: 2007-09-17 07:30 EDT by David Audel CLA
Modified: 2007-10-29 07:39 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (4.22 KB, patch)
2007-09-19 13:26 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (3.63 KB, patch)
2007-09-19 13:27 EDT, Olivier Thomann CLA
no flags Details | Diff
New fix (8.69 KB, patch)
2007-09-20 14:44 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 David Audel CLA 2007-09-17 07:30:44 EDT
build I20070917-0010

1) create X.java
public class X {
	void foo() {
		int   a  /*a*/,   b  /*b*/;
		for (int  i  /*i*/,  j  /*j*/;;) {
		}
	}
}

2) build a DOM AST (with ASTView).
The end of 'a' is after '/*a*/'.
The end of 'b' is after '/*a*/'.
The end of 'i' is after 'int  i' and not after '/*i*/'.
The end of 'j' is after ',  j' and not after '/*j*/'.

The end of the fragment should be the same in each case.
Comment 1 Olivier Thomann CLA 2007-09-17 08:36:50 EDT
Do we want to include the trailing comment inside the positions ?
I would say no. The comment could be included in the extended range though.
David, any thought ?
Comment 2 David Audel CLA 2007-09-17 09:00:21 EDT
My explanation wasn't clear. The problem isn't related to trailing comments. The problem is the same without comments.

public class X {
        void foo() {
                int   a  ,   b  ;
                for (int  i  ,  j  ;;) {
                }
        }
}

Inside a 'for' statement the end of the fragment is at the end of the variable name and inside a locale variable the end is just before the next comma or semicolon.
The problem is in the same area as bug 199668.
Comment 3 Olivier Thomann CLA 2007-09-17 09:09:21 EDT
The positions should be consistent in both cases. No whitespaces should be included in the position range.
Comment 4 Olivier Thomann CLA 2007-09-19 13:26:17 EDT
Created attachment 78775 [details]
Proposed fix
Comment 5 Olivier Thomann CLA 2007-09-19 13:27:51 EDT
Created attachment 78776 [details]
Regression test
Comment 6 Olivier Thomann CLA 2007-09-20 14:44:56 EDT
Created attachment 78882 [details]
New fix
Comment 7 Olivier Thomann CLA 2007-09-20 14:45:43 EDT
Released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0686
Comment 8 Jerome Lanneluc CLA 2007-10-29 07:39:18 EDT
Verified for 3.4M3 using I20071029-0800