views:

78

answers:

2

Is there a plug-in for Eclipse that lets you search based on the Java AST (Abstract Syntax Tree) of your project files? The "Java Search" feature doesn't seem to cover cases like:

"Get me all the fields declared as type 'X' in all classes"

I can imagine many more possibilities that would open up with an AST-based search, but I don't even know if such a plug-in would have practical performance.

Update: As pointed out by Kevin below, the Java Search feature does cover the use case I mentioned. I'm still curious though about whether or not someone has written a plug-in that allows any arbitrary kind of AST search, ex. "Get all string concatenations" (InfixExpression with + operator and StringLiteral operand)

+1  A: 

Get me all the fields declared as type 'X' in all classes

I don't know what else you had in mind but I believe you can accomplish this specific search by doing the following:

  • Opening up type X (Ctrl-Shift-T)
  • Highlight the class name
  • Ctrl-H to search
  • Search for Type / Match Locations -> Field Types
Kevin
That seems to just return the declaration of the type itself.
dcstraw
Sorry. I edited the entry to use the Match Locations filter instead of Declarations.
Kevin
Ah, excellent, thank you. I had never tried the Match Locations option before. That at least covers the use case I mentioned.
dcstraw
Marking this as the answer since it covers most cases where I might have otherwise wanted an AST-based search.
dcstraw
+1  A: 

It's not exactly what you're looking for, but nWire for Java can give you a lot of information which is derived from the AST. It also has a full text search for searching any type, method, field, etc. Once you find what you're looking for, a click will show you all the associations of that component.

Check out the demo here.

zvikico