在IntelliJ中搜索特定类层次结构中的类的文本。

huangapple go评论56阅读模式
英文:

Search text of classes in a specific class hierarchy in IntelliJ

问题

有一个抽象类,有数百个子类、孙子类等。我需要在其中任何提到像

somethingNaughty.do()

这样的字符串的子类中添加一小段代码。是否有一种方法可以执行类似于“在路径中查找”的搜索,但限定在特定的类层次结构中?

英文:

I have an abstract class that has hundreds of children, grandchildren, etc. I need to add a snippet to any of those children that mention a string such as

somethingNaughty.do()

Is there a way to perform a search like "Find in Path", but restricted to a specific class hierarchy?

答案1

得分: 2

如果您将所有这些类放在同一个包中,您可以在项目层次结构中选择该包,然后按Ctrl + Shift + F,这样您就只在该包中搜索。

如果您的类分散在不同地方,我认为Intellij不允许进行这种类型的搜索。您可以尝试进行正则表达式搜索,假设您可以找到层次结构成员之间的模式。

我建议查阅Idea的文档以获取潜在的想法。


稍后编辑

可以通过Class Hierarchy预定义范围来实现,当使用Ctrl + Shift + F进行搜索时可用。

英文:

Assuming you have all these classes in the same package, you can select that package in Project Hierarchy, then press Ctrl + Shift + F so that you search only in that package.

If your classes are spread, I don't think Intellij allows that type of search. You can try to go for a regex search, assuming you can find a pattern between the members of the hierarchy.

I suggest digging through Idea's documentation for potential ideas.


Later edit

It is doable via the Class Hierarchy predefined scope, available when searching via Ctrl + Shift + F .

huangapple
  • 本文由 发表于 2020年8月1日 05:33:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/63199348.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定