Bug 80021

Summary: [1.5] CCE in VariableBinding.getJavaElement()
Product: [Eclipse Project] JDT Reporter: Tobias Widmer <tobias_widmer>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M4   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
stack trace none

Description Tobias Widmer CLA 2004-12-02 10:39:29 EST
200412011139:

Steps to reproduce:
- Create 1.5 project with classes:
package a;
public class A {
  public void foo(){}
}

package b;
public class B {
  public void bar(A a, int f) {
    a.foo();
  }
}

- Invoke "Move Method" on "bar"
Comment 1 Tobias Widmer CLA 2004-12-02 10:40:22 EST
Created attachment 16303 [details]
stack trace
Comment 2 Olivier Thomann CLA 2004-12-02 15:59:33 EST
The parent of a VariableDeclaration can be something else than a
VariableDeclarationStatement.
It can be a EnhancedForStatement, a CatchClause or a MethodDeclaration. So the
CCE can occur in different cases.
Jérôme, I let you fix it.
Comment 3 Olivier Thomann CLA 2004-12-02 16:12:02 EST
Test case is ready in ASTConverter15Test.test0090. You simply need to enable the
test.
Comment 4 Olivier Thomann CLA 2004-12-02 16:14:15 EST
In fact I wonder why you need the parent.
The position (declaration source start and declaration source end) are the
positions of the Variable declaration. The name positions are the position of
the inner Name node, aren't they?
Comment 5 Jerome Lanneluc CLA 2004-12-03 08:00:41 EST
Fixed VariableBinding#getJavaElement() to handle the case of a
SingleVariableDeclaration. (Olivier you can see
ASTModelBridgeTests#testLocalVariable2() for the case where the parent is a
VariableDeclarationStatement).

Moved regression test to ASTModelBridgeTests#testLocalVariable3() (and
simplified it).
Comment 6 Frederic Fusier CLA 2004-12-15 07:30:00 EST
Verified for 3.1 M4 using build I200412142000.