FIELD_ACCESS in org.eclipse.jdt.core.dom.FieldAccess *Strange behaviour [message #705381] |
Fri, 29 July 2011 20:07  |
Eclipse User |
|
|
|
I am parsing a method using AST (dom).
I take an expression from the method body and I check if it's ASTNode type is FIELD_ACCESS. I only get 'true' if I refer to an instance variable using 'this'.
For example, if I have
public class Foo {
private int x = 10;
public void bar() {
x = 9;
}
}
If I create a visitor for MethodDeclarations, when my code is passed the body of method 'bar' above, I can get the x assignment statement, but the left hand operand (x) is of type 'SimpleName' whatever that is. It's type is not FIELD_ACCESS. However, if I change the statement to 'this.x = 9;' then the left hand operand is of type FIELD_ACCESS. This means that anytime I reference an instance variable in my code, I MUST prefix it with 'this' to have it recognized by my code as a FIELD_ACCESS. Is there a way around this? Thanks
[Updated on: Fri, 29 July 2011 20:08] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04588 seconds