用于分析 Java 源代码的工具
对于一个学生项目,我需要扩展一个 Java 项目。 问题是这个项目没有太多评论,很难分析。 我正在寻找一些东西来生成类图,如果可能的话,还可以生成序列图。
我已经尝试过 umbrello(但是大类存在一些错误)和agilej,但是该项目有很多包和子包,我没有找到如何递归生成图。
还有其他工具可以做到这一点吗?
先感谢您。
For a student project I need to extend a Java project.
The problem is that this project doesn't have a lot of comments and it's hard to analyze it.
I'm searching for something to generate a class diagram and, if possible, a sequence diagram.
I have already tried umbrello
(but there are some bugs with big classes) and agilej
but the project has a lot of packages and sub-packages and I did not find how to generate the diagram recursively.
Are there other tools to do this?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Eclipse 中,您可以选择将包表示方式设置为“扁平”或“分层”。在平面模式下,您可以在 src/ 文件夹下看到每个包的完全限定名称,在分层模式下,您必须展开才能看到 src/com/mypackage 等。在 AgileJ 中,当您处于平面模式(默认模式) Eclipse),然后无论您从包资源管理器中拖动什么,无论是项目、文件夹、库、Java 源文件、类还是其他什么,它将通过所有权树向下递归并添加它找到的类,就像您期望的那样。
当您将包资源管理器置于层次结构模式时,您在问题中描述的异常现象(不通过子包递归)就会发生。在这种情况下,会发生的情况是,类图仅接收到包删除的通知 - 但它无法知道包资源管理器的包呈现模式,或者即使拖动源自包资源管理器。
因此,如果您确实想在包的层次结构中递归,并且出于某种原因不想在平面模式下使用包资源管理器多次选择它们,那么最简单的方法就是切换到资源透视图并在导航器中查看找到您要包含的所有包的父文件夹,然后将其拖到类图上。这将开始对子包中的类进行递归搜索。
请注意,如果您拖入足够多的类(确切的阈值是可配置的),那么它将提供对它们的过滤 - 例如,您可能想要过滤掉单元测试或生成的类。如果您尝试添加大量的类(同样,它是可配置的,但默认情况下为 200 个),那么您将被阻止 - 但是包含 200 个类的单个类图有什么意义呢?只会导致不可读的类图。
In Eclipse you have the option to set the package presentation to Flat or Hierarchical. In the flat mode you see the fully qualified name of each package under the src/ folder, and in the hierarchical mode you have to expand to see src/com/mypackage etc. In AgileJ when you are in flat mode (the default mode for Eclipse) then whatever you drag from the package explorer, be it a project, folder, library, Java source file, class or whatever, it will recurse down through the ownership tree and add the classes which it finds as you would expect it to do.
The anomaly you describe in you question - not recursing through the sub-packages - happens when you have the package explorer in hierarchy mode. In this case what happens is that the class diagram just receives notification of a drop of a package - but it has no way of knowing the package presentation mode of the package explorer or even if the drag originated from the package explorer.
So if you really want to recurse down through a hierarchy of packages, and for some reason don't want to multiple select them with the package explorer in flat mode, then the easiest thing to do is switch to the Resource perspective and in the Navigator view find the folder which is the parent of all the packages you want to include then drag that onto the class diagram. That will kick off a recursive search for classes down through the sub-packages.
Please note that if you drag in a large enough number of classes (the exact threshold is configurable) then it will offer to filter them down - for example you might want to filter out unit tests or generated classes. If you try to add a really large number of classes (again, it is configurable, but by default it is 200) then you'll be blocked - but what is the point of a single class diagram with 200 classes on it, it will only result in an unreadable class diagram.
另一个 Eclipse 插件称为“metrics”,您可以在 sourceforge 上找到它。它可以以文本和图形形式提供有关 Java 项目的大量信息。
Another eclipse plugin is called 'metrics', which you can find on sourceforge. It can provide a bunch of information about a Java project, both in textual and graphical form.