-
Enhancement
-
Resolution: Fixed
-
P3
-
8
-
b91
-
Verified
It would be useful to javac Plugins and AnnoationProcessors if Trees.getElement would respond with a Element/Symbol also for non-declarations, similarly to current DocTrees.getElement(TreePath, ReferenceTree) does. For example, consider this snippet:
StringBuilder sb = new StringBuilder();
sb.append("");
Consider a plugin that wants to find out which method is actually invoked by "sb.append". Right now, the information is stored in the javac's trees, there is no easy way to read it out without touching javac internals. Probably the easiest way right now is to take the Trees.getTypeMirror for "sb.append" and Trees.getTypeMirror for "sb", and iterate the site's methods looking for one that would match the ExecutableType, which is quite complex.
StringBuilder sb = new StringBuilder();
sb.append("");
Consider a plugin that wants to find out which method is actually invoked by "sb.append". Right now, the information is stored in the javac's trees, there is no easy way to read it out without touching javac internals. Probably the easiest way right now is to take the Trees.getTypeMirror for "sb.append" and Trees.getTypeMirror for "sb", and iterate the site's methods looking for one that would match the ExecutableType, which is quite complex.