[英]How to find all usages of name() related to specific enum type
I need to find all usages of name()
method called on specific enum type. 我需要找到在特定枚举类型上调用的
name()
方法的所有用法。
Let's say I've got the enum: 假设我有枚举:
enum MyEnum {
A, B, C;
}
I want to receive all places where the method is called on any of MyEnum
element. 我想接收所有在
MyEnum
元素上调用该方法的所有位置。 It could be called on specific elements like A.name()
, B.name()
and so on, but as well it could be called on a parameter or a iterating variable, for example: 可以在诸如
A.name()
, B.name()
等特定元素上调用它,但是也可以在参数或迭代变量上调用它,例如:
String myMethod(MyEnum myEnum) {
return myEnum.name();
}
So far I could do it by pressing Alt + F7 on each element of MyEnum
and the enum type itself and then look for occurences containing name()
call in results. 到目前为止,我可以通过在
MyEnum
每个元素上按Alt + F7以及枚举类型本身来实现,然后在结果中查找包含name()
调用的出现。 But this require a lot of manual work. 但这需要大量的手工工作。
The other approach I've tried was to press Alt + F7 having cursor over method's name in statement like A.name()
but it found all occurences of name()
called on any enum type. 我尝试过的另一种方法是按Alt + F7 ,在
A.name()
类的语句A.name()
光标移到方法的名称上,但它发现在任何枚举类型上都出现过name()
。
So is it possible to do this easier and faster? 那么有可能更容易,更快地做到这一点吗?
In structural search (Edit > Find > Search structurally...), search for: 在结构搜索(编辑>查找>结构搜索...)中,搜索:
$e$.name()
then hit "Edit Variables...", select e
, and set the "Expression type (regexp)" to be the enum you are interested in. 然后点击“编辑变量...”,选择
e
,然后将“表达式类型(regexp)”设置为您感兴趣的枚举。
(Remember that any reference of type Enum<?>
could contain a reference to a MyEnum
, so you may need to consider looking for those also) (请记住,任何
Enum<?>
类型的引用都可能包含对MyEnum
的引用,因此您可能还需要考虑寻找那些引用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.