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

Enable javac-based compilation #3558

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Conversation

fbricon
Copy link
Collaborator

@fbricon fbricon commented Apr 3, 2024

Requires building eclipse.jdt.ls against dom-with-javac branch of the JDT fork
Requires running with Java 23 at the moment.

First build the server jars with:

npm run build-server

then generate the vsix with:

npx @vscode/vsce package

Enable with "java.jdt.ls.javac.enabled":"on" in vscode settings

You can enable the more experimental DOM-based completion with "java.completion.engine": "dom":

Screenshot 2024-07-10 at 13 35 03

@fbricon
Copy link
Collaborator Author

fbricon commented May 1, 2024

Daily vscode-javac builds are available from https://github.com/fbricon/vscode-java/releases/tag/javac-prototype

src/requirements.ts Outdated Show resolved Hide resolved
src/javaServerStarter.ts Outdated Show resolved Hide resolved
src/settings.ts Outdated Show resolved Hide resolved
@fbricon fbricon changed the title WIP: enable javac-based compilation Enable javac-based compilation Oct 14, 2024
@fbricon fbricon marked this pull request as ready for review October 14, 2024 17:28
package.json Show resolved Hide resolved
@rgrunber rgrunber added this to the End October 2024 milestone Oct 16, 2024
@rgrunber rgrunber merged commit 0f89a67 into redhat-developer:master Oct 16, 2024
2 checks passed
@viswatejan
Copy link

I wanted to try Javac and DOM but I was getting the following error.

!ENTRY org.eclipse.jdt.core 4 0 2024-11-05 13:28:32.326
!MESSAGE Internal failure while parsing or converting AST for unit /helloworld-service/src/main/java/com/hello/HelloWorld.java

!ENTRY org.eclipse.jdt.core 4 0 2024-11-05 13:28:32.333
!MESSAGE startPos = -1 and length is 3.
This breaks the rule that length must be 0 if startPosition is negative. Affected Node:
class org.eclipse.jdt.core.dom.SimpleName: com
!STACK 0
java.lang.IllegalArgumentException: startPos = -1 and length is 3.
This breaks the rule that length must be 0 if startPosition is negative. Affected Node:
class org.eclipse.jdt.core.dom.SimpleName: com
	at lombok.eclipse.agent.PatchDiagnostics.setSourceRangeCheck(PatchDiagnostics.java:43)
	at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java)
	at org.eclipse.jdt.core.dom.JavacConverter.convertToType(JavacConverter.java:2880)
	at org.eclipse.jdt.core.dom.JavacConverter.convertToType(JavacConverter.java:2898)
	at org.eclipse.jdt.core.dom.JavacConverter.convertToType(JavacConverter.java:2898)
	at org.eclipse.jdt.core.dom.JavacConverter.convertToType(JavacConverter.java:2898)
	at org.eclipse.jdt.core.dom.JavacConverter.convertToType(JavacConverter.java:2898)
	at org.eclipse.jdt.core.dom.JavacConverter.convertStatement(JavacConverter.java:2373)
	at org.eclipse.jdt.core.dom.JavacConverter.convertBlock(JavacConverter.java:2716)
	at org.eclipse.jdt.core.dom.JavacConverter.convertMethodDecl(JavacConverter.java:995)
	at org.eclipse.jdt.core.dom.JavacConverter.convertBodyDeclaration(JavacConverter.java:773)
	at org.eclipse.jdt.core.dom.JavacConverter.convertClassDecl(JavacConverter.java:625)
	at org.eclipse.jdt.core.dom.JavacConverter.convertClassDecl(JavacConverter.java:545)
	at org.eclipse.jdt.core.dom.JavacConverter.convertBodyDeclaration(JavacConverter.java:776)
	at org.eclipse.jdt.core.dom.JavacConverter.lambda$populateCompilationUnit$2(JavacConverter.java:196)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:636)
	at org.eclipse.jdt.core.dom.JavacConverter.populateCompilationUnit(JavacConverter.java:198)
	at org.eclipse.jdt.core.dom.JavacCompilationUnitResolver.parse(JavacCompilationUnitResolver.java:722)
	at org.eclipse.jdt.core.dom.JavacCompilationUnitResolver.toCompilationUnit(JavacCompilationUnitResolver.java:537)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTCached(ASTParser.java:1299)
	at org.eclipse.jdt.core.dom.ASTParser.lambda$1(ASTParser.java:1178)
	at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles(JavaModelManager.java:5692)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1178)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:918)
	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:184)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:246)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:569)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:292)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:278)
	at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:276)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.findElementsAtSelection(JDTUtils.java:1059)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.findElementAtSelection(JDTUtils.java:1045)
	at org.eclipse.jdt.ls.core.internal.handlers.NavigateToDefinitionHandler.computeDefinitionNavigation(NavigateToDefinitionHandler.java:83)
	at org.eclipse.jdt.ls.core.internal.handlers.NavigateToDefinitionHandler.definition(NavigateToDefinitionHandler.java:73)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$7(JDTLanguageServer.java:681)
	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)

Is this feature available to try or do we need to wait for some future vscode-java releases with right eclipse JDT core?

@snjeza
Copy link
Contributor

snjeza commented Nov 5, 2024

@viswatejan Could you attach a project example reproducing the error?

@viswatejan
Copy link

@snjeza , I could not reproduce the same issue with a sample project but I see some other issues related to the autocompletion with the eclipse lombok agent.

Delomboking and removing the Lombok dependency in my project loaded the project fine in the Java Project Explorer.

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

Successfully merging this pull request may close these issues.

5 participants