When using Java to write complex programs, do you often feel confused about the inheritance relationships and calling methods? Fortunately, we have a good ide like eclipse that can help us clarify our clues-this requires the use of Eclipse's powerful code tracking function.
1. open declaration allows you to view declarations of classes, methods, and variables. This is the most commonly used function. If you right-click the object to be traced and select open declaration, you can jump to the declared place. This function has a shortcut key F3. Of course, you can also press and hold the ctrl key, move the mouse over and it will become a small hand, and click it.
2. You can use open type hierarchy to view the class inheritance relationship. You can see the inheritance hierarchy navigation in the hierarchy window. Right-click the method or Class Name and select Open Type hierarchy. The shortcut key is F4.
3. Use open call hierarchy to view the call level of the method. If you want to know where a method is called, this function is very useful and is also very common. For example, when you want to refactor a method, you can use this function if you want to know where it may affect others. Right-click the method name and select Open Type hierarchy. The shortcut key is CTRL + ALT + H. You can see the call hierarchy navigation of the method in the call hierarchy window.
4. Use open super implemention to view the implementation of the current method in the parent class or the declaration of the interface (provided that the method is a rewriting of the corresponding method in the parent class or interface ), right-click the method name and select Open super implemention.
5. Finally, we will introduce a super easy-to-use function called Open implemention, which can jump to the specific implementation of a called method. Why is it super easy to use? Anyone who has used spring knows that API-oriented programming is now promoted. Therefore, if you use open declaration to track the call of a method, you will only see the declaration of this method in the interface, instead, you can use call hierarchy to obtain the entire invocation level of the method, and then navigate to the specific implementation, but the operation is a little troublesome. With open
Implemention, you can directly see the implementation code. Right-click the method name and select Open implemention! To enjoy this function, you can install an Eclipse plug-in.
(Now, press Ctrl + T or Ctrl and place the cursor over the method name. There are two options: open interface and open implemention)