mplushnikov / lombok-intellij-plugin

Lombok Plugin for IntelliJ IDEA
Apache License 2.0
3.11k stars 635 forks source link

IDEA plugin not supporting @With annotation for Java 16 records #1065

Open dstibbe opened 3 years ago

dstibbe commented 3 years ago

Short description

I have a java16 record with an @With annotation. When trying to use any of the generated with...() methods, the plugin tells me they don't exist, even though it compiles just fine.

Expected behavior

The plugin should show me the withLength(...) method exists. Instead it tells me it doesn't.

Steps to reproduce

   @With
    record Rectangle2(int length, int width) {}

    var rect = new Rectangle(12, 16);
    var rect2 = rect.withLength(19);

It will indicate that withLength doesn't exist.

Sample project

see code above

Version information

Additional information

-

Stacktrace

-

manniar commented 2 years ago

Hi, my additional observations.

Source public record Foo(String name, @With int size) {} compiles, but IntelliJ IDE warns Wither needs constructor for all fields If I add @AllArgsConstructor, the warning is gone.

Nonetheless, IntelliJ IDE won't recognize the generated Foo.withSize(int size) method. Maven build succeeds without problems though.

Lombok version: 1.18.22 Platform: Corretto-17.0.2.8.1 (build 17.0.2+8-LTS) Plugin version: 213.6777.52

IMHO, @With annotation is a perfect companion for the Java record types - yet another example of lombok providing the essential missing piece of functionality that really should be part of Java language.