[add] window/logMessage
This commit is contained in:
parent
7369f33b5e
commit
ab88b9139e
7 changed files with 62 additions and 9 deletions
|
@ -25,3 +25,5 @@ http://localhost:3000/exampleServer
|
||||||
https://github.com/mkslanc/ace-linters/blob/c1b317e01299016ac7da6588361228637f4eac25/packages/demo/websockets-lsp/server/server.ts
|
https://github.com/mkslanc/ace-linters/blob/c1b317e01299016ac7da6588361228637f4eac25/packages/demo/websockets-lsp/server/server.ts
|
||||||
|
|
||||||
https://www.jsonrpc.org/specification
|
https://www.jsonrpc.org/specification
|
||||||
|
|
||||||
|
yyy **GGG**
|
12
samples/didopen/client.json
Normal file
12
samples/didopen/client.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "textDocument/didOpen",
|
||||||
|
"params": {
|
||||||
|
"textDocument": {
|
||||||
|
"uri": "file:///some/file.xml",
|
||||||
|
"languageId": "xml",
|
||||||
|
"text": "<foo at=42><bar>test</bar></foo>vvvbvbvbvbvbv\nvv\n\nvcccccccccccccc\n",
|
||||||
|
"version": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
samples/logMessage/server.json
Normal file
5
samples/logMessage/server.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -26,13 +26,13 @@ as map(*)?
|
||||||
"contents": [
|
"contents": [
|
||||||
{
|
{
|
||||||
"language": "markdown",
|
"language": "markdown",
|
||||||
"value": `this is **bold** markdown
|
"value": `markdown: this is **bold**
|
||||||
a link (here)[http://google.com]
|
a [link](http://google.com)
|
||||||
The last line`
|
The last line.`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"language": "plaintext",
|
"language": "plaintext",
|
||||||
"value": "A hover for " || json:serialize($json)
|
"value": "plaintext: A hover for " || json:serialize($json?params?position)
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,13 @@ function lsp-text:didOpen($json as map(*))
|
||||||
as map(*)?
|
as map(*)?
|
||||||
{
|
{
|
||||||
let $textDoc:=$json?params?textDocument
|
let $textDoc:=$json?params?textDocument
|
||||||
let $text:=$textDoc?text=>trace("TXT")
|
|
||||||
return ()
|
let $x:=job:eval(xs:anyURI("parse.xq"),
|
||||||
|
{"textDocument":$textDoc,"webSocket":ws:id()},
|
||||||
|
{ 'cache': true() }
|
||||||
|
)
|
||||||
|
|
||||||
|
return ws:set(ws:id(),$textDoc?uri,$textDoc)
|
||||||
};
|
};
|
||||||
|
|
||||||
(:~ unknown method response :)
|
(:~ unknown method response :)
|
||||||
|
|
24
webapp/lsp/parse.xq
Normal file
24
webapp/lsp/parse.xq
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
(: parse a didOpen :)
|
||||||
|
import module namespace p="xq4" at "xq4.xqm";
|
||||||
|
|
||||||
|
declare variable $textDocument external;
|
||||||
|
declare variable $webSocket as xs:string external;
|
||||||
|
|
||||||
|
let $text as xs:string:=$textDocument?text
|
||||||
|
let $uri:=$textDocument?uri
|
||||||
|
let $files:=ws:get($webSocket,"files",{})
|
||||||
|
let $files:=if(map:contains($files,$uri))
|
||||||
|
then $files
|
||||||
|
else map:put($files,$uri,{"textDocument":random:uuid(),"parse":random:uuid() })
|
||||||
|
let $keys:=$files($uri)
|
||||||
|
let $xml:=p:parse-Module($text)
|
||||||
|
|
||||||
|
return (
|
||||||
|
ws:set($webSocket,"files",$files),
|
||||||
|
ws:set($webSocket,$keys?textDocument,$textDocument),
|
||||||
|
ws:set($webSocket,$keys?parse,$xml),
|
||||||
|
ws:send({"jsonrpc": "2.0","method":"window/logMessage",
|
||||||
|
"params":{"type":1,"message":"TODO"}},$webSocket)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
4
webapp/lsp/smoke.xq
Normal file
4
webapp/lsp/smoke.xq
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
job:eval(xs:anyURI("parse.xq"),
|
||||||
|
{"textDocument":"2+3","webSocket":ws:id()},
|
||||||
|
{ 'cache': true() }
|
||||||
|
)
|
|
@ -34,7 +34,7 @@
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
something
|
something
|
||||||
</div>
|
</div>
|
||||||
<div class="col flex-grow-1" style="background-color:gainsboro">
|
<div class="col flex-grow-1" >
|
||||||
<div class="row" >
|
<div class="row" >
|
||||||
<div >
|
<div >
|
||||||
<label for="file">File:</label><input id="iFile" type="url" value="file:///some/file.xml" />
|
<label for="file">File:</label><input id="iFile" type="url" value="file:///some/file.xml" />
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<script src="./lsp.bundle.js"></script>
|
<script src="./lsp.bundle.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
let doc = `<foo at=42><bar>test</bar></foo>`;
|
let doc = `3+1`;
|
||||||
// Load saved content from localStorage when the page loads
|
// Load saved content from localStorage when the page loads
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const savedText = localStorage.getItem('code');
|
const savedText = localStorage.getItem('code');
|
||||||
|
@ -90,6 +90,7 @@
|
||||||
lsp.simpleWebSocketTransport(server)
|
lsp.simpleWebSocketTransport(server)
|
||||||
.then(transport => {
|
.then(transport => {
|
||||||
let link = lsp.lsp(transport, file);
|
let link = lsp.lsp(transport, file);
|
||||||
|
const doc=view.state.doc.toString();
|
||||||
const state = lsp.createEditorState(doc, [...lsp.baseExts, link]);
|
const state = lsp.createEditorState(doc, [...lsp.baseExts, link]);
|
||||||
view.setState(state);
|
view.setState(state);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue