Xcode 有代码导航功能吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/865415/
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-14 18:33:56  来源:igfitidea点击:

Does Xcode have code navigation feature?

xcode

提问by lucius

Does Xcode have a code navigation feature? Like unix's cscope type of tool which I can enter the name of a class and it will open the file for me? Or find out the caller of a particular method of a class? Or show the type hierarchy of a class?

Xcode 有代码导航功能吗?像 unix 的 cscope 类型的工具,我可以输入一个类的名称,它会为我打开文件吗?或者找出类的特定方法的调用者?或者显示一个类的类型层次结构?

回答by Marc W

command-shift-D(Xcode 4: command-shift-O) opens a Quick Open window where you can type a partial class name and hit enter to open the file. As far as more complex versions such as what Eclipse offers (method names, symbol names, etc), I don't believe anything like that is built into XCode.

command- shift- D(Xcode 4: command- shift- O) 打开一个快速打开窗口,您可以在其中输入部分类名并按回车键打开文件。至于更复杂的版本,例如 Eclipse 提供的版本(方法名称、符号名称等),我不相信 XCode 中内置了任何类似的东西。

回答by Lyndsey Ferguson

In addition to the Quick Open window, there is the class browser. The class browser allows you to view the class hierarchy. The Class Browser can be found under the Project menu.

除了快速打开窗口,还有类浏览器。类浏览器允许您查看类层次结构。可以在“项目”菜单下找到“类浏览器”。

回答by Corey Floyd

The "Jump To Definition" item is accessible through CMD + double click, which takes you directly to the relevant code

“跳转到定义”项可通过CMD+双击访问,直接跳转到相关代码

Also, you can "Jump To Documentation" by (Option or ALT) + double clicking on a class/method/property

此外,您可以通过(选项或ALT)+双击类/方法/属性来“跳转到文档”

Update: Option + double click no longer takes you directly to documentation in Snow Leopard. Now it opens up a little documentation "bubble", with the option to jump to the documentation browser if needed.

更新:Option + 双击不再将您直接带到 Snow Leopard 中的文档。现在它打开了一个小文档“气泡”,如果需要,可以选择跳转到文档浏览器。

回答by epatel

If you Ctrl click a class name, method name or function name you will get a long meny where you can find the Jump to Definitionitem.

如果您按住 Ctrl 单击一个类名、方法名或函数名,您将得到一个很长的菜单,您可以在其中找到跳转到定义项。

回答by pille

From XCode 4.4 upwards, you can find callers and callees by opening the "show related items" pop-up for a selected (highlighted) method:

从 XCode 4.4 起,您可以通过打开选定(突出显示)方法的“显示相关项目”弹出窗口来查找调用者和被调用者:

  1. Mark method in code (using your cursor or double click name)
  2. Press Ctrl+1
  3. Select "Callers" from the pop-up menu
  1. 在代码中标记方法(使用光标或双击名称)
  2. Ctrl+1
  3. 从弹出菜单中选择“来电者”

You can also go View->Standard Editor->show related items or press the tiny button just left of the arrow buttons in the line just above the editor window (where it shows your currently selected file and method).

您还可以转到“查看”->“标准编辑器”->“显示相关项目”或按下编辑器窗口正上方行中箭头按钮左侧的小按钮(显示当前选择的文件和方法)。

回答by cdespinosa

Also: select an identifier, right-click on it, and choose Find in Project > As Symbol (or Find in Project and choose Symbol as the search type) shows all symbolic uses, that is, declarations, definitions, and call sites.

另外:选择一个标识符,右键单击它,然后选择 Find in Project > As Symbol(或 Find in Project 并选择 Symbol 作为搜索类型)显示所有符号用途,即声明、定义和调用点。

回答by liuyang

There should opens up something like an element preview window or bubble when the user point to a method or item. The "Jump to Definition" change the users focus and take 2 steps to go to the target.

当用户指向一个方法或项目时,应该会打开一个元素预览窗口或气泡之类的东西。“跳转到定义”改变了用户的注意力,分两步到达目标。

The relation window and context window in Source Insight is a good example,but I can't find them in Xcode and other dev tools for the mac.

Source Insight 中的关系窗口和上下文窗口就是一个很好的例子,但我在 Xcode 和其他 mac 开发工具中找不到它们。

By the way,the context window should have multiple layers to trace a deep referenced method like the split window in Xcode, not only one layer in the source insight.

顺便说一句,上下文窗口应该有多个层来跟踪像Xcode中的拆分窗口这样的深度引用方法,而不仅仅是源洞察中的一层。