Lombok-intellij-plugin: Does not support @Builder.Default in Lombok 1.16.16

Created on 5 Apr 2017  路  33Comments  路  Source: mplushnikov/lombok-intellij-plugin

Field(s) annotated with @Builder.Default won't show up in Code Completion dropdown.

enhancement

Most helpful comment

It appears that this only happens (for me) when the property being annotated is explicitly marked as final.

/* this works */
@Builder.Default() String foo = ""

/* this builder method won't be visible in the dropdown */
@Builder.Default() final String foo = ""

All 33 comments

+1

+1

+1

+1. Also, getters and setters created this way cannot be resolved.

+1. We would love to use this feature.

+1. The tests run successfully. But it is bit annoying to look at the red lines in Intellij. And it also masks any other errors that may be present after the line where it cannot recognize the field.

+1

If you can point to where this change might need to happen, I'd be willing to do the work but looking at the code I can't make heads or tails of why this doesn't work out of the box

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

Hi all, please note that spamming +1 does not help anyone. If you want to be a watcher either just select "Watch" or use the reaction on the original issue to show your support / request for this issue, like many others did.

As this is a voluntary project - it may take a looong time until we find time to look into issues, unless we face them ourselves and are blocked by it in our day-to-day work.

@AlexejK if you would be willing to provide some guidance on how the plugin works I'd be more than happy to try and tackle this issue. I took a look at the code but can't make heads or tails how this plugin does its work.

Does this issue only occur when attempting to use the annotation specifically as @Builder.Default?

It seems to work ok for me when I import like
import lombok.Builder.Default;

autocomplete and no error

IntelliJ isn't particularly happy when I try to use @Builder.Default directly

Builder.Default

Though it does seem ok with using the full @lombok.Builder.Default

lombok.Builder.Default

EDIT: Better examples

It appears that this only happens (for me) when the property being annotated is explicitly marked as final.

/* this works */
@Builder.Default() String foo = ""

/* this builder method won't be visible in the dropdown */
@Builder.Default() final String foo = ""

+1

One way to reproduce (and work-around) this issue using Lombok 1.16.18 and intellij 2017.2.

Start with this with everything imported:

@Value
@Builder
public class LombokTest {
  @NonNull
  String value;
}

Add your builder default value:

  @Builder.Default
  String value = "foo";

The builder setter for value isn't created (the value(String) method actually dissapears from the builder as soon as = "foo"; is added):
screen shot 2017-08-28 at 11 52 31 am

If I comment out @Value the builder value(String) method appears immediately:
screen shot 2017-08-28 at 11 54 07 am

Finally, re-enabling @Value leaves the builder working as expected, but there are no getters created for the main value class. If you replace @Value with @Getter it now sort of works.

Are there any plans to fix it?

Most likely yes, when we have time to look into it.
Feel free to create a PR if you are in a hurry :)

Just going to +1 this :)

I and a colleague were having an issue with this, so we wrote a PR: https://github.com/mplushnikov/lombok-intellij-plugin/pull/452. Please have a look and merge.

Oops, did not test it with older versions of Intellij. I'll commit a fix

Fixed. All tests pass now

When can we expect this fix to be released? This problem is really annoying. The only w/a right now is not to use final together with @Builder.Default, but dropping immutability where it's required is fundamentally a bad idea.

+1
This is the first time I will have to download Eclipse in over 2 years because this is unsupported in a package I am working with.

Was this page helpful?
0 / 5 - 0 ratings