Bug 8856 - DOM AST: positions and bindings missing on QualifiedName
Summary: DOM AST: positions and bindings missing on QualifiedName
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 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-31 13:11 EST by Dirk Baeumer CLA
Modified: 2002-02-11 04:52 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 Dirk Baeumer CLA 2002-01-31 13:11:18 EST
Build 20020129

package object_in;

public class TestNestedRead {
	public TestNestedRead field;
	public int i;
	
	public int foo() {
		return field.field.field.field.i;
	}
}

For the QualifiedName node field.field...i the start position of the simple 
names is always -1 and the length is always 0. Furthermore the class 
resolveBinding on the SimpleName node always returns null.
Comment 1 Olivier Thomann CLA 2002-01-31 14:27:25 EST
The qualified name which contains field.field.field.field.i has source positions, but what 
you want is intermediate source positions for simple names in the qualified name?
Comment 2 Olivier Thomann CLA 2002-01-31 16:33:11 EST
I fixed the positions problem for all sub parts of the qualified name. Unfortunately I don't see 
how it could be possible to get the intermediate bindings. The problem is that I only get one 
qualified reference for all the nodes I create. Then I can only point the enclosing qualified name 
to the corresponding binding.
Is this a problem for you? Let me know if the latest version works 
as expected.
Comment 3 Olivier Thomann CLA 2002-01-31 17:49:19 EST
Now resolveBinding() on the simpleName 'i' gives the VariableBinding corresponding to the 
field declaration 'i' in the class TestNestedRead. resolveTypeBinding() returns the 
ITypeBinding corresponding to the primitive type int. It is not possible to get the 
resolveTypeBinding() or resolveBinding() on the sub parts field.field.field.field, 
field.field.field ,field.field and field. I have the resolved binding, but I have only one 
qualified name reference for all the sub parts. You can ask resolveTypeBinding() on 
field.field.field.field.i and this will return the ITypeBinding corresponding to the 
primitive type int.
I released this code in HEAD. Let me know if this is good enough for you. If 
this is fine, I will close this PR as FIXED.
Comment 4 Dirk Baeumer CLA 2002-02-01 04:14:19 EST
Im not sure if I fully understand the current limitation. Here is what I expect 
to get. Can you please annotate this example

QualifiedName(f.f.f.i): note changed field to f to avoid conflicts with term 
field
  - this.resolveBinding: IVariableBinding for i
  - this.resolveTypeBinding: int
  - this.name.resolveBinding: IVariableBinding for i
  - this.name.resolveTypeBinding: int
  - this.qualifier: see below

QualifiedName(f.f.f)
  - this.resolveBinding: IVariableBinding for f
  - this.resoveTypeBinding: TestNestedRead
  - this.name.resolveBinding: IVaraibleBinding for f
  - this.name.resolveTypeBinding: TestNestedRead
  - this.qualifier: see below

QualifiedName(f.f)
  - this.resolveBinding: IVariableBinding for f
  - this.resoveTypeBinding: TestNestedRead
  - this.name.resolveBinding: IVaraibleBinding for f
  - this.name.resolveTypeBinding: TestNestedRead
  - this.qualifier: see below

SimpleName(f)
  - this.resolveBinding: IVariableBinding for f
  - this.resoveTypeBinding: TestNestedRead

Comment 5 Dirk Baeumer CLA 2002-02-01 04:16:30 EST
In the case of nested qualifications: isn't QualifiedName.resolveBinding == 
QualifiedName.name.resolveBinding and QualifiedName.resolveTypeBinding == 
QualifiedName.name.resolveTypeBinding.
Comment 6 Olivier Thomann CLA 2002-02-01 10:11:53 EST
This is quite simple.

QualifiedName(f.f.f.i): note changed field to f to avoid conflicts with term 
field
  - this.resolveBinding: IVariableBinding for i
  - this.resolveTypeBinding: int
  - this.name.resolveBinding: IVariableBinding for i
  - this.name.resolveTypeBinding: int
  - this.qualifier: see below
All these requests can be performed without a problem.

This is the problem.
QualifiedName(f.f.f)
QualifiedName(f.f)
SimpleName(f)

For these three names, I cannot retrieve the right binding. The problem is that 
I have only one compiler's qualifiedNameReference for all those. Then I cannot 
retrieve the right binding for a subpart of the qualified name, because I don't 
know which binding I have to return. I don't know if I am very clear, but the 
point is that the only bindings you can retrieve are on the qualifiedname and 
its name part, but not on any subpart of the qualified name.
Comment 7 Dirk Baeumer CLA 2002-02-01 10:25:32 EST
But this is something we need. Otherwise refactoring a field that is used in 
this way fail (for example Self Encapsulate field).

The current compiler AST gives us those bindings in the field 
QualifiedNameReference.otherBindings. So I don't really understand why we can't 
get them in the new AST. One idea would be to walk the parent relationship, 
counting them until you reach the node pointing to the QualifiedNameReference 
and then using this counter (or a transformation) as an index into 
QualifiedNameReference.otherBindings.
Comment 8 Olivier Thomann CLA 2002-02-01 10:38:12 EST
I understand how crucial it is for you to get these bindings. I am working on 
it. I will use the walking strategy you described to hopefully be able to 
retrieve the right bindings.
I am working on that today and it should be fixed by the end of the day. Thanks 
for your feedback.
Comment 9 Dirk Baeumer CLA 2002-02-01 10:46:40 EST
Thanks for the quick response !
Comment 10 Olivier Thomann CLA 2002-02-01 12:37:01 EST
Fixed and released in HEAD.
Added ASTConverterTests>>test0227/test0228/test0206.