Mike Sweeney
Mike Sweeney

Reputation: 2046

View lombok generated code in IntelliJ IDEA

I have the lombok plugin setup in IntelliJ and my code builds fine. I can see the lombok generated methods in the structure view. What I want is some way to actually see the source lombok generates for each of the methods. I realize I can delombok the file but I'm wondering if there is some way I can flip a switch to show or hide the lombok generated code.

Upvotes: 102

Views: 67658

Answers (6)

r-uu
r-uu

Reputation: 635

I had various undesirable effects with delombok. Therefore, here is an alternative with Intellij on-board tools:

First: Make sure that the target folder is not among the excluded folders of your project (you can check that at "Project Structure (F4) / Project Settings / Modules").

With the lombok annotated type highlighted you can press shift twice to open the search all dialog. The according .class resource should now appear under the items in the search result list. If you select that item a tab opens with the decompiled code.

In both cases it is mandatory of course, that lombok generation (for example with maven) took place beforehand.

Upvotes: 0

Ahmed Nabil
Ahmed Nabil

Reputation: 18986

You can use "Delombok" IntelliJ plugin.

After installing it, given any Java file which contains Lombok annotations:

  • Right click
  • Select Refactor
  • Select Delombok
  • Select any Delombok option as you want

Sample:

enter image description here

Upvotes: 0

jjd
jjd

Reputation: 2288

With the Lombok plugin (starting with v0.8.6), "Lombok" and "Delombok" menu items are available in the "Refactor" menu.

IDEA screenshot showing the Lombok & Delombok menu items

Upvotes: 119

Rajesh Kolappakam
Rajesh Kolappakam

Reputation: 2125

Lombok comes with a 'delombok' feature that can be used as follows:

java -jar lombok.jar delombok -p MyJavaFile.java

Upvotes: 17

Joseph Cass
Joseph Cass

Reputation: 149

For anyone who arrived here looking for a "delombok" shortcut, one can be created here:

enter image description here

Upvotes: 1

Vasily Pudikov
Vasily Pudikov

Reputation: 261

Find generated class in folder target/././classname.class and open it in IntelliJ IDEA.

Upvotes: 26

Related Questions