VariableTree.getNameExpression and TreeScanner

Werner Dietl wdietl at gmail.com
Thu May 23 10:58:52 PDT 2013


>> Why is it desirable to traverse the receiver parameter name, which is
>> usually simply "this"?
>
> Because it might not be "this".
>
> What if you were using a TreeScanner to create a custom pretty printer?

Then you have to handle parameter names separately anyway, because, as
you point out below, the parameter names are not visited by a
"visitIdentifier".
So one could argue that it might be surprising that you get a new
"visitIdentifier" call for the "this" name or some other calls for the
more complex receiver name expressions.

Either way is fine with me.

cu, WMD.



>> Should other parameter names also be visited, for consistency?
>
>
> Other parameter names are represented by Name, not a tree node, so they
> can't be visited.  The nameExpression is only set for a receiver parameter
> and is null the rest of the time, much like the "default" value on a method
> decl is only set for a "method" in an anno decl.
>
> -- Jon



--
http://www.google.com/profiles/wdietl


More information about the type-annotations-dev mailing list