Lombok-intellij-plugin: @Builder not work with static import in Intellij 2016.2.4

Created on 26 Sep 2016  路  5Comments  路  Source: mplushnikov/lombok-intellij-plugin

I have an issue with static import mode with @Builder

import com.raimtec.milkyway.orch.mktfeed.EventType;
import java.util.ArrayList;
import java.util.Collection;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder(builderMethodName = "ibMarketFeedRequestBuilder")
@NoArgsConstructor
@AllArgsConstructor
public class IBMarketFeedRequest {

  private String contextId;

  private Collection<EventType> eventTypes = new ArrayList<>();

}

When I use static import like this :

import static com.raimtec.milkyway.orch.mktfeed.ib.IBMarketFeedRequest.ibMarketFeedRequestBuilder;

public class MyService  {
  public void serve() {
    IBMarketFeedRequest request = ibMarketFeedRequestBuilder().contextId(marketFeed.getId()).eventTypes(eventTypes).build();
  }
}

I get error below :

Error:(23, 1) java: cannot find symbol
  symbol:   static ibMarketFeedRequestBuilder
  location: class

If I use normal mode:

import com.raimtec.milkyway.orch.mktfeed.ib.IBMarketFeedRequest;

public class MyService  {
  public void serve() {
    IBMarketFeedRequest request = IBMarketFeedRequest.ibMarketFeedRequestBuilder().contextId(marketFeed.getId()).eventTypes(eventTypes).build();
  }
}

It works perfectly.

If I build the project in commandline without Intellij, it works too.

enhancement

Most helpful comment

Just letting you know that this is a feature I would very much like, would have saved me a few hours of debugging and head-scratching.

All 5 comments

+1 I have the exact same problem - it's weird.

Note that the problem isn't related to overriding the builder method name - it's just the static import that triggers this.

+1 I'm seeing this too. It's really hard to debug what the issue is when it happens as everything just breaks.

Still a bug in IntelliJ Lombok plugin 0.19-2018.1 using IntelliJ 2018.1.5

This error comes from javac, not IntelliJ.
Unfortunatly static import for BuilderClass is not possible with lombok: https://github.com/rzwitserloot/lombok/issues/2044

I can only think about adding some Inspection and generate IntelliJ-Warning in this situation.

Just letting you know that this is a feature I would very much like, would have saved me a few hours of debugging and head-scratching.

Was this page helpful?
0 / 5 - 0 ratings