--
You received this message because you are subscribed to the Google Groups "JavaParser" group.
To post to this group, send email to javap...@googlegroups.com.
To unsubscribe from this group, send email to javaparser+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javaparser?hl=en.
[snip]
> The VariableDeclarationExpr is indeed modified but changes are not
> propagated to other nodes where the variable is used in the method.
> The implication seems to be that a VariableDeclaratorId is not reused
> as part of the reference stored in the AST for the variable name
> whenever the variable is used in the method, but only used once, i.e.
> as a distinct node storing the locus of declaration.
>
> So, my question is how to have the change to the VariableDeclaratorId
> suitably propagated?
You have to visit all the sub-nodes of the VariableDeclarationExpr,
and also its sibling-nodes, and perform renaming for each node. Better
place to start would probably be "visit(BlockStmt n, Object arg)". The
arg parameter could be used to pass the info about "from" and "to".
And in the BlockStmt you probably don't want to change the name before
the variable declaration, so you have to keep track of that too. This
means that you have to also override "visit(NameExpr n, Object arg)"
which is where you rename the name in n based on the info given in
arg. You also need to implement visit for things like MethodCallExpr
to avoid replacing name of method being called and variable used in
parameter list, also probably for QualifiedNameExpr as well. Some
others too, probably. Can't tell from top of my head at the moment.
--
lego
See http://code.google.com/p/java-pm/
--
lego