java - Eclipse JDT ASTVisitor - how to tell if a field is read or written in a method? -


I am writing an eclipse ASTVisitor to tell how a field is read or written in a method?

The information provided "You need to vist the assignment node. The field is written on LHS, while the field on RHS expression is read."

After I go to the assignment and get LHS and RHS which are both of the expressions, how do I tell if the expression has a field?

If you are working on AST, then I suggest working with it. This is a very easy tool to understand JDT AST.

Your view will work, I use a variable inside the visitor to indicate that I am in an assignment.

  Public Boolean Visit (Last Assignment Node) {inVariableAssignment = true; . Accepting Node.getLeftHandSide () (this); InVariableAssignment = false; . Accepting Node.getRightHandSide () (this); return false; }  

Now, when I do something like SimpleName or QualifiedName :

  Public Boolean Visit (Last Simple Name Node) {if (! Node.isDeclaration ()) {Last Iibing Nodebading = Node. Rollingbung (); If (nodebading examples of iWerableBinding) {...}} return false; }  

The ellipisis (...) will be replaced by a code that handles field access according to the value of your inVariableAssignment . It will start you

Oh, do not forget Postfix expression and prefix expression ...


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -