finos / rune-dsl

The project containing the Rune DSL grammar and default code generators
Apache License 2.0
26 stars 30 forks source link

Long if-then-else statement crashes language server #669

Open SimonCockx opened 1 year ago

SimonCockx commented 1 year ago

A long if-then-else expression can results in a null pointer in the generated ANTRL parser, which causes the language server to crash.

Stacktrace:

java.util.concurrent.CompletionException: java.lang.NullPointerException: parseResult is null
    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:332)
    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:347)
    at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:708)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
    at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
    at org.eclipse.xtext.ide.server.concurrent.AbstractRequest.logAndCompleteExceptionally(AbstractRequest.java:73)
    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:69)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NullPointerException: parseResult is null
    at org.eclipse.xtext.ide.editor.contentassist.antlr.ContentAssistContextFactory.create(ContentAssistContextFactory.java:130)
    at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createProposals(ContentAssistService.java:104)
    at org.eclipse.xtext.ide.server.contentassist.ContentAssistService.createCompletionList(ContentAssistService.java:78)
    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$23(LanguageServerImpl.java:554)
    at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438)
    at org.eclipse.xtext.ide.server.LanguageServerImpl.completion(LanguageServerImpl.java:553)
    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$completion$22(LanguageServerImpl.java:539)
    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66)

Reproduce: create an if-then-else expression having 30+ branches.

SimonCockx commented 1 year ago

Related: https://www.eclipse.org/forums/index.php/m/1861451/

SimonCockx commented 1 year ago

Potential solutions:

SimonCockx commented 1 year ago

Since https://github.com/REGnosys/rosetta-dsl/pull/671, the language server will fail more gracefully by giving back a diagnostic to the user.