英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论