基于 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 搜索
- 搜索类型/匹配位置 -> 字段类型
这篇关于基于 AST 的 Eclipse 搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!