Home » Modeling » TMF (Xtext) » XText Web. How finds ACE the Language Server?
XText Web. How finds ACE the Language Server? [message #1796935] |
Mon, 22 October 2018 10:43  |
Eclipse User |
|
|
|
Hi there,
I try to use as many parts as possible from examples. I can't use the existing Web-Project of Xtext so i imported the war-file of it to another project (Eclipse-PlugIn) There I modified a existing Servlet which has doGet() und doPost() to a XTextServlet and put all the libs in a directory. To show up the WebPage with the Ace-Editor I used
getServletContext().getRequestDispatcher("/index.html").forward(req, resp);
Instead of index.html was a "jsp" in the original doGet()-Method.
How does ACE find the way back? How it connects to the LanguageServer-Servlet?
I see Ace in the Browser, no errors during booting the WebServer... but no connection. The files don't show me a url and i have no welcome-page like on the original Apache. I can't use the same setup but need a way to connect.
Thanks for help
Markus
|
|
| | | | | | | |
Re: XText Web. How finds ACE the Language Server? [message #1799471 is a reply to message #1799469] |
Fri, 07 December 2018 06:45   |
Eclipse User |
|
|
|
I found two tutorials to add this websocket to monaco and xtext language server.
To connect it i use: const url = 'ws://localhost:4389', in the editor and commandline says it's connected.
The editor code has following:
// register Monaco languages
monaco.languages.register({
id: 'mydsl',
extensions: ['mydsl'],
aliases: ['MYDSL'],
mimetypes: ['application/Java'],
});
and
const editor = monaco.editor.create(document.getElementById("container")!, {
model: monaco.editor.createModel(value, 'mydsl',monaco.Uri.parse('inmemory:/MyDslParser')),
glyphMargin: true,
lightbulb: {
enabled: true
}
});
No idea how to teach Monaco mydsl from the server. I tried some things in ths Uri.parse(), but failed
|
|
| | | | | | | | | | | | | | |
Re: XText Web. How finds ACE the Language Server? [message #1799703 is a reply to message #1799626] |
Wed, 12 December 2018 12:12   |
Eclipse User |
|
|
|
Hi ,
i don't find code to uncomment in LS-Repo.
Here is the client, or what I think the client is
Markus
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { listen, MessageConnection } from 'vscode-ws-jsonrpc';
import {
MonacoLanguageClient, CloseAction, ErrorAction,
MonacoServices, createConnection
} from 'monaco-languageclient';
const ReconnectingWebSocket = require('reconnecting-websocket');
// register Monaco languages
//monaco.languages.register({
// id: 'json',
// extensions: ['.json', '.bowerrc', '.jshintrc', '.jscsrc', '.eslintrc', '.babelrc'],
// aliases: ['JSON', 'json'],
// mimetypes: ['application/json'],
//});
// create Monaco editor
const value = `{
"$schema": "http://json.schemastore.org/coffeelint",
"line_endings": "unix"
}`;
const editor = monaco.editor.create(document.getElementById("container")!, {
model: monaco.editor.createModel(value, 'mydsl', monaco.Uri.parse('inmemory://model.mydsl')),
glyphMargin: true,
lightbulb: {
enabled: true
}
});
// install Monaco language client services
MonacoServices.install(editor);
// create the web socket
const url = 'ws://localhost:4389'
const webSocket = createWebSocket(url);
// listen when the web socket is opened
listen({
webSocket,
onConnection: connection => {
// create and start the language client
const languageClient = createLanguageClient(connection);
const disposable = languageClient.start();
connection.onClose(() => disposable.dispose());
}
});
function createLanguageClient(connection: MessageConnection): MonacoLanguageClient {
return new MonacoLanguageClient({
name: "Sample Language Client",
clientOptions: {
// use a language id as a document selector
documentSelector: ['mydsl'],
// disable the default error handler
errorHandler: {
error: () => ErrorAction.Continue,
closed: () => CloseAction.DoNotRestart
}
},
// create a language client connection from the JSON RPC connection on demand
connectionProvider: {
get: (errorHandler, closeHandler) => {
return Promise.resolve(createConnection(connection, errorHandler, closeHandler))
}
}
});
}
function createWebSocket(url: string): WebSocket {
const socketOptions = {
maxReconnectionDelay: 10000,
minReconnectionDelay: 1000,
reconnectionDelayGrowFactor: 1.3,
connectionTimeout: 10000,
maxRetries: Infinity,
debug: false
};
return new ReconnectingWebSocket(url, undefined, socketOptions);
}
|
|
| | | | | | | | |
Re: XText Web. How finds ACE the Language Server? [message #1799768 is a reply to message #1799750] |
Thu, 13 December 2018 06:18   |
Eclipse User |
|
|
|
With RunWebSocketServer3 i get now in the (Run-Mode) (In Debug Mode i get Websocketnotconnected)
gogogo
start
open
message: {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"rootPath":null,"rootUri":null,"capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"]}},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"renameProvider":true,"executeCommandProvider":{"commands":["mydsl.a","mydsl.b","mydsl.c"]},"semanticHighlighting":{"scopes":[]}}}}
message: {"jsonrpc":"2.0","method":"initialized","params":{}}
open
message: {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"rootPath":null,"rootUri":null,"capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"]}},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
Dez 13, 2018 12:17:20 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SCHWERWIEGEND: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:99)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
... 11 more
Caused by: java.lang.IllegalStateException: This language server has already been initialized.
at org.eclipse.xtext.ide.server.LanguageServerImpl.initialize(LanguageServerImpl.java:225)
... 16 more
{"jsonrpc":"2.0","id":0,"error":{"code":-32603,"message":"Internal error.","data":"java.lang.RuntimeException: java.lang.reflect.InvocationTargetException\r\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)\r\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)\r\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)\r\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)\r\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)\r\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\r\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:99)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)\r\n\tat java.util.concurrent.FutureTask.run(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat java.lang.Thread.run(Unknown Source)\r\nCaused by: java.lang.reflect.InvocationTargetException\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\r\n\tat java.lang.reflect.Method.invoke(Unknown Source)\r\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)\r\n\t... 11 more\r\nCaused by: java.lang.IllegalStateException: This language server has already been initialized.\r\n\tat org.eclipse.xtext.ide.server.LanguageServerImpl.initialize(LanguageServerImpl.java:225)\r\n\t... 16 more\r\n"}}
message: {"jsonrpc":"2.0","id":1,"method":"shutdown","params":null}
{"jsonrpc":"2.0","id":1,"result":{}}
message: {"jsonrpc":"2.0","method":"exit","params":null}
|
|
| |
Re: XText Web. How finds ACE the Language Server? [message #1799771 is a reply to message #1799770] |
Thu, 13 December 2018 06:24   |
Eclipse User |
|
|
|
I get this and then nothing happens on the editor
gogogo
start
open
message: {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"rootPath":null,"rootUri":null,"capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"]}},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true}}},"trace":"off","workspaceFolders":null}}
{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"hoverProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"renameProvider":true,"executeCommandProvider":{"commands":["mydsl.a","mydsl.b","mydsl.c"]},"semanticHighlighting":{"scopes":[]}}}}
message: {"jsonrpc":"2.0","method":"initialized","params":{}}
|
|
| | |
Re: XText Web. How finds ACE the Language Server? [message #1799775 is a reply to message #1799774] |
Thu, 13 December 2018 07:10   |
Eclipse User |
|
|
|
everything should be mydsl. (thought that would be clear)
do you get any errors in client side console?
monaco.languages.register({
id: 'mydsl',
extensions: ['.mydsl'],
aliases: ['MYDSL', 'mydsl'],
mimetypes: ['application/mydsl']});
});
model: monaco.editor.createModel(value, 'mydsl', monaco.Uri.parse('inmemory://demo/model.mydsl')),
documentSelector: ['mydsl'],
[Updated on: Thu, 13 December 2018 07:11] by Moderator
|
|
|
Re: XText Web. How finds ACE the Language Server? [message #1799777 is a reply to message #1799775] |
Thu, 13 December 2018 07:22   |
Eclipse User |
|
|
|
Hi,
much better. Whenever i press the keyboard, a message goes to the server. The Language consists of 'Hello'? This doesn't find autocomplete. Just the words which are already in the editor.
message: {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"inmemory://demo/model.mydsl","version":59},"contentChanges":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":1}},"rangeLength":1,"text":""}]}}
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"inmemory://demo/model.mydsl","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":1}},"severity":1,"code":"org.eclipse.xtext.diagnostics.Diagnostic.Syntax","message":"missing EOF at \u0027{\u0027"}]}}
|
|
|
Re: XText Web. How finds ACE the Language Server? [message #1799778 is a reply to message #1799777] |
Thu, 13 December 2018 07:24   |
Eclipse User |
|
|
|
then there is still something wrong on your side that i cannot see.
i get this content assist answers
this is the request
message: {"jsonrpc":"2.0","id":4,"method":"textDocument/completion","params":{"textDocument":{"uri":"inmemory://demo/model.mydsl"},"position":{"line":3,"character":0},"context":{"triggerKind":1}}}
this is the response
{"jsonrpc":"2.0","id":4,"result":{"isIncomplete":true,"items":[{"label":"Hello","kind":14,"sortText":"00000","textEdit":{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"Hello"}},{"label":"New Greeting (Template with Choice)","kind":15,"sortText":"00001","insertTextFormat":2,"textEdit":{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"Hello ${1|A,B,C|} from ${2|A,B,you|}!"}},{"label":"New Greeting (Template with Placeholder)","kind":15,"sortText":"00002","insertTextFormat":2,"textEdit":{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"Hello ${1:name} from ${2:fromName}!"}}]}}
|
|
|
Re: XText Web. How finds ACE the Language Server? [message #1799779 is a reply to message #1799778] |
Thu, 13 December 2018 07:37   |
Eclipse User |
|
|
|
When I press 'H' within { }
I get this:
message: {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"inmemory://demo/model.mydsl","version":116},"contentChanges":[{"range":{"start":{"line":0,"character":1},"end":{"line":0,"character":1}},"rangeLength":0,"text":"H"}]}}
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"inmemory://demo/model.mydsl","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":1}},"severity":1,"code":"org.eclipse.xtext.diagnostics.Diagnostic.Syntax","message":"missing EOF at \u0027{\u0027"}]}}
message: {"jsonrpc":"2.0","id":142,"method":"textDocument/completion","params":{"textDocument":{"uri":"inmemory://demo/model.mydsl"},"position":{"line":0,"character":2},"context":{"triggerKind":1}}}
{"jsonrpc":"2.0","id":142,"result":{"isIncomplete":true,"items":[]}}
message: {"jsonrpc":"2.0","id":143,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"inmemory://demo/model.mydsl"},"range":{"start":{"line":0,"character":2},"end":{"line":0,"character":2}},"context":{"diagnostics":[]}}}
{"jsonrpc":"2.0","id":143,"result":[]}
message: {"jsonrpc":"2.0","id":144,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"inmemory://demo/model.mydsl"},"range":{"start":{"line":0,"character":2},"end":{"line":0,"character":2}},"context":{"diagnostics":[]}}}
{"jsonrpc":"2.0","id":144,"result":[]}
|
|
| | | | | | | | | | | | | | | | | |
Goto Forum:
Current Time: Thu Apr 24 03:07:06 EDT 2025
Powered by FUDForum. Page generated in 0.08363 seconds
|