- JavaScript 63.3%
- XQuery 19.5%
- Java 13%
- CSS 2.1%
- HTML 1.6%
- Other 0.3%
| .vscode | ||
| app | ||
| bundles | ||
| docs | ||
| scripts | ||
| test | ||
| webapp | ||
| .basexgui | ||
| .basexhistory | ||
| .gitignore | ||
| basex-home.bat | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| rollup.config.js | ||
| webawesome-3.1.0.tar.gz | ||
Work in progress.
An attempt to write a Language Server Protocol server for and in XQuery 4.0. It tracks the draft specifications at https://qt4cg.org/ It written for BaseX 12.0 and uses the BaseX websocket for transport. See The WebSocket Protocol RFC 6455
Provides
- A BaseX LSP using websockets at
ws://localhost:3000/ws/lsp - A service management web interface for the LSP at
http://localhost:3000/app
Demo
- Clone this repostory.
- Set enviroment variable
$BASEX_HOMEto the path of the BaseX installation to use. - cd into the
app/ - run
basexhttp -S - In a browser naviagate to
http:\\localhost:3000
In principle, the LSP can be used in any environment that can make use of a LSP server accessed via a websocket.
LSP Server
webapp/lspThe LSP implementation in XQuery using WebSockets for transport and the JSON-RPC 2.0 API for data format.
Sample html clients
Samples using common browser based code editors are available. The CodeMirror 6 sample is the most functional.
These examples are self contained (no internet access required). Some make use of recent html features, for instance popovertarget
CodeMirror6 https://codemirror.net/
webapp/static/codemirrorA test html page using the CodeMirror6 editor that connects to the BaseX LSP instance
uses
- https://codemirror.net/docs/ref/#lsp-client
- https://github.com/codemirror/legacy-modes/
xquerymode provides browser based syntax highlighting (XQuery 3.1?)
alternative LSP interfaces
Ace Editor
webapp/static/aceA test html page using the Ace editor that connects to the BaseX LSP instance @TODO fix
Uses
Make a websocket server for lsp on port 3000 https://mkslanc.github.io/ace-linters/websocket.html
http://localhost:3000/exampleServer
github.com/mkslanc/ace-linters@c1b317e012/packages/demo/websockets-lsp/server/server.ts
I needed set NODE_OPTIONS=--max_old_space_size=8192 for build to complete
Or node --max-old-space-size=8192 node_modules/webpack-dev-serve r/bin/webpack-dev-server.js
Monaco editor
@TODO create https://socket.dev/npm/package/monaco-editor
Server dev notes
State is held in websocket attributes.
| Name | Use |
|---|---|
| id | wsid |
| connectTime | dateTime of connection |
| initialized | set true after client sends initialized message |
| client | the client initialize message |
| files | A map whose keys are open uris, values are maps (doctype-> attribute name where doctype is stored |
| file-{uuid} | name of websocket attribute containing the textDocument |
| parse-{uuid} | name of websocket attribute containing parse tree XML |
sequenceDiagram
WS->>lsp-ws: message
lsp-ws->>rpc: reply
rpc->>+John: John, can you hear me?
XQuery 4.0 parser
The Ebnf is taken from Gunther Rademacher's rex-parser-generator XQuery-40.ebnf
The script scripts/rex.xq can generate XQuery or Java parser code from this.
The npm package.json script javac can create a jar file from the Java source.
Related links
java -cp org.eclipse.lemminx-uber.jar org.eclipse.lemminx.XMLServerSocketLauncher`