Bug 11638 - ast: CompilationUnit::findDeclaringNode fails
Summary: ast: CompilationUnit::findDeclaringNode fails
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 11659 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-19 10:26 EST by Adam Kiezun CLA
Modified: 2002-03-20 14:29 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.