Search for usages查找用法
With the Find Usages actions you can search for the references of your code element throughout the whole codebase.使用“查找用法”操作,您可以在整个代码库中搜索代码元素的引用。
You can manage the search process, and search only in a single file, extend your search to the whole project, or create a certain search scope. 您可以管理搜索过程,只在单个文件中搜索,将搜索扩展到整个项目,或创建特定的搜索范围。Moreover, you can configure the color of the usages highlighting or disable the automatic highlighting of usages altogether.此外,您可以配置用法高亮显示的颜色,或者完全禁用用法的自动高亮显示。

Search for usages in a file在文件中搜索用法
-
In the editor, select a symbol you want to find, WebStorm automatically highlights all found usages in the file.在编辑器中,选择要查找的符号,WebStorm会自动高亮显示文件中找到的所有用法。To turn this highlighting off, open the Settings/Preferences dialog Ctrl+Alt+S, go to , and clear the Highlight usages of element at caret checkbox.要关闭此高亮显示,请打开“设置/首选项”对话框Ctrl+Alt+S,转到“编辑器”|“常规”,然后清除“在插入符号处高亮显示元素用法”复选框。When automatic highlighting is disabled, press Ctrl+Shift+F7 to highlight all usages of a symbol at caret within the file.禁用自动高亮显示后,按Ctrl+Shift+F7高亮显示文件中插入符号的所有用法。 -
From the main menu, select从主菜单中,选择“编辑”|“查找用法”|“在文件中查找用法”Ctrl+F7。 Ctrl+F7.WebStorm selects the first usage occurrence in the file.WebStorm选择文件中的第一个用法。
Use the F3 and Shift+F3 shortcuts to navigate between highlighted symbols.使用F3和Shift+F3快捷键在高亮显示的符号之间导航。
Search for usages in a project搜索项目中的用法
-
Select a symbol for which you want to find usages, right-click the symbol, and select选择要查找其用法的符号,右键单击该符号,然后从其关联菜单中选择“查找用法”,或按Alt+F7。 from its context menu or press Alt+F7. -
Check the results in the Find tool window.在“查找”工具窗口中检查结果。If you need, you can group (如果需要,可以按文件、包、目录等对结果进行分组() the results by files, packages, directories, and so on.
)。
To open the Find Usages dialog, click要打开“查找用法”对话框,请单击“查找”工具窗口中的工具栏上的on the toolbar in the Find tool window or press Ctrl+Alt+Shift+F7.
或按Ctrl+Alt+Shift+F7。
While in the Find tool window, you can also use the Preview area to check the places where the usages were found, to see a call hierarchy for methods, data flow for fields, and so on.在“查找”工具窗口中,还可以使用预览区域检查找到用法的位置,查看方法的调用层次结构、字段的数据流等。You can use the Find Usages action as an alternative to the Call Hierarchy actions.您可以使用查找用法操作作为调用层次结构操作的替代方法。
Show usages in a separate window在单独的窗口中显示用法
You can view usages of the selected symbol in a separate window that you can move to different parts of your screen and use for quick navigation.您可以在一个单独的窗口中查看所选符号的用法,该窗口可以移动到屏幕的不同部分并用于快速导航。
-
In the editor, select a symbol for which you want to see the usages.在编辑器中,选择要查看其用法的符号。 -
From the main menu, select从主菜单中,选择“编辑”|“查找用法”|“显示用法”Ctrl+Alt+F7。 Ctrl+Alt+F7.Click单击to move the search results to the Find tool window.
以将搜索结果移动到“查找”工具窗口。
The usages window shows the current scope and total count of usages.“用法”窗口显示当前范围和使用总数。If you want to quickly switch to the default scope, press Ctrl+Alt+F7.如果要快速切换到默认范围,请按Ctrl+Alt+F7。If the search results have too many entries, then WebStorm shows the first hundred usages found and the more usages option on the bottom of the window which you can click to display another hundred usages, and so on until the search is finished.如果搜索结果有太多的条目,那么WebStorm会在窗口底部显示找到的前一百个用法和“更多用法”选项,您可以单击该选项显示另外一百个用法,依此类推,直到搜索完成。Use filters on the top of the window to show or hide the certain search entries.使用窗口顶部的过滤器显示或隐藏某些搜索条目。
View results of recent searches for usages查看最近使用情况的搜索结果
WebStorm remembers your Find Usages results, so you don't need to run the action again.WebStorm会记住您的“查找用法”结果,因此无需再次运行该操作。
-
From the main menu, select从主菜单中,选择“编辑”|“查找”|“最近查找用法”,然后选择用法查询。 and then select the usage query.
Manage the Find Usages scope管理“查找用法”范围
-
If WebStorm doesn't find any usages of a symbol, it displays a message.如果WebStorm找不到符号的任何用法,它会显示一条消息。Click单击or press Ctrl+Alt+Shift+F7 to open the Find Usages dialog and set a new scope for your search, for example, Open Files or Project Test Files.
或按Ctrl+Alt+Shift+F7打开“查找用法”对话框,并为搜索(例如“打开文件”或“项目测试文件”)设置新范围。
To set a custom scope, click要设置自定义“范围”,请单击.
。
When you are done setting a new scope, click Find.设置完新范围后,单击“查找”。
Disable automatic highlighting of usages禁用用法的自动突出显示
When you place the caret at a symbol, the IDE highlights all usages of this symbol in the current file. 在符号处放置插入符号时,IDE将突出显示当前文件中该符号的所有用法。Use the F3 and Shift+F3 shortcuts to navigate between highlighted symbols.使用F3和Shift+F3快捷键在高亮显示的符号之间导航。
-
To disable automatic highlighting, open the Settings/Preferences dialog Ctrl+Alt+S, go to , and clear the Highlight usages of element at caret checkbox.要禁用自动高亮显示,请打开“设置/首选项”对话框Ctrl+Alt+S,转到“编辑器”|“常规”,然后清除“高亮显示插入符号处元素的用法”复选框。
When automatic highlighting is disabled, place the caret at the necessary symbol and press Ctrl+Shift+F7. 禁用自动高亮显示后,将插入符号放置在必要的符号处,然后按Ctrl+Shift+F7。This will highlight all usages of the symbol in the current file.这将突出显示当前文件中符号的所有用法。
Change the background color of the highlighted usages更改突出显示的用法的背景色
-
In the Settings/Preferences dialog Ctrl+Alt+S, go to .在“设置/首选项”对话框Ctrl+Alt+S中,转到“编辑器”|“配色方案”|“常规”。 -
From the options on the right, open the Identifier under caret.从右侧的选项中,打开“代码”节点并选择“插入符号下的标识符”。 node and select -
In the Background field, specify the color you need and save the changes.在“背景”字段中,指定所需的颜色并保存更改。
Search for the base method or method's implementations搜索基本方法或方法的实现
When you search for usages of a method, WebStorm prompts you to choose whether you want to search for the base method or method's implementations.当您搜索方法的用法时,WebStorm会提示您选择是要搜索基本方法还是方法的实现。
If you select the Remember, don't ask again checkbox, WebStorm will no longer display the prompt, and the selected search option will be used as default. 如果选中“记住,不再询问”复选框,WebStorm将不再显示提示,所选搜索选项将用作默认选项。If necessary, you can restore the prompt.如有必要,可以恢复提示。
-
In the Settings/Preferences dialog Ctrl+Alt+S, go to .在“设置/首选项”对话框中,按Ctrl+Alt+S键,转到“编辑器”|“常规”|“智能键”。 -
In the PHP area, select the Show additional options when searching for method usages checkbox.在“PHP”区域中,选中“搜索方法用法时显示其他选项”复选框。