vscode-lombok
vscode-lombok copied to clipboard
Errors in workspace until opening all source files with lombok annotations
Opening a project that has several files using lombok annotations will result in many errors displayed in the "Problems" tab. Clicking on one of the errors, which opens the file will resolve the errors for that file. Once each file with lombok annotations was opened, the "Problems" tab does not show errors anymore. Unfortunately, closing VC Code and reopening the project brings all errors back.
I'm experiencing the same issue. I wonder if there would be a way to load lombok extension before the redhat.java extension.
Perhaps something like this could help: https://github.com/Microsoft/vscode/issues/46846
Having the same issue. When will it be resolved?
Which Java version are you using? It happens using Maven or Gradle?
I'm using java version "1.8.0_212" and Gradle 5.4.1.
openjdk version "12.0.1" 2019-04-16 OpenJDK Runtime Environment (build 12.0.1+12) OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing) Maven
Also happening for me with
openjdk version "12.0.1" 2019-04-16 OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.1+12) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.1+12, mixed mode, sharing)
Using Maven
On Windows 10
This may be a solution: https://github.com/redhat-developer/vscode-java/wiki/Lombok-support
At least for me, adding "-Xbootclasspath/a:/path/to/lombok.jar" to the java.jdt.ls.vmargs made VSCode properly load everything.
Adding -Xbootclasspath/a:/path/to/lombok.jar did not fix this issue for me. I still have to open each source file to get the errors to disappear.
For large projects with many classes, this makes vscode practically unusable for me.
Adding
-Xbootclasspath/a:/path/to/lombok.jardid not fix this issue for me. I still have to open each source file to get the errors to disappear.For large projects with many classes, this makes vscode practically unusable for me.
It‘s same to me.I added -Xbootclasspath/a:/path/to/lombok.jar to the java.jdt.ls.vmargs in the setting file,but it didn't work properly for the opened project while VSCode was reloaded.
The solution is removing the .vscode folder for me.Hope to help you.
Thank you @GKilm, your suggestion to delete the .vscode folder worked like a charm!
Similar:
$ ./gradlew -version
------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------
Build time: 2019-01-10 23:05:02 UTC
Revision: 3c9abb645fb83932c44e8610642393ad62116807
Kotlin DSL: 1.1.1
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_202 (Oracle Corporation 25.202-b08)
OS: Mac OS X 10.14.6 x86_64
Adding -Xbootclasspath/a:/path/to/lombok.jar didn't work for me either and strangely, I have no .vscode directory in my project.
Same issue here. For me the solution was to save the open folder as new workspace. It worked for one project only. After re- opening the workspace it start showing the errors again.
It seems like that three projects has loading in my workspace before installing the Lombok plugin. I remove it and add it back again, this problem is vanished.
Please make sure you’re using the latest version of Lombok in your Pom or gradle file to avoid conflicts with the plugin
I had this problem too, all the Java files using Lombok used to give the same error (i.e. The method setXXX is undefined for the type YYY). I never had a .vscode folder in my project.
This may be a solution: https://github.com/redhat-developer/vscode-java/wiki/Lombok-support
At least for me, adding "-Xbootclasspath/a:/path/to/lombok.jar" to the java.jdt.ls.vmargs made VSCode properly load everything.
This fixed it - I'll leave my specs below anyway so that anyone can try to replicate the environment and see if it works out for them too.
Beware that -Xbootclasspath/a:/path/to/lombok.jar has to be escaped with \" like -Xbootclasspath\"/a:/path/to/lombok.jar\" otherwise it wont' work (it can be pretty obvious but I spent some time figuring this out).
EDIT: I noticed that placing the -Xbootclasspath flag made VS Code not work properly on other java projects in other directories as well, being unable to show compiler errors and even unable to run due to a Could not find or load main class exception. I did not manage to find a workaround for this problem yet; in fact, if the flag -Xbootclasspath/a:/path/to/lombok.jar is present in the VS Code settings other projects won't work. It's quite annoying to have to insert and remove that line while working on different projects. I always used Java: clean the language server workspace every time I closed/opened VS Code.
@GabrielBB maybe you could export -Xbootclasspath\"/a:/path/to/lombok.jar\" as a default option in the plugin? Pointing at -Xbootclasspath\"/a:/home/USER/.vscode/extensions/gabrielbb.vscode-lombok-1.0.1/server/lombok.jar\"
Lombok version in build.gradle: org.projectlombok:lombok:1.18.12
Gradle wrapper version:
$ ./gradlew --version
------------------------------------------------------------
Gradle 6.3-rc-4
------------------------------------------------------------
Build time: 2020-03-20 05:39:45 UTC
Revision: 507eaa2e999827ec256a700ffc413c5e92a9e69d
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 13.0.2 (Oracle Corporation 13.0.2+8)
OS: Linux 5.3.0-42-generic amd64
Based on @GKilm suggestion to delete the .vscode folder, which I think don't exists anymore, I deleted all VS Code generated folders and files:
- .settings/
- .classpath
- .factorypath
- .project
After that I opened VS Code and the lombok issues where gone. Then I closed and opened again 5x times to make sure, and the issue didn't come back.
Based on @GKilm suggestion to delete the
.vscodefolder, which I think don't exists anymore, I deleted all VS Code generated folders and files:
- .settings/
- .classpath
- .factorypath
- .project
After that I opened VS Code and the lombok issues where gone. Then I closed and opened again 5x times to make sure, and the issue didn't come back.
This works just great for me!
Based on @GKilm suggestion to delete the
.vscodefolder, which I think don't exists anymore, I deleted all VS Code generated folders and files:* .settings/ * .classpath * .factorypath * .projectAfter that I opened VS Code and the lombok issues where gone. Then I closed and opened again 5x times to make sure, and the issue didn't come back.
I tried this but as soon as I compiled the project using maven, the lombok errors were back.
It's been almost a year, no fix yet? What I have to do every time I compile the project is to go to the pom.xml file and remove the scope from the lombok dependency, save the file, add the scope again. The errors disappear. This is a very hacky solution and we shouldn't have to mess around to get it to work.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>compile</scope> <-- I remove the "compile", save the file, add it again
</dependency>