Use IntelliJ IDEA to see the source code when viewing how elegant class inheritance ... [to see] this is enough

1, view graphics in the form of inheritance chain

In the tab you want to view the class, right click and select Diagrams, which show and show ... Popup, but the former within the new tab page, which appear as a floating window:

Here Insert Picture Description
In fact, you can project from the left side of the tree, you want to see the class right click and select the same Diagrams, the effect is the same:
Here Insert Picture Description
Then you will get the inheritance pattern shown in the following figure, to custom controller as an example:

Here Insert Picture Description
The whole is not particularly obvious, we use the service as an example, look again:
Here Insert Picture Description
is obvious that:

The dotted line indicates the packet

Green dashed arrows refer interface relationship

Added: solid blue arrow means inheritance

2, optimized graphics inheritance chain, like I think

2.1 remove the class does not care about

Inheritance graphics get, some not what we want to know, such as a map service package, we just want to care about important relationships IDocTestService, how do?

Simple, deleted. Click to select the class you want to delete, and then directly use the delete key on the keyboard on the line . After cleaning up the relationship between other classes of graphics as follows:
Here Insert Picture Description

Details 2.2 show class

Some people say, eh, how does this enough, that those methods inherited I also want to see ah? Simple, IDEA meet you all.

Right-click the page, select show categories, you can expand as needed class properties, methods, constructors, and so on. Of course, the second method can also be used directly on top of the toolbar:

Here Insert Picture Description
Then you get:
Here Insert Picture Description

What, you want a method in the screening, for example, you want to see protected rights and above range? Simple, right click and choose Change Visibility Level, adjust as required.
Here Insert Picture Description
What, you too graphic is too small you can not see? IDEA also satisfy you, hold down the keyboard's Alt, actually had a magnifying glass, no surprise surprise, meaning not an accident?
Here Insert Picture Description

2.3 was added to the relationships to other classes

When we also need to see whether the current class and other classes have inheritance relationship, we can choose to add it into the current pattern of inheritance come.

Right-click the page, select Add Class to Diagram, and then the class you want to join it:

Here Insert Picture Description
For example we added a UserContext class, as shown below. Well, not any of the arrow, and it seems that the current number of classes and interfaces that it does not matter what happened can not be described:

Here Insert Picture Description

2.4 Specific Code View

If you want to see a class, such as the source code of a specific method, of course, it is impossible for you to show up on the graph, or screen shall also hold deep-fried?

But you can use graphics, or IDEA with the structure quickly and easily into the source code of a class to view.

After double-clicking a class, you can walk under it in the list of methods, for the way you want to view, select and right-click and select Jump to Source:

Here Insert Picture Description
Here Insert Picture Description
After entering a class, if you want a quick look at other methods of the class, you can also make use of structure functions IDEA provides:
Here Insert Picture Description

3, final

IDEA with these features mentioned above, learning and view class relationships, to understand things like the mainstream framework source code and the like, can be said to be very comfortable.

Digression: Welcome attention, comments, thumbs up, your encouragement is my creative power!

Published 69 original articles · won praise 304 · views 210 000 +

Guess you like

Origin blog.csdn.net/qq_43733123/article/details/104896936