基于AST的搜索Eclipse [英] AST-based search for Eclipse
问题描述
是否有Eclipse插件,可让您根据项目文件的Java AST(抽象语法树)进行搜索? Java搜索功能似乎没有涵盖如下情况:
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:
让我在所有类中声明为类型X的所有字段
"Get me all the fields declared as type 'X' in all classes"
我可以想象出更多的可能性,可以通过基于AST的搜索开放,但我甚至不知道这样的插件是否具有实际的性能。
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.
更新:如下面的Kevin所指出的,Java搜索功能确实涵盖了我提到的用例。我仍然很好奇,不管有人是否写了一个插件,允许任意种类的AST搜索,例如。 获取所有字符串连接(带有+运算符和StringLiteral操作数的InfixExpression)
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)
推荐答案
在所有类中声明为
'X'的字段
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:
- 打开X(Ctrl-Shift-T)
- 突出显示类名称
- Ctrl-H搜索 li>
- 搜索类型/匹配位置 - >字段类型
-
- Opening up type X (Ctrl-Shift-T)
- Highlight the class name
- Ctrl-H to search
- Search for Type / Match Locations -> Field Types
这篇关于基于AST的搜索Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!