microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
298 stars 129 forks source link

Error when parsing code when lombok is used #1725

Closed gayanper closed 2 months ago

gayanper commented 2 months ago
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 java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    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.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:186)
    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.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:860)
    at org.eclipse.jdt.internal.core.hierarchy.RegionBasedHierarchyBuilder.createTypeHierarchyBasedOnRegion(RegionBasedHierarchyBuilder.java:86)
    at org.eclipse.jdt.internal.core.hierarchy.RegionBasedHierarchyBuilder.build(RegionBasedHierarchyBuilder.java:55)
    at org.eclipse.jdt.internal.core.hierarchy.RegionBasedTypeHierarchy.compute(RegionBasedTypeHierarchy.java:78)
    at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1281)
    at org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:94)
    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.core.JavaCore.newTypeHierarchy(JavaCore.java:5276)
    at org.eclipse.jdt.internal.junit.launcher.JUnit5TestFinder.findTestsInContainer(JUnit5TestFinder.java:216)
    at com.microsoft.java.test.plugin.searcher.JUnit5TestSearcher.findTestItemsInContainer(JUnit5TestSearcher.java:130)
    at com.microsoft.java.test.plugin.util.TestSearchUtils.findTestPackagesAndTypes(TestSearchUtils.java:168)
    at com.microsoft.java.test.plugin.handler.TestDelegateCommandHandler.executeCommand(TestDelegateCommandHandler.java:61)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:606)
    at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:690)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:527)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)
jdneo commented 2 months ago

How does the code look like in your case?

We delegate the test item search to upstream:

org.eclipse.jdt.internal.junit.launcher.JUnit5TestFinder.findTestsInContainer(JUnit5TestFinder.java:216)
gayanper commented 2 months ago

@jdneo This seems to be a issue with Lombok library, I have reported a issue to both Lombok and JDTLS to handle it. SO closing this.