Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives problems (when using Lombok) #458

Closed
herrmanno opened this issue Mar 6, 2018 · 12 comments
Closed

False positives problems (when using Lombok) #458

herrmanno opened this issue Mar 6, 2018 · 12 comments

Comments

@herrmanno
Copy link

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.

@fbricon fbricon added the bug label Mar 12, 2018
@fbricon fbricon changed the title False positives rPoblems (when using Lombok) False positives problems (when using Lombok) Mar 12, 2018
@snjeza
Copy link
Contributor

snjeza commented Apr 16, 2018

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

@GabrielBB
Copy link
Contributor

GabrielBB commented Dec 12, 2018

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: microsoft/vscode-lombok#13 (comment) , but that workaround doesn't work for others

@snjeza
Copy link
Contributor

snjeza commented Dec 12, 2018

@GabrielBB could you attach a sample project?

@YongJieYongJie
Copy link

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.

@EuniceB
Copy link

EuniceB commented Oct 14, 2020

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

@Koishilll
Copy link

Maybe the extension Lombok Annotations Support for VS Code can help.

@EuniceB
Copy link

EuniceB commented Jul 21, 2021

@Koishilll unfortunately that project seems to be inactive for a while, see here

@gandhiprachi
Copy link

I saw this issue too, but this goes away if i downgrade vscode-java plugin to 0.79.2

@monaka
Copy link

monaka commented Dec 25, 2021

Just in my case, the issue was fixed by adding <java.version>11</java.version> to pom.xml.
No vmargs setting required.

<properties>
  <java.version>11</java.version>
</properties>

It looks vscode-java generates configs for Java8 and recent versions of jars expect newer Javas.
I'm not familiar with Java build tools except Maven. But I guess there are a each way to set the version of Java.

My env is java-0.82.0-369.vsix on Theia in Eclipse/Che.


update: vmargs is required. No code completion for setter/getter without vmargs.
The part of settings.json in my Theia is: "java.jdt.ls.vmargs": "-javaagent:/lombok.jar", (it must be same as in VSCode).

@jkone27
Copy link

jkone27 commented Nov 22, 2022

Screenshot 2022-11-22 at 10 00 46

the preview gets it right, it seems java extension is not reading java version from my pom.xml file?

@jdneo
Copy link
Collaborator

jdneo commented Feb 10, 2023

Lombok is supported now. Check https://github.com/redhat-developer/vscode-java/wiki/Lombok-support

@jdneo jdneo closed this as completed Feb 10, 2023
@jkone27
Copy link

jkone27 commented Feb 15, 2023

i opened it in nov 2022, lombok support was from july 2022 so i suspect it was already there at the time of this, i will try reload the app to see if the problem persist after updating all...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests