Vscode-java: False positives problems (when using Lombok)

Created on 6 Mar 2018  Â·  5Comments  Â·  Source: redhat-developer/vscode-java

When using this plugin with a lombok-project the plugin determines many problems (e. g. for missing getters and setters) that disappear when the corresponding file is opened.

Environment
  • Operating System: macOS
  • JDK version: 1.8.0_102
  • Visual Studio Code version: 1.20.1
  • Java extension version: 0.20.0
Steps To Reproduce
  1. Configure lombok support for this plugin, as described here
  2. Open a project that uses lombok annotations like @Getter or @Data
Sample Project

Unfortunately, I cannot submit the affected project.
The important bits are:

<!-- pom.xml -->
<dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
</dependency>
// License.java
@Data
public class License {
    private String serial;
}
Java Language Server log
!SESSION 2018-03-06 07:59:11.945 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_102
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=de_DE
Command-line arguments:  -data /Users/oliverherrmann/Library/Application Support/Code/User/workspaceStorage/d8ec444f7205bbe5fb9c8b70109bb494/redhat.java/jdt_ws

!ENTRY org.eclipse.jdt.ls.core 1 0 2018-03-06 07:59:14.658
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started

!ENTRY org.eclipse.jdt.ls.core 1 0 2018-03-06 07:59:14.992
!MESSAGE Main thread is waiting


{ ... }


!ENTRY org.eclipse.jdt.ls.core 4 0 2018-03-06 08:00:20.767
!MESSAGE Error occured while building workspace. Details: 
message: The method getSerial() is undefined for the type License;code: 67108964
message: The method getExportChannels() is undefined for the type Project;code: 67108964
message: The method getEditions() is undefined for the type Project;code: 67108964
Current Result

A Problem “The method getSerial() is undefined for the type License“ is listed in the problems view. When opening the corresponding file by clicking on the entry the problem disappears after a few seconds.
This behavior is reproducable when restarting vs code.

Expected Result

No problem “The method getSerial() is undefined for the type License“ is listed in the problems view.

Lombok bug diagnostics

Most helpful comment

This bug is still happening, please see: Problems list still show errors of undefined for getters or setters. The issue opener resolved it doing this: https://github.com/GabrielBB/vscode-lombok/issues/13#issuecomment-440981551 , but that workaround doesn't work for others

All 5 comments

I can't reproduce the issue.
I have used the attached project and the following settings:

"java.jdt.ls.vmargs": "-javaagent:/home/snjeza/.m2/repository/org/projectlombok/lombok/1.16.20/lombok-1.16.20.jar -Xbootclasspath/a:/home/snjeza/.m2/repository/org/projectlombok/lombok/1.16.20/lombok-1.16.20.jar -noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication",

mytest.zip

This bug is still happening, please see: Problems list still show errors of undefined for getters or setters. The issue opener resolved it doing this: https://github.com/GabrielBB/vscode-lombok/issues/13#issuecomment-440981551 , but that workaround doesn't work for others

@GabrielBB could you attach a sample project?

Here's how I managed to solve the problem:

  1. Make sure everything else works:

    • I.e., even though the errors show up in the PROBLEMS list, once you navigate to the specific file, the errors for that file disappears.

    • You will likely need to install the Lombok Annotations Support for VSCode extension for this.

  2. Run Java: Clean the Java language server workspace from Command Palette.
  3. Run Java: Import Java projects in workspace from Command Palette.
  4. The problem is fixed (at least for me).

    • Do note however that you might still see a huge number of warnings / info messages.

I tried @YongJieYongJie 's solution but the problems appeared again as soon as I compiled the project using maven.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ulongx picture ulongx  Â·  4Comments

danielcalvogonzalez picture danielcalvogonzalez  Â·  3Comments

bilymed picture bilymed  Â·  3Comments

jcjolley picture jcjolley  Â·  3Comments

marlinla picture marlinla  Â·  3Comments