Korhan
Korhan

Reputation: 232

How to parse and list classes fields, constructors and methods that are used in a java file or code block?

I need to write a crawler to find sample java class,method and field usage. So I need a parser to parse a java source file (parsing of source code in incomplete form is much more better of course!) and return used classes, methods, fields in it.

public void methodName() {

   String s = new String("Test");

   int x = s.lastIndexOf("st");

}

In this example, I want to get that String class is used, its String(String) constructor and its lastIndexOf(String) method are called.

Upvotes: 0

Views: 318

Answers (1)

Considered writing a Javadoc doclet which can do what you need?

http://download.oracle.com/javase/1.5.0/docs/guide/javadoc/

Upvotes: 1

Related Questions