Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between call hierarchy and find references eclipse?

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

enter image description here

Call Hierarchy Output (Ctrl+Alt+H) .

enter image description here

Find References (Ctrl+Shift+G) output

enter image description here

Both are showing same results. Can anyone know what is the difference between these two commands?

like image 595
kannanrbk Avatar asked Dec 24 '12 10:12

kannanrbk


People also ask

What is call hierarchy in Eclipse?

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.

Where can I find method references in eclipse?

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.

How do I open hierarchy in Eclipse?

Press Ctrl+Shift+H -or- from the Menu Bar go to Navigate | Open Type in Hierarchy. The "Open Type in Hierarchy" dialog is displayed.

How can I see the call hierarchy code in Visual Studio?

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.


2 Answers

"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:

Call hierarchy

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.

like image 101
Bananeweizen Avatar answered Oct 04 '22 01:10

Bananeweizen


  • Ctrl + Shift + G : Reference in workspace. It shows only references of selected class or method or variable in source code.
  • Ctrl + Alt + H : Call Hierarchy. It shows all hierarchy up to root class.
like image 42
Premraj Avatar answered Oct 04 '22 01:10

Premraj