基于 AST 的 Eclipse 搜索
Eclipse 是否有一个插件可以让您根据项目文件的 Java AST(抽象语法树)进行搜索? “Java 搜索”功能似乎并不涵盖以下情况:
“获取所有类中声明为“X”类型的所有字段”
我可以想象基于 AST 的搜索会带来更多可能性,但我也不知道这样的插件是否有实用性能。
更新:正如 Kevin 下面所指出的,Java 搜索功能确实涵盖了我提到的用例。我仍然很好奇是否有人编写了一个允许任意类型 AST 搜索的插件,例如。 “获取所有字符串连接”(带有 + 运算符和 StringLiteral 操作数的 InfixExpression)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有几个 Eclipse 插件提供面向对象的查询语言并旨在回答此类查询。其中一些:
在 Eclipse 之外有 < a href="http://www.javadepend.com/Features.aspx#CQL" rel="nofollow noreferrer">JArchitect 代码查询语言
There are several Eclipse plug-ins that provide object-oriented query languages and aim to answer such queries. Some of them:
Outside Eclipse there is JArchitect Code Query Language
我不知道您还有什么想法,但我相信您可以通过执行以下操作来完成此特定搜索:
I don't know what else you had in mind but I believe you can accomplish this specific search by doing the following:
这并不完全是您正在寻找的内容,但 nWire for Java 可以为您提供大量源自 AST 的信息。它还具有全文搜索功能,用于搜索任何类型、方法、字段等。找到所需内容后,单击即可显示该组件的所有关联。
请在此处查看演示。
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.