Git Product home page Git Product logo

xtext-languageserver-example's Introduction

Xtext Visual Studio Code Example

This is an Example showing the Visual Studio Code Integration of Xtext using the Microsoft Language Server Protocol.

Build Status

Quickstart

Requires Visual Studio Code (VS Code) with version 1.4.0 or greater to be on the path as code and Java 8+ available as java.

  • Run ./gradlew startCode

This will start VS Code and after a few seconds load the demo folder of this repository.

Project Structure

  • vscode-extension (node based VS Code extension to run with a separate server using socket)
  • vscode-extension-self-contained (node based VS Code extension to run with a embedded server using process io)
  • org.xtext.example.mydsl (contains the dsl)
  • org.xtext.example.mydsl.ide (contains the dsl specific customizations of the Xtext language server)
  • org.xtext.example.mydsl.tests

Building in Details

  1. Make sure that java -version is executable and pointing to a Java 8+ JDK.
  2. Type code. If the command is not known, open VS Code and select View / Command Palette. Enter code and select to install code on the path.
  3. Run ./gradlew startCode to build the DSL and the VS Code extensions.

Scenario 1 (embedded server)

  1. Install the self-contained extension into VS Code using code --install-extension vscode-extension-self-contained/build/vscode/vscode-extension-self-contained-0.0.1.vsix
  2. Run a second instance of vscode on the demo folder code demo

Scenario 2 (client-only with separate server process)

  1. Run ./gradlew run or launch RunServer from Eclipse.
  2. Open vscode-extension in VS Code and F5 to launch new editor (you may need a Debug -> Start Debugging initally).
  3. Open folder demo in the new editor.

Build VS Code Extension Package manually (manually Gradle)

npm install -g vsce
cd vscode-extension
vsce package
cd ../vscode-extension-self-contained
vsce package

Hints

For Other Xtext/VSCode versions please also check other branches for newer/older Xtext Versions that also support newer/older vscode versions Atom language client is dead. We plan to update to a fork. See itemis#73

xtext-languageserver-example's People

Contributors

cdietrich avatar franzbecker avatar holgerschill avatar koenkk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xtext-languageserver-example's Issues

Formatting uses tabs when the model is updated from the CommandService

For our domain we have a command defined in vscode that assigns a uuid to each model element and as part of that it saves the model back to the files.
The problem were having is that thru this invocation point the formatting is inserting tabs rather than spaces. However when explicitly using the dsl-formatter spaces are inserted.

My vscode is configured to use spaces:

    "editor.detectIndentation": false,
    "editor.tabSize": 4,
    "editor.insertSpaces": true,

I'm not sure how to come around this issue. Any help appreciated.

Corrections to README.md

I was able to run it with Java 11 and Eclipse Sep-2018, though instructions are a little bit different.

  1. change the npm install command, needs to "-g"
    npm install -g vsce
  2. To run scenario 2, I had to first run the build "vsce package" and therafter the commands were ..
    code --install-extension vscode-extension-self-contained/xtext-vscode-example-0.0.14.vsix
    code demo

Visual Studio Code extension does not work on Windows

It seems that there are some troubles on Windows with the Xtext Server startup. Can you take a look at this and fix this? Thank you.
Test Environment:

  • Windows 10 Build 14393
  • VS Code v1.8.0

I also tested the same visx file on Ubuntu 16.04 and everything seems to work fine.

image

Code Generation

Would it be possible to add a command invoking code generation?

Thanks in advance.

IndexOutOfBoundsException repro

Thank you for this excellent repo which has been really helpful. I have reproduced the following trace with the repo and a standard monaco server (harder to repro in VSCode but hopefully this gives an indication and this is very much the same issue as that linked below):

(relates to eclipse/xtext-core#1451 )

SEVERE: Internal error: java.lang.IndexOutOfBoundsException: Position [
  line = 8
  character = 7
] text was : Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

java.util.concurrent.CompletionException: java.lang.IndexOutOfBoundsException: Position [
  line = 8
  character = 7
] text was : Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

	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:834)
Caused by: java.lang.IndexOutOfBoundsException: Position [
  line = 8
  character = 7
] text was : Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

	at org.eclipse.xtext.ide.server.Document.getOffSet(Document.java:62)
	at org.eclipse.xtext.ide.server.hover.HoverService.hover(HoverService.java:53)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$hover$32(LanguageServerImpl.java:718)
	at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:438)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.hover(LanguageServerImpl.java:717)
	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$hover$31(LanguageServerImpl.java:704)
	at org.eclipse.xtext.ide.server.concurrent.ReadRequest.lambda$doRun$0(ReadRequest.java:66)
	... 5 more

to repro: on this fork and branch:

https://github.com/ewenmaclean/xtext-languageserver-example/tree/IndexOutOfBoundsError

in the monaco-server dir run yarn then yarn prepare in the server dir. Then yarn start from the server dir to start - you will get an editor at http://localhost:3000.

Now do the following - add the text:

Hello Xtext!
Hello VSCode from Xtext!
Hello ThisFile from Other!

then paste in at the end


Hello you!

Now hover over the validation error at "you!". Now delete this section, then press ctrl-Z so it reappears and then hover over the "you!" error again and you should get the error trace above

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.