处理成eclipse对java代码的解析?
Eclipse 如何在内部构建其 Java 代码的内部表示,以便能够检测诸如未引用的方法之类的内容,或者在项目中查找方法引用?有没有什么方法可以获取这些信息来构建基于 Eclipse 内部解析的工具,无论是作为 Eclipse 插件还是作为独立的? (用于构建一些用于死代码检测的小工具)
我发现的最接近的事情是使用 bcel,但这绝对有重新发明轮子的味道。
How does eclipse internally build its internal representation of java code in order to be able to detect things like unreferenced methods, or to find method references in a project? And is there any way to get a hook into that information to build tools based on eclipse's internal parsing, Whether as an eclipse plug-in or as a standalone? (for use in building some small tools for dead-code detection)
The closest thing I've found would involve building my own representations using bcel, but that definitely smells of reinventing the wheel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Eclipse 的 ASTParser (链接 2) (链接 3) 是您应该开始查找的地方。
Eclipse's ASTParser (link 2) (link 3) is where you should start looking.
有一些工具可以做到这一点,除非您真的热衷于自己编写它(正如您所说:重新发明轮子)。
FindBugs 是一个流行的工具(不要让 90 年代的外观欺骗了你),用于检测你的代码。
至于查找参考,如果 Eclipse 机制不适合您,请查看 nWire for Java,一个代码探索工具。
是的,AST 将是一个好的开始。这个问题有很多问题,浏览一下。
There are tools for doing that, unless you are really keen on writing it yourself (as you've put it: reinventing the wheel).
FindBugs is a popular tool (don't let the 90's façade fool you) for detecting all sorts of problems in your code.
As for finding references, if Eclipse mechanism is not enough for your, check out nWire for Java, a code exploration tool.
And, yes, AST would be a good start. There are many questions on this subject, browse around.