views:

76

answers:

2

How does eclipse internally build its internal representation of java code in order to be able to detect things like unreferenced methods, or to find method references in a project? And is there any way to get a hook into that information to build tools based on eclipse's internal parsing, Whether as an eclipse plug-in or as a standalone? (for use in building some small tools for dead-code detection)

The closest thing I've found would involve building my own representations using bcel, but that definitely smells of reinventing the wheel.

+3  A: 

Eclipse's ASTParser (link 2) (link 3) is where you should start looking.

Mike Atlas
+2  A: 

There are tools for doing that, unless you are really keen on writing it yourself (as you've put it: reinventing the wheel).

FindBugs is a popular tool (don't let the 90's façade fool you) for detecting all sorts of problems in your code.

As for finding references, if Eclipse mechanism is not enough for your, check out nWire for Java, a code exploration tool.

And, yes, AST would be a good start. There are many questions on this subject, browse around.

zvikico