Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Required steps to create Language Server with Maven(How to create a language server with Maven and integrate it to VS Code)
Required steps to create Language Server with Maven [message #1839033] Thu, 11 March 2021 15:41 Go to next message
Bilal Bas is currently offline Bilal BasFriend
Messages: 5
Registered: March 2021
Junior Member
Hi everyone,

I'm trying to create a language server with Xtext for VS Code. For that, I followed this tutorial (https://www.eclipse.org/Xtext/documentation/340_lsp_support.html).
When creating a file in eclipse, the language server works but I don't get code completion. Is there anything I have to do to enable code completion?
But now to my actual question: When creating the project, I selected everything as shown in the tutorial. I wrote a simple grammar (even tried the grammar in the tutorials) and generated the Xtext artifacts. But after that, what are the necessary steps in order to successfully get the jar file that I can use for the VS Code extension. I'm not that familiar with Eclipse and Java. Maybe I'm missing something obvious?

Any help would be appreciated.
Thanks in advance.
Re: Required steps to create Language Server with Maven [message #1839042 is a reply to message #1839033] Thu, 11 March 2021 16:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
for eclipse

may sure you define the content type correct (file extension with *, basetype text)
that you open the file with generic editor (maybe have a validation to make sure it works in general)

for vscode: check out this example with gradle and xtext 2.24 on this branch
https://github.com/itemis/xtext-languageserver-example/tree/cd_224wip

there is a vscode-extension-self-contained
which you should be able to adapt to your dsl

you can copy the server there,
and adapt the extension.ts and
build the extensin with npm and vsce


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 11 March 2021 16:36]

Report message to a moderator

Re: Required steps to create Language Server with Maven [message #1839079 is a reply to message #1839042] Fri, 12 March 2021 14:19 Go to previous messageGo to next message
Bilal Bas is currently offline Bilal BasFriend
Messages: 5
Registered: March 2021
Junior Member
Thank you for your quick reply. By copying the server, do you mean the jar files into src/mydsl/lib? I created the jar files by selecting "Run As Maven Install" in the .parent project.
Re: Required steps to create Language Server with Maven [message #1839084 is a reply to message #1839079] Fri, 12 March 2021 16:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
copy it in a way so that it can be executed by the extension. where exactly depends e.g if you choose fat jar or not etc.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Required steps to create Language Server with Maven [message #1839086 is a reply to message #1839084] Fri, 12 March 2021 16:46 Go to previous messageGo to next message
Bilal Bas is currently offline Bilal BasFriend
Messages: 5
Registered: March 2021
Junior Member
Okay got it. Thank you very much :)
Re: Required steps to create Language Server with Maven [message #1839275 is a reply to message #1839033] Thu, 18 March 2021 14:53 Go to previous messageGo to next message
Bilal Bas is currently offline Bilal BasFriend
Messages: 5
Registered: March 2021
Junior Member
Hi again,

I still have some issues running my language server.
First of all I would like to describe my steps:
1. Create new Xtext Project with following options:
- Project name, Language and Extension with default values
- Java Version: JavaSE-11
2. Select Generic IDE Support with:
- Preferred Build System: Maven
- Build Language Server: FatJar
- Source Layout: Plain
3. Create Project
4. Right click on org.xtext.example.mydsl.parent and select "Run As: Maven install"
5. Create a VS Code Extension with this extension.ts file (https://github.com/itemis/xtext-languageserver-example/blob/cd_224wip/vscode-extension-self-contained/src/extension.ts)
6. Remove the disposable2 part
7. Copy the generated file "org.xtext.example.mydsl.ide-1.0.0-SNAPSHOT-ls.jar" into src/bin
8. Inside src/bin create a file "mydsl-standalone" with following content (java -jar org.xtext.example.mydsl.ide-1.0.0-SNAPSHOT-ls.jar) and "mydsl-standalone.bat" with (java -jar %~dp0\org.xtext.example.mydsl.ide-1.0.0-SNAPSHOT-ls.jar) (Got those from here: https://github.com/alexandrelombard/sarl-vscode/tree/master/src/sarl/bin)

Now when I run the extension, I get following error message:
Exception in thread "main"
Exception: com.google.inject.internal.util.$ComputationException thrown from the UncaughtExceptionHandler in thread "main"
[Info - 15:52:20] Connection to server got closed. Server will restart.

Am I missing something?
Re: Required steps to create Language Server with Maven [message #1839288 is a reply to message #1839275] Thu, 18 March 2021 18:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
in fear you have to remote debug the server.
likely some guice error#
does it work when you call the java command on command line?
which java version is the java command you call?
which xtext version do you use?
did you deselect "eclipse" in the wizard?
how does the META-INF services folder in your jar look like. what is the content of the ISetup file there?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 18 March 2021 19:50]

Report message to a moderator

Re: Required steps to create Language Server with Maven [message #1839289 is a reply to message #1839288] Thu, 18 March 2021 18:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
can you also provide your ls jar somewhere?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Required steps to create Language Server with Maven [message #1839311 is a reply to message #1839289] Fri, 19 March 2021 08:26 Go to previous messageGo to next message
Bilal Bas is currently offline Bilal BasFriend
Messages: 5
Registered: March 2021
Junior Member

  • No when I call it in the command line I get the same error message
  • When I type java -version I get this:

    • java version "1.8.0_171"
    • Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
    • Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)



  • My Xtext version: 2.254.0
  • Yes I deselected Eclipse in the wizard
  • The contents of my ISetup file:
    org.xtext.example.mydsl.ide.MyDslIdeSetup

  • Jar file is attached

Re: Required steps to create Language Server with Maven [message #1839323 is a reply to message #1839311] Fri, 19 March 2021 10:13 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
if you have java 11 in the code you should also use it to run.

running with java 8 gives me the same error as you have
with java 11 no issue


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Where is cardinality stored in the ecore model?
Next Topic:String without double quotes
Goto Forum:
  


Current Time: Thu Jul 29 18:55:00 GMT 2021

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

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

Back to the top