[fix] server diags
This commit is contained in:
parent
776d5013d0
commit
18f3f309c7
2 changed files with 20 additions and 5 deletions
|
@ -52,7 +52,7 @@ declare function lsp-diags:parse-error($text as xs:string, $xml as element(ERROR
|
|||
as map(*)*{
|
||||
|
||||
if(string-length($text) gt 0)
|
||||
then let $last:= string-length($text)
|
||||
then let $last:= string-length($text)-1
|
||||
let $dmesg:=$xml/string()=>trace("parse-error")
|
||||
let $dmesg:=translate($dmesg," ",";")
|
||||
let $b:=number($xml/@b)-1
|
||||
|
@ -60,7 +60,7 @@ as map(*)*{
|
|||
return (
|
||||
(: mark error :)
|
||||
lsp-diags:nostic(pos:Range(pos:toPosition($text, $b),
|
||||
pos:toPosition($text, min(($e,$last)))),
|
||||
pos:toPosition($text, $e)),
|
||||
1,
|
||||
$dmesg,'XPST0003'),
|
||||
|
||||
|
|
|
@ -64,13 +64,20 @@ function connect() {
|
|||
.then(transport => {
|
||||
transport.socket.onclose = (event) => connectStatus(false);
|
||||
transport.socket.oneror = (event) => $("msg").innerText = "sock error!";
|
||||
|
||||
transport.subscribe(incoming);
|
||||
client = new lsp.LSPClient({extensions: lsp.languageServerExtensions()});
|
||||
client.connect(transport);
|
||||
$("popConnect").hidePopover();
|
||||
connectStatus(true);
|
||||
let extLsp =client.plugin( file, "xquery");
|
||||
view.dispatch({ effects: lsp.StateEffect.appendConfig.of(extLsp) })
|
||||
let up=lsp.debouncedChangeListener({
|
||||
delay: 750,
|
||||
onChange: (content, state) => {
|
||||
console.log('Debounced change detected:'+content);
|
||||
client.sync();
|
||||
}})
|
||||
|
||||
view.dispatch({ effects: lsp.StateEffect.appendConfig.of([...extLsp,up]) })
|
||||
})
|
||||
.catch(r => { connectStatus(false); alert("connection failed: " + server) });
|
||||
|
||||
|
@ -86,12 +93,20 @@ function connectStatus(bool) {
|
|||
}
|
||||
};
|
||||
|
||||
function incoming(msg) {
|
||||
const rpc = JSON.parse(msg);
|
||||
log(rpc);
|
||||
|
||||
};
|
||||
|
||||
|
||||
function log(rpc) {
|
||||
console.log("<-",rpc)
|
||||
if (rpc.id) return
|
||||
const text = rpc.method;
|
||||
const li = document.createElement("li");
|
||||
li.appendChild(document.createTextNode(text));
|
||||
const n=$("traffic").childElementCount + " ";
|
||||
li.appendChild(document.createTextNode(n + text));
|
||||
$("traffic").insertBefore(li, $("traffic").firstChild)
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue