Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Load external metamodel for LSP using gradle(Language Server Protocol(LSP) with different grammar than Hello World)
Load external metamodel for LSP using gradle [message #1784468] Wed, 28 March 2018 06:09 Go to next message
Eclipse UserFriend
Hello, everyone.
This is my first post here.

I have a registered metamodel project located in a workspace root folder.
I am trying to generate an LSP with Xtext 2.13.
I have selected the following configuration :
1. Xtext Project from Existing ecore models.
2. I then select the root element of the metamodel.
3. Preffered build system: Gradle
4. Build Language Server: Regular
5. Source layout: Plain.

In the parent folder of my lsp I have included the model project like this:
include 'projectName'
project(':projectName').projectDir = new File('../projectName')

I have also added compile project(':projectA') to the project containing my mw2 file.

The metamodel project has been converted to a gradle project by right clicking on it and then configure gradle project.
I also added a build.gradle which looks like this
dependencies {
compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.10.1'
compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.common', version: '2.10.1'
}

I am able to build an LSP server. Nevertheless, when I connect it to VsCode I get parseError and when I run the tests for my LSP i also get

org.eclipse.xtext.parser.ParseException: java.lang.IllegalStateException: Unresolved proxy (url here) . Make sure the EPackage has been registered.
at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:105)
at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.parse(AbstractAntlrParser.java:84)
at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:62)
at org.eclipse.xtext.parser.AbstractParser.parse(AbstractParser.java:33)
at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:176)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:100)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.xtext.testing.util.ResourceHelper.resource(ResourceHelper.java:56)
at org.eclipse.xtext.testing.util.ParseHelper.parse(ParseHelper.java:41)
at org.eclipse.xtext.testing.util.ParseHelper.parse(ParseHelper.java:51)
at org.eclipse.xtext.testing.util.ParseHelper.parse(ParseHelper.java:47)
at org.xtext.example.mydsl.tests.AcidParsingTest.loadModel(AcidParsingTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.eclipse.xtext.testing.XtextRunner$1.evaluate(XtextRunner.java:49)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.IllegalStateException: Unresolved proxy (url here). Make sure the EPackage has been registered.
at org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser.parse(AbstractInternalAntlrParser.java:579)
at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:102)
... 35 more
Caused by: java.lang.IllegalStateException: Unresolved proxy (URL HERE). Make sure the EPackage has been registered.
at org.eclipse.xtext.parser.DefaultEcoreElementFactory.create(DefaultEcoreElementFactory.java:58)
at org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser.forceCreateModelElement(AbstractInternalAntlrParser.java:684)
at org.xtext.example.mydsl.parser.antlr.internal.InternalAcidParser.ruleVersion(InternalAcidParser.java:1015)
at org.xtext.example.mydsl.parser.antlr.internal.InternalAcidParser.ruleWorld(InternalAcidParser.java:165)
at org.xtext.example.mydsl.parser.antlr.internal.InternalAcidParser.entryRuleWorld(InternalAcidParser.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser.parse(AbstractInternalAntlrParser.java:556)
... 36 more


My question is HOW DO I PROPERLY include a metamodel in my project using Gradle, because right now I have the feeling that it is not working correctly.

Thank you for reading this long post.
Re: Load external metamodel for LSP using gradle [message #1784480 is a reply to message #1784468] Wed, 28 March 2018 09:40 Go to previous messageGo to next message
Eclipse UserFriend
how do you put the existing metamodel project on the classpath?
is the model packaged into the jar?
how do you reference it from the workflow?

(see e.g. https://github.com/cdietrich/xtext-existing-metamodel-gradle-example - very old example)
Re: Load external metamodel for LSP using gradle [message #1784481 is a reply to message #1784480] Wed, 28 March 2018 09:52 Go to previous messageGo to next message
Eclipse UserFriend
I don't know how to put the model into a jar using gradle.

I have not prepackaged the model into a jar. It is just referring to the project in gradle.
The output in the lib folder does contain my model.

In the workflow the metamodel is referenced like this:
referencedResource = "platform:/resource/project folder/model/xxx.genmodel"
Re: Load external metamodel for LSP using gradle [message #1784483 is a reply to message #1784481] Wed, 28 March 2018 10:33 Go to previous messageGo to next message
Eclipse UserFriend
my example does exactly that ?!?
Re: Load external metamodel for LSP using gradle [message #1784498 is a reply to message #1784468] Wed, 28 March 2018 13:28 Go to previous messageGo to next message
Eclipse UserFriend
I will try it out now.
Will post the latest results if it works.
Re: Load external metamodel for LSP using gradle [message #1784513 is a reply to message #1784498] Wed, 28 March 2018 16:38 Go to previous messageGo to next message
Eclipse UserFriend
I tried it and it did not work. The error is the easiest to see when you run the jettyRun task and open the LSP in a browser. I press ctrl + space, i get the first autosuggestion.
and then when I fill in something it crashes.
[pool-2-thread-1] ERROR server.model.XtextWebDocumentAccess - Error during background work.
org.eclipse.xtext.parser.ParseException: java.lang.IllegalStateException: Unresolved proxy http://www.example.org/emf#//Questionaire. Make sure the EPackage has been registered.

I have attached the project. You will just need to change the settings.gradle in the parent to point to your directory.
Please help I have been stuck on this for week and a half.
https://ottko.stackstorage.com/s/pcurKR2DnD9m3N5
Re: Load external metamodel for LSP using gradle [message #1784517 is a reply to message #1784513] Wed, 28 March 2018 16:57 Go to previous messageGo to next message
Eclipse UserFriend
Are you talking about the workflow are are you talking about runtime
Before you were talking about workflow
For runtime you need to adapt standalonesetup and make surr
The epackage are registered (have a look at generated standalone setup for inspiration)
Re: Load external metamodel for LSP using gradle [message #1784542 is a reply to message #1784517] Thu, 29 March 2018 03:53 Go to previous messageGo to next message
Eclipse UserFriend
The error occurs when I run gradle test.

The EPackage has been registered by right clicking on the ecore and register EPackage.

I have also read https://wiki.eclipse.org/EMF/FAQ.

How should I change the StandaloneSetup?
At this point in time, it is the one that is generated from Xtext project from existing ecore model.
Re: Load external metamodel for LSP using gradle [message #1784544 is a reply to message #1784542] Thu, 29 March 2018 03:54 Go to previous messageGo to next message
Eclipse UserFriend
did you have a look at my example?
https://github.com/cdietrich/xtext-existing-metamodel-gradle-example/blob/master/org.xtext.example.mydsl/src/org/xtext/example/mydsl/MyDslStandaloneSetup.xtend

[Updated on: Thu, 29 March 2018 04:02] by Moderator

Re: Load external metamodel for LSP using gradle [message #1784546 is a reply to message #1784544] Thu, 29 March 2018 04:20 Go to previous messageGo to next message
Eclipse UserFriend
I do not know how did I miss that. I just checked the mw2 and .xtext,
I will do it now and check again. I really hope that it works.
Re: Load external metamodel for LSP using gradle [message #1784549 is a reply to message #1784544] Thu, 29 March 2018 04:49 Go to previous message
Eclipse UserFriend
It works.
Thank you so much!
Previous Topic:Xtext grammar which do not generate an EMF java interface
Next Topic:Linking in external file
Goto Forum:
  


Current Time: Fri Jun 20 19:43:57 EDT 2025

Powered by FUDForum. Page generated in 0.52432 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top