简体   繁体   English

如何在RubyMine中查找自定义方法?

[英]How do I lookup custom methods in RubyMine?

If there is a method like def cookie_monster somewhere in the project and I'm in a file which is using cookie_monster , how do I quickly find the file and line where cookie_monster is defined? 如果项目中某处有类似def cookie_monster的方法,并且我在使用cookie_monster的文件中,如何快速查找定义cookie_monster的文件和行?

I saw " Navigate Code, Not Text: How to Navigate Effectively in RubyMine " from PivotalLabs which says I can use command + option/alt + O but perhaps my key mappings are different (default RubyMine 6). 我从PivotalLabs看到了“ 导航代码,而不是文本:如何在RubyMine中有效地导航 ”,它说我可以使用command + option/alt + O但是也许我的键映射是不同的(默认RubyMine 6)。 That does nothing for me. 那对我没有任何帮助。

Select the word. 选择单词。

Edit -> Find -> Find Usages

or 要么

Edit -> Find -> Find in Path

For keyboard shortcut, use the one against the menu. 对于键盘快捷键,请使用菜单上的快捷键。

Well I see you got your answer, but that isn't really the best solution, rubymine already caches all the function names and index it to find it fast without doing a search, try this method instead, it should be faster 好吧,我知道您有答案,但这并不是最好的解决方案,rubymine已经缓存了所有函数名称并对其进行索引以快速找到它而不进行搜索,而尝试使用此方法,它应该更快

Navigate -> Symbol

You'll get a small popup search bar, as soon as you write cook you should probably find your function in an auto complete, depending on your layout settings you'll find a nice shortcut to open it. 您会看到一个小的弹出式搜索栏,当您编写cook您可能应该在自动完成功能中找到您的功能,具体取决于您的布局设置,您会找到一个很好的快捷方式来打开它。

As a plus there's also 另外,还有

Navigate -> File

I never search for a file on the side bar to navigate, use this, it's always faster and will list all files with auto complete 我从不在侧栏上搜索文件来导航,使用它,它总是更快,并且会列出所有文件并自动完成

The normal find function mentioned is used when you're trying to find a normal line of code, not a name of a function or a file. 当您尝试查找正常的代码行而不是函数或文件的名称时,将使用提到的普通查找功能。

Note that in both these popups you don't need to write the full name, for example to open the cookie_monster function, you can search for it as this comon ( co for cookie, and mon for monster ) you'll find it fun and very fast. 请注意,在这两个弹出窗口,你不需要写全名,例如打开cookie_monster功能,您可以搜索它,因为这comonco为饼干,和mon的怪物),你会发现它的趣味性和非常快。

As for the find usages it's common usage for me is to find where a certain partial is called, or a certain function is used. 至于find usages ,对我来说,最常见的用法是查找某个部分调用的位置或某个函数的使用位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM