ContextMapper / vscode-extension

Context Mapper VSCode Extension
https://contextmapper.org/
Apache License 2.0
19 stars 2 forks source link

VSCode extension fails for valid CML file with `The resource 'file:///model.cml' does not contain a CML model.` #21

Closed tPl0ch closed 3 years ago

tPl0ch commented 3 years ago

Hi,

I am using VSCode with the ContextMapper extension on Ubuntu, and when using the Insurance example CML definitions the CML Language Server fails with the exception that the valid CML is not a valid CML model.

Exception

[Error - 11:53:37] Request textDocument/codeAction failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: org.contextmapper.dsl.cml.exception.ResourceIsNoCMLModelException: The resource 'file:///projects/sprk-contextmap/src/main/cml/model.cml' does not contain a CML model.
    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)
    at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:704)
    at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
    at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
    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:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.contextmapper.dsl.cml.exception.ResourceIsNoCMLModelException: The resource 'file:///home/tploch/projects/sprk-contextmap/src/main/cml/model.cml' does not contain a CML model.
    at org.contextmapper.dsl.cml.CMLResource.throwResourceIsNoCMLModelException(CMLResource.java:68)
    at org.contextmapper.dsl.cml.CMLResource.<init>(CMLResource.java:52)
    at org.contextmapper.dsl.ide.actions.CMLActionService.getCodeActions(CMLActionService.java:52)
    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$codeAction$37(LanguageServerImpl.java:786)
    at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438)
    at org.eclipse.xtext.ide.server.LanguageServerImpl.codeAction(LanguageServerImpl.java:777)
    at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$codeAction$36(LanguageServerImpl.java:763)
    at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66)
    ... 5 more

Java

$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

VS Code

Version: 1.57.1
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-17T13:26:56.255Z
Electron: 12.0.7
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Linux x64 5.10.0-1034-oem
stefan-ka commented 3 years ago

Hi @tPl0ch

Thanks for reporting your issue!

Unfortunately I cannot reproduce it; although I work with Ubuntu and Java 11 as well... Can you maybe share the content of your model.cml file? Because I don't know which example you mean (there is no model.cml here)... And which version of the Context Mapper extension do you use?

Just an assumption: Maybe you created an empty model.cml file first and then copy-pasted the content? Because it is a known-issue that the language server throws this exception in case you have an empty file (an empty file is not a valid CML model). In that case the exception could be ignored; as long it is not thrown again after pasting the model into the file.

Thanks and best regards, Stefan

tPl0ch commented 3 years ago

Hi @stefan-ka

Just an assumption: Maybe you created an empty model.cml file first and then copy-pasted the content? Because it is a known-issue that the language server throws this exception in case you have an empty file (an empty file is not a valid CML model). In that case the exception could be ignored; as long it is not thrown again after pasting the model into the file.

Yeah, somehow that was one of the issues. Another one was that I forgot to create the BoundedContext definitions before referencing them in the ContextMap block. So all works right now, closing this.

And congrats for this awesome library, it's really helpful.

stefan-ka commented 3 years ago

Thanks for the feedback @tPl0ch!