简体   繁体   English

分析Java源代码的工具

[英]Tools for analyze Java source code

For a student project I need to extend a Java project. 对于一个学生项目,我需要扩展一个Java项目。 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. 我已经尝试过umbrello (但是umbrello有一些bug)和agilej但是该项目有很多程序包和子程序包,我没有找到如何递归生成图的方法。

Are there other tools to do this? 还有其他工具可以做到这一点吗?

Thank you in advance. 先感谢您。

In Eclipse you have the option to set the package presentation to Flat or Hierarchical. 在Eclipse中,您可以选择将包显示设置为Flat或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. 在平面模式下,您可以在src /文件夹下看到每个软件包的全限定名称,在分层模式下,您必须展开才能看到src / com / mypackage等。在AgileJ中,当您处于平面模式时(默认模式为Eclipse),然后从包资源管理器中拖动它,无论是项目,文件夹,库,Java源文件,类还是其他任何东西,都将通过所有权树向下递归,并按您的期望添加找到的类。

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. 如果您尝试添加非常多的类(同样,它是可配置的,但是默认情况下为200),那么您将被阻止-但是具有200个类的单个类图的意义何在?只会导致无法读取的类图。

Another eclipse plugin is called 'metrics', which you can find on sourceforge. 另一个eclipse插件称为“指标”,您可以在sourceforge上找到它。 It can provide a bunch of information about a Java project, both in textual and graphical form. 它可以以文本和图形形式提供有关Java项目的大量信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM