I am starting to use some Java code which was written by someone else. I have to understand, change and test it. The author is not available now. The package has some 50 files (and so classes) of different sizes. It would be great if I could just see/print out the names of the methods (public and private) and the public variables (like they are visible in the "outline window" in Eclipse). It would really help in understanding the code since I can just look at this and understand the general purpose of each class.
我开始使用一些由其他人编写的Java代码。我必须了解,改变并测试它。该作者现在不可用。该软件包包含大约50个不同大小的文件(以及类)。如果我能看到/打印出方法的名称(公共和私有)和公共变量(比如它们在Eclipse中的“大纲窗口”中可见),那将是很棒的。它真的有助于理解代码,因为我可以看一下这个并理解每个类的一般用途。
Can I do it in Eclipse other than by generating Javadoc, since Javadoc really creates too much details ? Is there a Eclipse plugin for this ? Or any other tool ?
除了生成Javadoc之外,我可以在Eclipse中执行此操作,因为Javadoc确实创建了太多详细信息吗?是否有Eclipse插件?还是其他任何工具?
Example:
For a Class file which represents a student, I could just get :
对于代表学生的类文件,我可以得到:
String name
int[] marks
int year
int idNumber
Student()
printName()
printMarks()
setName(String name)
...
6 个解决方案
#1
javap might give you what you want too:
javap可能会给你你想要的东西:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javap.html
#2
In Package Explorer, right click on the package in question, select Open Type Hierarchy (Shortcut F4) gives a nice view of the hierarchy of objects in that package, selecting a class in that view will give you the class details. Not exactly what you're asking for but it'll help in understanding the package that you're changing.
在Package Explorer中,右键单击有问题的包,选择Open Type Hierarchy(快捷键F4)可以很好地查看该包中对象的层次结构,在该视图中选择一个类将为您提供类详细信息。不完全是你所要求的,但它有助于理解你正在改变的包。
#3
I'm an IntelliJ user, so I can't help with an Eclipse plug-in, but I'd wonder if importing this into a UML tool like JUDE might be more helpful. It'll show you the methods, the attributes, and the relationships between objects. Personally, I think pictures are worth a thousand words, but that's just me.
我是IntelliJ用户,所以我无法使用Eclipse插件,但我想知道将它导入JUDE之类的UML工具可能会更有帮助。它将向您展示方法,属性以及对象之间的关系。就个人而言,我认为图片胜过千言万语,但那只是我。
#4
Nathan Feger's answer seems to be spot on. I made a plugin not long ago that tries to analyze the relationship between member variables/methods and might bring another perspective on things. Variable Usage Plugin
Nathan Feger的回答似乎是现场。我不久前制作了一个插件,试图分析成员变量/方法之间的关系,并可能带来另一种观点。变量使用插件
#5
You could create a Javadoc for the code and look at the index which shows the public classes/methods.
您可以为代码创建一个Javadoc,并查看显示公共类/方法的索引。
#6
Often generating a Javadoc out of the source code might also help you in navigating through the source code and getting a better understanding. You can do this through "Project/Generate Javadoc" menu.
通常从源代码生成Javadoc也可以帮助您浏览源代码并更好地理解。您可以通过“Project / Generate Javadoc”菜单执行此操作。
I have some doubts on whether there is a tool which does exactly what you want. Maybe you could achieve this by writing your own small tool that recursively walks over the code files and through Reflection prints out these infos.
我怀疑是否有一个工具可以完全满足您的需求。也许你可以通过编写自己的小工具来实现这一点,该工具以递归方式遍历代码文件并通过Reflection打印出这些信息。
Other tools that might help you in understanding the source code are Metrics plugins. There exists one for Eclipse.
其他可能有助于您理解源代码的工具是Metrics插件。 Eclipse中存在一个。
#1
javap might give you what you want too:
javap可能会给你你想要的东西:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javap.html
#2
In Package Explorer, right click on the package in question, select Open Type Hierarchy (Shortcut F4) gives a nice view of the hierarchy of objects in that package, selecting a class in that view will give you the class details. Not exactly what you're asking for but it'll help in understanding the package that you're changing.
在Package Explorer中,右键单击有问题的包,选择Open Type Hierarchy(快捷键F4)可以很好地查看该包中对象的层次结构,在该视图中选择一个类将为您提供类详细信息。不完全是你所要求的,但它有助于理解你正在改变的包。
#3
I'm an IntelliJ user, so I can't help with an Eclipse plug-in, but I'd wonder if importing this into a UML tool like JUDE might be more helpful. It'll show you the methods, the attributes, and the relationships between objects. Personally, I think pictures are worth a thousand words, but that's just me.
我是IntelliJ用户,所以我无法使用Eclipse插件,但我想知道将它导入JUDE之类的UML工具可能会更有帮助。它将向您展示方法,属性以及对象之间的关系。就个人而言,我认为图片胜过千言万语,但那只是我。
#4
Nathan Feger's answer seems to be spot on. I made a plugin not long ago that tries to analyze the relationship between member variables/methods and might bring another perspective on things. Variable Usage Plugin
Nathan Feger的回答似乎是现场。我不久前制作了一个插件,试图分析成员变量/方法之间的关系,并可能带来另一种观点。变量使用插件
#5
You could create a Javadoc for the code and look at the index which shows the public classes/methods.
您可以为代码创建一个Javadoc,并查看显示公共类/方法的索引。
#6
Often generating a Javadoc out of the source code might also help you in navigating through the source code and getting a better understanding. You can do this through "Project/Generate Javadoc" menu.
通常从源代码生成Javadoc也可以帮助您浏览源代码并更好地理解。您可以通过“Project / Generate Javadoc”菜单执行此操作。
I have some doubts on whether there is a tool which does exactly what you want. Maybe you could achieve this by writing your own small tool that recursively walks over the code files and through Reflection prints out these infos.
我怀疑是否有一个工具可以完全满足您的需求。也许你可以通过编写自己的小工具来实现这一点,该工具以递归方式遍历代码文件并通过Reflection打印出这些信息。
Other tools that might help you in understanding the source code are Metrics plugins. There exists one for Eclipse.
其他可能有助于您理解源代码的工具是Metrics插件。 Eclipse中存在一个。