microsoft / vscode-lombok

Lombok Annotations Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=GabrielBB.vscode-lombok
MIT License
87 stars 20 forks source link

Symbols not getting resolved for lombok on vs code #72

Open smadll opened 2 years ago

smadll commented 2 years ago

I'm using OSS version 1.66.0 of vs code. My vscode-lombok extension version is 1.0.1. My jdk is OpenJDK 11. I'm getting a whole bunch of errors like

The method builder() is undefined for the type MyClass
log cannot be resolved

My vs code config is

{
    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m"
}

So far, I tried cleaning workspace cache, clean java language server workspace, deleting the workspaceStorae folder from .config. None of them helped.

uvwxy commented 2 years ago

@smadll I had the same issue until I manually added the value

-javaagent:\"/Users/paul/.vscode-server/extensions/gabrielbb.vscode-lombok-1.0.1/server/lombok.jar\" (make sure to adapt for your system!)

at the end of "java.jdt.ls.vmargs" inside ./vscode/settings.json.

If I remember correctly the language server went into an Out Of Memory exception and I agreed to increasing the memory. I assume this has removed the respective setting to make the plugin work.

smadll commented 2 years ago

@uvwxy Thanks for the tip. I used a similar work around. I gave the path to my lombok jar directly instead of the extension's. Since it's not working, didn't see a point in keeping it.

jarcand commented 2 years ago

This worked for me too, thanks @uvwxy !

abnayak commented 2 years ago

I've the right javaagent set in my VS code and still symbols are not getting resolved. Any idea?

ProfeJulianLasso commented 2 years ago

I solved it by uninstalling this extension georgewfraser.vscode-javac

sdtorresl commented 2 years ago

I solved it by uninstalling this extension georgewfraser.vscode-javac

Thank you so much, this worked for me

dinhphu28 commented 2 years ago

I solved it by uninstalling this extension georgewfraser.vscode-javac

Thank you so much

blizzy78 commented 2 years ago

I don't have extension georgewfraser.vscode-javac installed (never had), and it still does not resolve Lombok annotations for me.

Edit: In my project, I had used an older Lombok version (1.16.x). After updating the pom.xml to the latest version, I got a prompt to reload the VS Code window, which I accepted. After that, the issue had resolved itself.

mykas3trade commented 1 year ago

I solved it by uninstalling this extension georgewfraser.vscode-javac

solved mine. thanks

tsumirai commented 11 months ago

I solved it by uninstalling this extension georgewfraser.vscode-javac

I can't believe it! But it works. I have spent one day to solve this problem. Thank you very much!

smil2k commented 3 months ago

For me the exception was thrown by lombok. (Look for the warning icon in the status bar: image).

Clicking on "open logs..." showed that it was a lombok error with one particular class:

!ENTRY org.eclipse.jdt.core 4 0 2024-08-21 11:08:27.826
!MESSAGE Lombok annotation handler class lombok.eclipse.handlers.HandleConstructor$HandleAllArgsConstructor failed
!STACK 0
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "compilationUnit" is null
    at lombok.eclipse.handlers.EclipseHandlerUtil.setDocComment(EclipseHandlerUtil.java:2841)
    at lombok.eclipse.handlers.EclipseHandlerUtil.setDocComment(EclipseHandlerUtil.java:2830)
    at lombok.eclipse.handlers.HandleConstructor.generateConstructorJavadoc(HandleConstructor.java:609)
    at lombok.eclipse.handlers.HandleConstructor.generate(HandleConstructor.java:290)
    at lombok.eclipse.handlers.HandleConstructor.generateConstructor(HandleConstructor.java:246)
    at lombok.eclipse.handlers.HandleConstructor$HandleAllArgsConstructor.handle(HandleConstructor.java:165)
    at lombok.eclipse.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:106)
    at lombok.eclipse.HandlerLibrary.handleAnnotation(HandlerLibrary.java:237)
    at lombok.eclipse.TransformEclipseAST$AnnotationVisitor.visitAnnotationOnType(TransformEclipseAST.java:269)
    at lombok.eclipse.EclipseNode.traverse(EclipseNode.java:107)
    at lombok.eclipse.EclipseAST.traverseChildren(EclipseAST.java:231)
    at lombok.eclipse.EclipseNode.traverse(EclipseNode.java:74)
    at lombok.eclipse.EclipseAST.traverseChildren(EclipseAST.java:231)
    at lombok.eclipse.EclipseNode.traverse(EclipseNode.java:69)
    at lombok.eclipse.EclipseAST.traverse(EclipseAST.java:224)
    at lombok.eclipse.TransformEclipseAST.go(TransformEclipseAST.java:226)
    at lombok.eclipse.TransformEclipseAST.transform(TransformEclipseAST.java:187)
    at lombok.eclipse.TransformEclipseAST.transform_swapped(TransformEclipseAST.java:104)
    at jdk.internal.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at lombok.launch.PatchFixesHider$Util.invokeMethod(PatchFixesHider.java:146)
    at lombok.launch.PatchFixesHider$Transform.transform_swapped(PatchFixesHider.java:272)
    at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:11512)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12712)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12942)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12899)
    at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11283)
    at org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:152)
    at org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.buildCompilationUnit(SourceTypeConverter.java:99)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.accept(CompilationUnitProblemFinder.java:123)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:384)
    at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:276)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:624)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleImport(CompilationUnitScope.java:696)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInImports(CompilationUnitScope.java:523)
    at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:598)
    at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1081)
    at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1130)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:280)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:346)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:186)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:92)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:739)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:804)
    at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1303)
    at org.eclipse.jdt.ls.core.internal.handlers.BaseDocumentLifeCycleHandler.publishDiagnostics(BaseDocumentLifeCycleHandler.java:332)
    at org.eclipse.jdt.ls.core.internal.handlers.BaseDocumentLifeCycleHandler.publishDiagnostics(BaseDocumentLifeCycleHandler.java:295)
    at org.eclipse.jdt.ls.core.internal.handlers.BaseDocumentLifeCycleHandler$PublishDiagnosticJob.run(BaseDocumentLifeCycleHandler.java:777)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

After changing the @Value to @Getter and @AllArgsConstructor (for @Builder) the problem resolved.

Link to the lombok issue: https://github.com/projectlombok/lombok/issues/3706