Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Code completion in VSCode(xtext, code completion, vscode, grammar)
Code completion in VSCode [message #1803035] Thu, 21 February 2019 09:55 Go to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
Hello and good day!

I just saw Miro's article on how to build a VS Code extension with Xtext and LSP.

https://typefox.io/building-a-vs-code-extension-with-xtext-and-the-language-server-protocol

As soon as I tried the published example language I noticed there is no code completion/content assist. Is it possible to implement this important feature?
Re: Code completion in VSCode [message #1803053 is a reply to message #1803035] Thu, 21 February 2019 14:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
There is a specific version where content assist is broken

That is fixed in more recent versions
See

https://github.com/itemis/xtext-languageserver-example

For an sample project


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code completion in VSCode [message #1803091 is a reply to message #1803053] Fri, 22 February 2019 09:28 Go to previous messageGo to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
Good to see that it can work, I seem to have some troubles with building my own extension. Can you be more specific about which version you're talking about? Xtext version or?...
Re: Code completion in VSCode [message #1803095 is a reply to message #1803091] Fri, 22 February 2019 10:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Its in 215 and fixed in 216 and later
Workaround is here
https://github.com/itemis/xtext-languageserver-example/pull/36/files


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code completion in VSCode [message #1803103 is a reply to message #1803095] Fri, 22 February 2019 13:08 Go to previous messageGo to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
I can't find the files you edited. 'contentassist' folder is non-existent in my IDE project folder. Am I supposed to add them manually or have I built the project the wrong way?
Re: Code completion in VSCode [message #1803120 is a reply to message #1803035] Fri, 22 February 2019 17:25 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Please take the example Christian mentions and compare that carefully against your setup.
Re: Code completion in VSCode [message #1803123 is a reply to message #1803120] Fri, 22 February 2019 18:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
My examples shows what needs to be done to workaround
Using a old Xtext version
If the commit adds a file you should do it too.
If the package does not exist , create it

But my question would be: why sticking with an old Xtext version ?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code completion in VSCode [message #1803184 is a reply to message #1803123] Mon, 25 February 2019 06:48 Go to previous messageGo to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
It's not about sticking with an old version of xtext but rather not really knowing how to create this extension and make it work. I haven't worked with xtext much and I am confused.

I tried pasting my grammar rules into your project to see if it works, looks like it doesn't. Though it works when I am running it on my project.
Re: Code completion in VSCode [message #1803187 is a reply to message #1803184] Mon, 25 February 2019 07:29 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

So again, best is to start with Christian's example, make it work and then carefully compare to yours.

https://github.com/itemis/xtext-languageserver-example
Re: Code completion in VSCode [message #1803188 is a reply to message #1803187] Mon, 25 February 2019 07:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Are you sure you don't have a concept in your grammar that simply requires customization of content assist
The default impl does not do as many things as in eclipse
And eg. For datatype rules you have to customize it anyway


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code completion in VSCode [message #1803190 is a reply to message #1803188] Mon, 25 February 2019 08:08 Go to previous messageGo to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
The content assist works in the eclipse client. Shouldn't it not work in eclipse too if that would be the problem?
Re: Code completion in VSCode [message #1803193 is a reply to message #1803190] Mon, 25 February 2019 08:28 Go to previous messageGo to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
In regards to Karsten, I am doing that at the moment and found some differences but they look more like differences between xtext versions? As I stated in my second reply I made Christians example work. Does the way I build, other than choosing Gradle as build system, impact the project and not make it work?
Re: Code completion in VSCode [message #1803203 is a reply to message #1803193] Mon, 25 February 2019 10:08 Go to previous messageGo to next message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
Ok, used https://github.com/eclipse/xtext-eclipse/issues/834

and that seems to fix it, but there is another problem remaining. It doesn't do syntax highlight. Saw in a json file that none of those set where there. When I used Miro's way of building the extension the highlighting worked.
Re: Code completion in VSCode [message #1803205 is a reply to message #1803203] Mon, 25 February 2019 10:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
there is no syntax highlighting
it happens client side with a specific config.
the example contains the textmate grammar for it.
https://github.com/itemis/xtext-languageserver-example/blob/master/vscode-extension-self-contained/syntaxes/mydsl.tmLanguage.json

there are specific clients that support semantic highlighting as well (and xtext server side does too) but vscode does not


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Code completion in VSCode [message #1803214 is a reply to message #1803205] Mon, 25 February 2019 11:32 Go to previous message
Robert-Adrian Chelaru is currently offline Robert-Adrian ChelaruFriend
Messages: 18
Registered: November 2018
Junior Member
That should sum it up, hopefully no more problems will arise. Thank you for sticking with me Christian!
Previous Topic:Usage of org.eclipse.sphinx.emf.check.checkvalidators
Next Topic:DSL Generate Documentation
Goto Forum:
  


Current Time: Fri Mar 29 07:59:18 GMT 2024

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

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

Back to the top