I got confused when using this two commands in eclipse
Ctrl+Shift+G and Ctrl+Alt+H both are returning same results .
Scenario:
Want to find where the method "findUsage" has been called.
Sample Class
Call Hierarchy Output (Ctrl+Alt+H) .
Find References (Ctrl+Shift+G) output
Both are showing same results. Can anyone know what is the difference between these two commands?
In the Java perspective, Call Hierarchy view shows callers and callees for the selected Java member. In the JavaScript perspective, Call Hierarchy view shows callers and callees for the selected JS member. Both Java and JavaScript perspectives (as well as their views) are the part of the Eclipse-based IDE.
Right click and select References > Project or References > Workspace from the pop-up menu. Show activity on this post. This will show you a Search view containing the hierarchy of class and method which using this method.
Press Ctrl+Shift+H -or- from the Menu Bar go to Navigate | Open Type in Hierarchy. The "Open Type in Hierarchy" dialog is displayed.
To display the Call Hierarchy window, right-click in the code editor on the name of a method, property, or constructor call, and then select View Call Hierarchy. The member name appears in a tree view pane in the Call Hierarchy window.
"Find references" shows you all direct callers of the selected method. "Call hierarchy" in contrast shows also the callers of those direct callers, and the callers of those, ... and so on.
So the output is only identical, if direct callers of your selected method do not have any callers themselfes. Just try both commands on some larger code base and you will immmediately see the difference, like in this screenshot:
If you wonder why there are two such features, if "Find references" is basically just a subset of the "Call hierarchy": Find references works really fast, so you can use it all the time without any waiting for results. The call hierarchy on the other hand takes more computation time and therefore may interrupt your coding workflow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With