简体   繁体   English

在Intellij中查找lombok生成的构造函数的用法

[英]Find usages of lombok generated constructor in Intellij

I have a class with lombok annotation (either @Value or @Data ) and I am looking for an easy way to find usages of the auto generated constructor. 我有一个带有@Value注释的类( @Value@Data ),我正在寻找一种简单的方法来查找自动生成的构造函数的用法。

What I can do now is to find a one use of the constructor, put the cursor there and run 'Find usages' command and I get the results I want. 我现在可以做的是找到构造函数的一个用途,将光标放在那里并运行'Find usages'命令,我得到我想要的结果。

However I would like to do this directly from the class declaration. 但是我想直接从类声明中做到这一点。 Is there a way to do that? 有没有办法做到这一点?

I have finally found an acceptable solution to this: 我终于找到了一个可接受的解决方案:

  1. Anywhere in the file invoke "File structure" action (Ctrl + F12 on linux) 文件中的任何位置调用“文件结构”操作(Linux上的Ctrl + F12)
  2. Select the desired element (constructor, but also works for Lombok generated builder() method when @Builder is present). 选择所需的元素(构造函数,但当@Builder存在时,也适用于Lombok生成的builder()方法)。
  3. Invoke "Find usages" action (Alt + F7 on linux) 调用“查找用法”操作(Linux上的Alt + F7)

Not as easy as Find Usages, but you could use Structural Search for this. 不像查找用法那么容易,但您可以使用结构搜索。 Use the button Copy existing template... and choose new expressions : 使用Copy existing template...按钮Copy existing template...并选择new expressions

new $Constructor$($Argument$)

Edit variables to set the text/regexp of Constructor to your classname. 编辑变量以将Constructor的text / regexp设置为您的类名。

You can search for usages of the type (the class declaration). 您可以搜索类型的用法(类声明)。 IDEA will display the usages grouped by usage type. IDEA将显示按使用类型分组的用法。 There you will find "new instance creation". 在那里你会发现“新实例创建”。

This works for me with IDEA Ultimate 2016.3 and lombok plugin. 这适用于IDEA Ultimate 2016.3和lombok插件。

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

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