调用层次结构和查找引用 eclipse 之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14019906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:29:12  来源:igfitidea点击:

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

eclipseeclipse-plugin

提问by kannanrbk

I got confused when using this two commands in eclipseCtrl+Shift+Gand Ctrl+Alt+Hboth are returning same results .

在使用此两个命令时,我糊涂了eclipseCtrl+ Shift+GCtrl+ Alt+H两者都返回相同的结果。

Scenario:

场景

Want to find where the method "findUsage" has been called.

想找到方法“ findUsage”被调用的地方。

Sample Class

样本类

enter image description here

在此处输入图片说明

Call Hierarchy Output (Ctrl+Alt+H).

调用层次输出(Ctrl+ Alt+ H

enter image description here

在此处输入图片说明

Find References (Ctrl+Shift+G) output

查找引用(Ctrl+ Shift+ G)输出

enter image description here

在此处输入图片说明

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

两者都显示相同的结果。谁能知道这两个命令有什么区别?

回答by Bananeweizen

"Find references" shows you all direct callersof 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.

如果您想知道为什么有两个这样的功能,如果“查找引用”基本上只是“调用层次结构”的一个子集:查找引用的工作速度非常快,因此您可以一直使用它而无需等待结果。另一方面,调用层次结构需要更多的计算时间,因此可能会中断您的编码工作流程。

回答by Premraj

  • Ctrl+ Shift+ G: Reference in workspace. It shows only referencesof selected class or method or variable in source code.
  • Ctrl+ Alt+ H: Call Hierarchy. It shows all hierarchyup to root class.
  • Ctrl+ Shift+G:工作区中的参考。它仅显示源代码中所选类或方法或变量的引用
  • Ctrl+ Alt+H:呼叫^ hierarchy。它显示了直到根类的所有层次结构