是否可以显示Java代码的树形结构?
我是Java新手。我试图弄清楚如何工作
I am a newbie in Java. I am trying to figure out how to work this code. It seems to me that it would be very useful if in the beginning I get the general structure of the code (which methods exists and how they are interrelated). For example I see that "main" uses "createAndShowGUI" which, in its turn, uses "addComponentsToPane" and so on. So, the code has kind of a tree structure and it would be nice if I can visualize this structure. Is there any software that can do it. Or, more specifically, can NetBeans do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
右键单击 NetBeans 中的方法名称,您可以选择
调用层次结构
。它将打开一个显示树结构的窗口。我认为它默认为调用者视图。在窗口的工具栏中,您可以切换到被调用者视图。然后,您将获得当前方法调用的所有内容的可导航树视图。展开被调用者上的树将显示被调用者的方法。它不完全是一个图表,但应该有所帮助。Right clicking on a method name in NetBeans, you can choose
Call Hierarchy
. It'll open a window with a tree structure displayed. I think it defaults to the callers view. In the window's toolbar you can switch to the callees view. You will then have a navigable tree view of everything the current method calls. Expanding the tree on a callee will show that methods callees. It's not exactly a diagram but should help.不确定 Netbeans,但在 Eclipse 中,您可以右键单击一个方法并选择“打开调用层次结构”以获取调用您所选方法的方法的树视图,并且在视图的顶部有一个图标反转这个(“显示被调用者层次结构”),它几乎可以完成你想要的事情(除了它一次只显示一个方法的被调用者)。
Not sure about Netbeans, but in eclipse, you can right-click on a method and select "open call hierarchy" to get a tree view of methods that call the method you have selected, and at the top of the view is an icon to reverse this ("Show Callee Hierarchy"), which does pretty much what you want (except it shows only one method's callees at a time).
在 eclipse 中,您可以在 最后视图。 Netbeans 可能有类似的东西。
In eclipse you can see it in ast view. Netbeans might have something similar.
在 NetBeans 中打开
Window >导航器
。您将得到如图所示的结果 -
In NetBeans open
Window > Navigator
.You'll get it as shown in the image-
在 Mac OS X 上,Xcode 设计工具具有“快速模型”功能,对于可视化现有类特别方便图书馆。
On Mac OS X, the Xcode design tool has a "Quick Model" feature that is specially handy for visualizing an existing class library.
我有一些 Eclipse 插件的演示代码这里。它创建实例变量和实例方法以及它们如何相互关联的树视图和表视图。
I've some demo code here for an eclipse plugin. It creates a tree view and table view of instance variables and instance methods and how they relate to each other.
您可以使用优秀的 doxygen 源代码文档生成工具。
You can use the excellent doxygen source-code documentation generation tool for that.