Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AST-based search for Eclipse

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)

like image 773
dcstraw Avatar asked Feb 04 '10 20:02

dcstraw


2 Answers

There are several Eclipse plug-ins that provide object-oriented query languages and aim to answer such queries. Some of them:

  • Browse-by-Query
  • SEA-QL
  • Semmle code

Outside Eclipse there is JArchitect Code Query Language

like image 54
Andrejs Avatar answered Sep 28 '22 05:09

Andrejs


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
like image 32
Kevin Avatar answered Sep 28 '22 05:09

Kevin