Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Java LSP client for Xtext Language Server?
Java LSP client for Xtext Language Server? [message #1836723] Tue, 12 January 2021 21:54 Go to next message
M D is currently offline M DFriend
Messages: 5
Registered: January 2021
Junior Member
Hi,

I'm trying to build my own sort of editor and use it with the Xtext language server. The LSP client must be in Java. I've created a jar with the Xtext language server following this link (https://www.eclipse.org/community/eclipse_newsletter/2017/may/article5.php). The problem is, I have no idea of how to build the LSP client to connect to the server.

All examples I have found are for IDEs where a plugin / extension uses the jar. But I haven't been able to find something in just Java. I've looked at LSP4J which I know Xtext also uses for the server, but again haven't found anything.

Any solutions or ideas of how to get the client connecting to the server?

Thanks.

[Updated on: Tue, 12 January 2021 22:45]

Report message to a moderator

Re: Java LSP client for Xtext Language Server? [message #1836730 is a reply to message #1836723] Wed, 13 January 2021 05:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13722
Registered: July 2009
Senior Member
Hi, can you please explain what you mean by client .
What are your plans to build?


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: Wed, 13 January 2021 05:04]

Report message to a moderator

Re: Java LSP client for Xtext Language Server? [message #1836740 is a reply to message #1836730] Wed, 13 January 2021 09:23 Go to previous messageGo to next message
M D is currently offline M DFriend
Messages: 5
Registered: January 2021
Junior Member
The plan is to build sort of a web-based editor that follows the language of an Xtext grammar. The idea is for the inputs in the editor to be sent to a server, that sends them to the Xtext language server. I believe an implementation of a language server client will be needed on the server, to send the inputs as JSON-RPC to the Xtext language server?

I do not know if the jar can be located on the actual server, but nonetheless I need a way in just Java to send the JSON-RPC messages to the Xtext language server. If that makes sense?
Re: Java LSP client for Xtext Language Server? [message #1836747 is a reply to message #1836740] Wed, 13 January 2021 09:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13722
Registered: July 2009
Senior Member
but if you have a web based editor then your client will be written in html/javascript or will run e.g. in theia as vscode plugin.
so i dont see the client written in java here.

of course you can use lsp4j to implement the client in java e.g. as LSP4E does


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: Wed, 13 January 2021 09:52]

Report message to a moderator

Re: Java LSP client for Xtext Language Server? [message #1836837 is a reply to message #1836747] Fri, 15 January 2021 08:14 Go to previous messageGo to next message
M D is currently offline M DFriend
Messages: 5
Registered: January 2021
Junior Member
The editor will some based on spreadsheets. Of course some way of processing the inputs will have to be done to make it work with the grammar. That's why the idea was for the input to be sent to a java server and then processed there. Don't know if you see an easier way here?

I've looked at the LSP4E. But I haven't really been able to figure out exactly how it works. I've looked at LanguageServerWrapper and LanguageServerRegistry, but they seem to make use of Eclipse plugins. You don't have a small example when using it with a generated jar? Just need the client to be able to send a simple message to the language server here in the beginning.
Re: Java LSP client for Xtext Language Server? [message #1836839 is a reply to message #1836837] Fri, 15 January 2021 09:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13722
Registered: July 2009
Senior Member
i dont understand. maybe you are confused by the bad terms client and server

- a server runs as a jar. there are basically 3 ways to talk it. (1) process io, in this case the client (or a client proxy) starts the server as child process. socket and websocket.
- then the client sends json rcp messages to the server and receives notifications from the server.

=> have no idea how your client is comprised. likely it is written in javascript and you will talk to the server via websocket?


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: Fri, 15 January 2021 09:08]

Report message to a moderator

Re: Java LSP client for Xtext Language Server? [message #1837063 is a reply to message #1836839] Thu, 21 January 2021 14:38 Go to previous messageGo to next message
M D is currently offline M DFriend
Messages: 5
Registered: January 2021
Junior Member
When I try to run my Language Server jar in the terminal I'm expecting it to print the "... starting" and "... started" strings but that never happens. Presumably because I'm not passing any args? But I can't find any documentation about which args would be required to get process IO started. Any links or tips? Obviously subsequent inputs to the terminal don't result in any outputs from the server either.
Re: Java LSP client for Xtext Language Server? [message #1837064 is a reply to message #1837063] Thu, 21 January 2021 14:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13722
Registered: July 2009
Senior Member
can you start with -log debug then a log file with that messages should be created.
as process io is used to communicate with the server the srdin/out streams are redirected for that


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: Java LSP client for Xtext Language Server? [message #1837066 is a reply to message #1837064] Thu, 21 January 2021 14:54 Go to previous messageGo to next message
M D is currently offline M DFriend
Messages: 5
Registered: January 2021
Junior Member
"-log debug" helped getting the output when starting. Thanks.
Do you have any sources that show how to use Process IO for the subsequent communication with the server?
Re: Java LSP client for Xtext Language Server? [message #1837068 is a reply to message #1837066] Thu, 21 January 2021 15:07 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13722
Registered: July 2009
Senior Member
this is usually done by the client.
it starts a child process
and uses its io to communicate
=> again the question: which client do you want to use

you may e.g. have a look at the https://git.eclipse.org/r/plugins/gitiles/lsp4e/lsp4e codebase e.g. the LanguageServerWrapper or LanguageClientImpl classes and their usages. i am not sure if there is somewhere a more simple example.
you may check out org.eclipse.lsp4j.launch.LSPLauncher.createClientLauncher(LanguageClient, InputStream, OutputStream)


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, 21 January 2021 15:15]

Report message to a moderator

Previous Topic:Declare and implement ecore model import in xtext grammar
Next Topic:Import MyDslStandaloneSetup does not resolve
Goto Forum:
  


Current Time: Sat Jan 23 15:54:40 GMT 2021

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

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

Back to the top