Skip to main content

JDK Compiler API

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
dlsa
Offline
Joined: 2011-10-31

Hello,

I am trying to develop some code that will analyse a code base for a project. I have made an implementation based on the example :

http://today.java.net/pub/a/today/2008/04/10/source-code-analysis-using-...

I implemented the visiClass method of the class that extends the TreePathScanner.

The code

        // Get the current path of the node              TreePath path = getCurrentPath();          //Get the type element corresponding to the class         TypeElement e = (TypeElement) trees.getElement(path);

returns null on the second statement when in the case of inner classes. How do I get the element in those cases ?

Regards

Daniel Santos

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
brucechapman
Offline
Joined: 2004-03-18

Can you format your code so that we can see "the second statement" please.

Bruce

dlsa
Offline
Joined: 2011-10-31

Here it goes. It was a copy/paste issue.

// Get the current path of the node
[prettify]TreePath path = getCurrentPath();         
//Get the type element corresponding to the class         TypeElement e = (TypeElement) trees.getElement(path); [/prettify]