Bug 62463 - Wrong length for ExpressionStatement after conversion
Summary: Wrong length for ExpressionStatement after conversion
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-17 07:51 EDT by Frederic Fusier CLA
Modified: 2004-05-18 13:49 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2004-05-17 07:51:01 EDT
Using I200405140800 build.

I was testing DOM AST nodes hierarchy building on all eclipse source files and 
noticed a problem in class 
org.eclipse.update.internal.model.InstallConfigurationParser

Here's a smaller example easier to debug:
import java.util.Vector;
public class A {
	AA aa;
	void foo() {    
		int size = (aa.bar()).size();
		System.out.println("Size=" + size);
	}
}
class AA {
	Vector bar() { return new Vector(1); };
}
In this case, (aa.bar()).size() ExpressionStatement has the same start position 
and length than aa.bar() which is not correct.

Here's a more annoying variation of this problem:
import java.util.Vector;
public class A {
  AA aa;
  void foo() {    
    (aa.bar()).get(0);
    // comment
    if (true) {
      System.out.println("Hello: " + toString()); //$NON-NLS-1$
    }
  }
}
class AA {
  Vector bar() { return new Vector(1); };
}
In this case (aa.bar()).get(0) ExpressionStatement starts at 'aa' and ends at 
semi-colon of syso statement!

I used ASTView plugin to see the invalid node ranges.

Looking at code, it seems that enclosing parenthesis around aa.bar() expression 
statement are not correctly handled in 
removeTrailingCommentFromExpressionEndingWithAParen(ASTNode) and 
retrieveEndingSemiColonPosition(int,int) methods of ASTConverter...
Comment 1 Olivier Thomann CLA 2004-05-17 10:06:36 EDT
I am investigating.
Comment 2 Olivier Thomann CLA 2004-05-17 10:39:18 EDT
Fixed and released in HEAD.
The code to optimize the case of cascading method invocations was not handling
intermediate parenthesized expressions.
Regression tests added (ASTConverterTest2.test0556 and test0557).
Comment 3 David Audel CLA 2004-05-18 13:49:32 EDT
Verified for 3.0M9