Bug 11638

Summary: ast: CompilationUnit::findDeclaringNode fails
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.0 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Adam Kiezun CLA 2002-03-19 10:26:32 EST
package p;
class A{
	void m(){
		final int j= 0;
		A a= new A(){
			void m(int j){
				int u= j;
			}
		};
	}
}

i have SimpleName ('j' in the int u= j declaration) in hand
i call resolveBinding and get a VariableBinding
on the CompilationUnit (root of all nodes) i call findDeclaringNode on that 
binding

null is returned - i expected the SingleVariableDeclaration from the 
MethodDeclaration (m)
Comment 1 Olivier Thomann CLA 2002-03-19 10:40:53 EST
You are right. You should get the declaration of 'j' in the method declaration.
I will fix it 
today.
Comment 2 Olivier Thomann CLA 2002-03-19 10:50:35 EST
I hope you mean that you want the single variable declaration of 'j' in 'void m(int j){' and not the 
'final int j = 0'.
I am working on it.
Comment 3 Adam Kiezun CLA 2002-03-19 11:04:43 EST
yes, argument j in declaration of void m(int j)
Comment 4 Olivier Thomann CLA 2002-03-19 12:08:28 EST
My test case is:
[
package test0311;

public class Test {
	void m(){
		final int j= 
0;
		A a= new A(){
			void m(int j){
				int u= j;
			}
		};
	}
}
]

and I don't 
get null when I ask for the declaring node of the binding I retrieve from the name 'j'. I don't have 
the right node, but I don't get null.
Which version are you using?
Comment 5 Olivier Thomann CLA 2002-03-19 12:13:38 EST
Oops, I had to change A in Test in the test case. Now I got null.
Comment 6 Olivier Thomann CLA 2002-03-19 12:28:49 EST
The initial problem is fixed, but I need to find out why I could resolve bindings with a compiler 
error.
Comment 7 Olivier Thomann CLA 2002-03-19 12:57:44 EST
*** Bug 11659 has been marked as a duplicate of this bug. ***
Comment 8 Olivier Thomann CLA 2002-03-19 12:59:32 EST
Fixed and resolved in HEAD.