简体   繁体   中英

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.

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.

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)
  2. Select the desired element (constructor, but also works for Lombok generated builder() method when @Builder is present).
  3. Invoke "Find usages" action (Alt + F7 on linux)

Not as easy as Find Usages, but you could use Structural Search for this. Use the button Copy existing template... and choose new expressions :

new $Constructor$($Argument$)

Edit variables to set the text/regexp of Constructor to your classname.

You can search for usages of the type (the class declaration). IDEA will display the usages grouped by usage type. There you will find "new instance creation".

This works for me with IDEA Ultimate 2016.3 and lombok plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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