Lombok-intellij-plugin: Add support for @SuperBuilder

Created on 30 Jul 2018  路  70Comments  路  Source: mplushnikov/lombok-intellij-plugin

Short description

Please add support for @SuperBuilder annotation. It's a long-awaited feature and now, with Lombok 1.18.2, it has been released.

Expected behavior

Support for @SuperBuilder annotation

Version information

  • IDEA Version: 2018.1
  • JDK Version: JDK8
  • OS Type & Version: Windows 10 Pro
  • Lombok Plugin Version: 0.19
  • Lombok Dependency Version: 1.18.2

Steps to reproduce

Add Lombok 1.18.2 to the project

enhancement Generics

Most helpful comment

Would love to see this

All 70 comments

Would love to see this

I was ecstatic when @SuperBuilder was released, but it's largely unusable without IDE integration.

This would be very helpful for us.

I'd be glad to help contribute this, but I'd probably need some direction as I've never made an IntelliJ plugin. @mplushnikov are you or anyone else aware of anyone else working on this?

i can help on that, but need a piece of explanation where to start.

Is this being worked on by anyone? Or do we have to wait for the annotation to make it out of experimental?

@sluongng I don't believe so. If you're familiar with the IntelliJ plugin ecosystem, I say go for it.

I had started to very briefly during my company's hackathon but switched gears early on as I realized I have a lot more to grok looking at the existing Builder code in the plugin as an example.

Support for @SuperBuilder please!

My team also need @SuperBuilder Support

Yes please support for @SuperBuilder please! My team also uses it!

+1

+1 !

+1

+1

+2 (from paired programmers at major enterprise)

+10086

We are eagerly waiting for support of superbuilder

You are more than welcome to contribute with a PR for this

+1

hope it will be implemented soon

@alexejk
I think nobody here is able to provide a PR without help of the maintainers/collaborators.
Here are people willing to contribute. But they need help.
See https://github.com/mplushnikov/lombok-intellij-plugin/issues/513#issuecomment-417105785 and https://github.com/mplushnikov/lombok-intellij-plugin/issues/513#issuecomment-420594061

i will check on weekend

Yes that would be awesome as now in a professional environment creating test data for the models is a pain using just the @Builder because most probably these models extend from a superclass.

+1

+1

+1

My team also need @SuperBuilder Support

+1

+1

+1

Looked on this feature now. It's quite complex and will need some deeper rework of current Builder implementation. Solution will take some time.

+1

+1

+1

+1

This would be great! Without the lombok plugin, lombok is quite useless for us :)

+1

+1

+1

+1

+1

+1

+1

+1

+1

I think its fair to say that along with many other people this is my biggest issue, so would be wonderful to have super builders working in the plugin. Pretty please!

+1

馃憤 Yes please

馃憤馃徎

@mplushnikov what do you think of locking this thread to maintainers only? I'd like to track this issue for genuine updates but I also don't want to see a bunch of +1 and :+1: comments.

I encourage folks to use the built-in GitHub reactions on the issue description to express your desire for this feature. :smile:

This feature is already on my todo-list, more +1 comments doesn't make it faster :-)

Hello guys,
implementation of SuperBuilder makes a big step forward. :wink:

If you want, you can try current alpha build (only for IntelliJ 2019.2+) here: https://github.com/mplushnikov/lombok-intellij-plugin/releases/tag/0.27_superbuilder_alpha

Feel free to share you experience and comment any problems with it. :fire:

nice, long-awaited 馃憤

perfect

yeah :thumbsup:

Works for me, great job !

can't wait to see it in stable version

Works like a charm! Thanks a lot!!

But (I think the same belongs to @Builder too)

@Data
@SuperBuilder
public class Foo {
    private int x;
    private int y;
}

produces this outline/structure

image

As you can see: There is the default-constructor shown.
Also you can type Foo foo = new Foo(); in IDE without error, because IDE thinks there is the default-constructor.
But starting the compiler you see the truth

error: constructor Foo in class Foo cannot be applied to given types;
        final Foo foo = new Foo();
                        ^
  required: FooBuilder<?,?>
  found: no arguments
  reason: actual and formal argument lists differ in length

@octopus-prime Good catch, will look on it!

Thanks锛宨t's prefect.

Hey guys, when will the new release come?

Hey guys, when will the new release come?

https://github.com/mplushnikov/lombok-intellij-plugin/releases/tag/0.27_superbuilder_alpha

Hi, I tried to install plug in but I got error: "Plugin 'Lombok' is incompatible with this installation"
My Idead version is: 2019.1.1 (Build #IU-191.6707.61)

Hey guys, when will the new release come?

https://github.com/mplushnikov/lombok-intellij-plugin/releases/tag/0.27_superbuilder_alpha

Hi, I tried to install plug in but I got error: "Plugin 'Lombok' is incompatible with this installation"
My Idead version is: 2019.1.1 (Build #IU-191.6707.61)

it's only supported by IntelliJ 2019.2+

hi,
i used the lombok-plugin-0.27.0-2019.2 for @SuperBuilder annotation and i have the following structure:

@SuperBuilder
public class A {
public field1;
}

@SuperBuilder
public class B extends A {
public field2;
}

now, i'm trying to use the builder of class A in a scenario like this:

return someOptional
    .map(item -> A.builder().field1(value).build())
    .orElseGet(() -> A.builder().field1(otherClass.method(something)).build());

the error i get is:
Error:(102, 201) java: incompatible types: bad return type in lambda expression
capture#1 of ? cannot be converted to capture#2 of ?
and appears on the line of orElseGet

can you please help me with this?

Version information:
IntellijIdea: IntelliJ IDEA 2019.2.3 (Ultimate Edition) Build #IU-192.6817.14, built on September 24, 2019
Runtime version: 11.0.4+10-b304.69 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

@cosmin-rezmerita Interesting usecase! I think you can't use a lambda expression for a functional interface, if the method in the functional interface has type parameters. See section 搂15.27.3 in JLS8: https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.27.3

But your code should compile if your add explicit cast to the map method: (.map(item -> (A) A.builder().field1(value).build())).

@mplushnikov thank you! explicit cast works fine.
is it something like: using builder in .map does not return a "clear" object type, so .orElseGet does not know what to expect? Because using classic constructors also works:

return someOptional
    .map(item -> new A())
    .orElseGet(() -> A.builder().field1(otherClass.method(something)).build()

@cosmin-rezmerita Yes, you are right. Using Builders-methods in the map-method returns generic wildcard type like ABuilder and the right type cann't be automatically calculated. If you cast it/or use just constructor, its clear for the comiler, which type shlould be used.

Thank you so much @mplushnikov

Hi
@mplushnikov Will @SuperBuilder is having support in xjc- lombok plugin ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dodalovic picture dodalovic  路  3Comments

bestitxq picture bestitxq  路  5Comments

wellhor picture wellhor  路  6Comments

pedegie picture pedegie  路  4Comments

Viking1726 picture Viking1726  路  4Comments