使用交叉引用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
借助交叉引用,您可以探索代码库中符号之间的关联。
如果已配置,则交叉引用由 kythe 提供。如需确定特定代码库是否已配置交叉引用,请查看项目页面上的“交叉引用”列。如果显示对勾标记,则表示相应代码库中至少有一种语言存在交叉引用。请注意,并非所有带对勾标记的代码库都具有相同语言集的交叉引用。
跳转到定义
如果启用了交叉引用,符号会变成链接。点击符号用法会跳转到代码中定义该符号的位置。如需了解如何为可点击的符号启用下划线,请参阅交叉引用设置。
查找用法并使用交叉引用面板
点击定义符号的位置,即可打开交叉引用面板,其中会显示使用该符号的位置列表。点击引用会通过打开预览面板或在主窗口中显示用法来跳转到相应用法。如需了解如何切换此行为,请参阅交叉引用设置。当点击交叉引用面板中的链接时,代码浏览器会跳转到构建交叉引用的文件版本。
使用调用层次结构
借助交叉引用面板的调用层次结构部分,您可以探索引用的上下文。在调用层次结构部分中,点击行号旁边的下拉箭头可显示相应引用的调用方。这样,您就可以向上探索调用层次结构。
查看生成的文件
在具有交叉引用的代码库中,您可以看到 build 生成的但代码库中不存在的制品;例如,从 proto 文件创建的 .cc
和 .h
文件。下载的某些文件(作为 build 流程的一部分)也会显示。
交叉引用面板中的某些链接会将您带到生成的文件中。您可以通过目录面板视图前往这些生成的文件。
交叉引用设置
您可以切换交叉引用预览窗口。当预览面板处于开启状态时,在交叉引用面板中点击会打开一个预览,显示在交叉引用面板旁边。当预览面板处于关闭状态时,在交叉引用面板中点击会打开主代码窗口中的引用。
您还可以开启或关闭交叉引用下划线。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eCross-references allow exploring connections between symbols, letting you jump to definitions and find usages.\u003c/p\u003e\n"],["\u003cp\u003eClicking a symbol usage navigates to its definition, while clicking a definition opens a panel showing all usages.\u003c/p\u003e\n"],["\u003cp\u003eThe call hierarchy feature enables exploring the context of references by showing the caller of a specific line.\u003c/p\u003e\n"],["\u003cp\u003eGenerated files, such as those created from proto files, are visible and navigable through cross-references.\u003c/p\u003e\n"],["\u003cp\u003eCustomize your experience by toggling the cross-reference preview window and underlining of clickable symbols.\u003c/p\u003e\n"]]],[],null,["# Working with cross-references\n\nCross-references allow you to explore connections between symbols in the code\nbase.\n\nWhere configured, cross references are supplied by [kythe](https://kythe.io). To\ndetermine if a particular repository has cross references configured, look at the\ncross-references column on the project page. If there is a checkmark, there are\ncross-references for at least one language in that repository. Note that not all\nrepositories with checkmarks have cross-references for the same set of\nlanguages.\n\nJumping to a definition\n-----------------------\n\nWhere cross-references are enabled, symbols become links. Clicking a symbol\nusage navigates to the place in the code where the symbol is\ndefined. See [Cross-reference settings](#cross-reference_settings) for\ninformation on enabling underlining for clickable symbols.\n\nFinding usages and using the cross-references panel\n---------------------------------------------------\n\nClicking the place where a symbol is defined opens the cross-reference panel\nthat shows you a list of places where the symbol is used. Clicking a\nreference jumps to that usage by opening a preview panel or by showing the usage\nin the main window. See [Cross-reference settings](#cross-reference_settings)\nfor information on toggling this behavior. When a link in the\ncross-reference panel is clicked, the code browser jumps to the version of the\nfile at which cross-references were built.\n\nUsing the call hierarchy\n------------------------\n\nThe call hierarchy section of the cross reference panel allows you to explore\nthe context of references. In the call hierarchy section, clicking the twistie\nnext to the line number shows you the caller of that reference. This allows you\nto explore the call hierarchy upward.\n\nViewing generated files\n-----------------------\n\nIn repositories with cross-references, you can see artifacts generated from the\nbuild that are not present in the repository; for example, `.cc` and `.h`\nfiles created from proto files. Some files downloaded as part of the build\nprocess are also visible.\n\nSome links from the cross-references panel take you into generated files. You\ncan navigate to these generated files from the directory panel view.\n\nCross-reference settings\n------------------------\n\nYou can toggle the cross-references preview window. When the preview panel is\non, clicking in the cross-reference panel opens a preview of the file next to\nthe cross reference panel. When the preview panel is off, clicking in the\ncross-reference panel opens the reference in the main code window.\n\nYou can also turn underlining of cross references on and off."]]