Is it possible to display of the tree structure of the Java-code?
Asked Answered
S

7

7

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?

Strong answered 28/1, 2010 at 9:11 Comment(1)
That is no tree. Remember recursion? It can well be a non-tree graph.Abba
L
4

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).

Lilalilac answered 28/1, 2010 at 10:10 Comment(0)
J
5

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.

Jardiniere answered 3/2, 2010 at 19:17 Comment(0)
L
4

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).

Lilalilac answered 28/1, 2010 at 10:10 Comment(0)
L
1

In eclipse you can see it in ast view. Netbeans might have something similar.

Latreshia answered 28/1, 2010 at 9:19 Comment(1)
He wants to see iterated method calls, not the AST.Lilalilac
U
1

On Mac OS X, the Xcode design tool has a "Quick Model" feature that is specially handy for visualizing an existing class library. KeyEventDemo model

Unsheathe answered 28/1, 2010 at 18:27 Comment(0)
D
1

In NetBeans open Window > Navigator. You'll get it as shown in the image-

enter image description here

Dickerson answered 14/8, 2016 at 8:8 Comment(1)
Great answer, Partharaj Deb ! That was precisely what I was looking for.Groomsman
M
0

You can use the excellent doxygen source-code documentation generation tool for that.

Medico answered 28/1, 2010 at 9:39 Comment(1)
That's a good answer, @JRL, but I suppose the OP wanted a solution inside the IDE.Groomsman
F
0

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.

Ftc answered 28/1, 2010 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.