[fix] severities
This commit is contained in:
parent
99a77cd5bf
commit
2d99af9389
5 changed files with 38 additions and 11 deletions
|
@ -6,7 +6,7 @@
|
||||||
"triggerCharacters": [ "\"", ":" ],
|
"triggerCharacters": [ "\"", ":" ],
|
||||||
"documentSelector": [{ "language": "xquery" }]
|
"documentSelector": [{ "language": "xquery" }]
|
||||||
},
|
},
|
||||||
"hoverProvider": false,
|
"hoverProvider": true,
|
||||||
"documentSymbolProvider": false,
|
"documentSymbolProvider": false,
|
||||||
"documentRangeFormattingProvider": false,
|
"documentRangeFormattingProvider": false,
|
||||||
"colorProvider": {},
|
"colorProvider": {},
|
||||||
|
|
|
@ -21,9 +21,9 @@ declare record lsp-diags:nostic(
|
||||||
|
|
||||||
declare variable $lsp-diags:severities:={
|
declare variable $lsp-diags:severities:={
|
||||||
'error':1,
|
'error':1,
|
||||||
'hint':2,
|
'hint':4,
|
||||||
'info':3,
|
'info':3,
|
||||||
'warning':4
|
'warning':2
|
||||||
};
|
};
|
||||||
|
|
||||||
declare function lsp-diags:publish(
|
declare function lsp-diags:publish(
|
||||||
|
@ -33,7 +33,7 @@ declare function lsp-diags:publish(
|
||||||
as map(*){
|
as map(*){
|
||||||
let $diagnostics:=if($xml/self::ERROR)
|
let $diagnostics:=if($xml/self::ERROR)
|
||||||
then array{lsp-diags:parse-error($text, $xml)}
|
then array{lsp-diags:parse-error($text, $xml)}
|
||||||
else []
|
else array{lsp-diags:parse-xquery($text,$xml)}
|
||||||
|
|
||||||
return {"jsonrpc": "2.0",
|
return {"jsonrpc": "2.0",
|
||||||
"method":"textDocument/publishDiagnostics",
|
"method":"textDocument/publishDiagnostics",
|
||||||
|
@ -47,13 +47,29 @@ as map(*){
|
||||||
declare function lsp-diags:parse-error($text as xs:string, $xml as element(ERROR))
|
declare function lsp-diags:parse-error($text as xs:string, $xml as element(ERROR))
|
||||||
as map(*)*{
|
as map(*)*{
|
||||||
|
|
||||||
lsp-diags:nostic(pos:Range(pos:toPosition($text=>trace("EXML "), $xml/@b),
|
lsp-diags:nostic(pos:Range(pos:toPosition($text, $xml/@b),
|
||||||
pos:toPosition($text, $xml/@e)),
|
pos:toPosition($text, $xml/@e)),
|
||||||
1,
|
$lsp-diags:severities('error'),
|
||||||
$xml/string()),
|
$xml/string()),
|
||||||
|
|
||||||
lsp-diags:nostic(pos:Range(pos:toPosition($text, $xml/@e +1 ),
|
lsp-diags:nostic(pos:Range(pos:toPosition($text, $xml/@e +1 ),
|
||||||
pos:toPosition($text, string-length($text)-1)),
|
pos:toPosition($text, string-length($text)-1)),
|
||||||
2,
|
$lsp-diags:severities('warning'),
|
||||||
"Previous parse error")
|
"Previous parse error")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(: test data :)
|
||||||
|
declare function lsp-diags:parse-xquery($text as xs:string, $xml as element(Module))
|
||||||
|
as map(*)*{
|
||||||
|
lsp-diags:nostic(pos:Range(pos:Position(0,0), pos:Position(0, 5)),
|
||||||
|
$lsp-diags:severities('error'),"111"),
|
||||||
|
|
||||||
|
lsp-diags:nostic(pos:Range(pos:Position(1,0), pos:Position(1,5)),
|
||||||
|
$lsp-diags:severities('warning'),"2222"),
|
||||||
|
|
||||||
|
lsp-diags:nostic(pos:Range(pos:Position(2,0), pos:Position(2, 5)),
|
||||||
|
$lsp-diags:severities('info'),"333"),
|
||||||
|
|
||||||
|
lsp-diags:nostic(pos:Range(pos:Position(3,0), pos:Position(3, 12)),
|
||||||
|
$lsp-diags:severities('hint'), "44")
|
||||||
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ var editor = ace.edit("editor", {
|
||||||
useWorker: false // Disable web worker for this simple demo
|
useWorker: false // Disable web worker for this simple demo
|
||||||
});
|
});
|
||||||
|
|
||||||
//ace.require('ace/ext/settings_menu');
|
ace.require('ace/ext/settings_menu');
|
||||||
editor.setTheme("ace/theme/github");
|
editor.setTheme("ace/theme/github");
|
||||||
//editor.session.setMode("ace/mode/html");
|
//editor.session.setMode("ace/mode/html");
|
||||||
editor.commands.addCommands([
|
editor.commands.addCommands([
|
||||||
|
|
|
@ -61,6 +61,9 @@
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||||
|
<ul id="msg" style="overflow: scroll;">
|
||||||
|
<li>-</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col flex-grow-1" style="overflow: auto;">
|
<div class="col flex-grow-1" style="overflow: auto;">
|
||||||
|
|
|
@ -76,7 +76,8 @@ function connect() {
|
||||||
};
|
};
|
||||||
|
|
||||||
function incoming(msg) {
|
function incoming(msg) {
|
||||||
const rpc=JSON.parse(msg)
|
const rpc=JSON.parse(msg);
|
||||||
|
log(rpc.method);
|
||||||
switch (rpc.method) {
|
switch (rpc.method) {
|
||||||
case "textDocument/publishDiagnostics":
|
case "textDocument/publishDiagnostics":
|
||||||
diags(rpc.params);
|
diags(rpc.params);
|
||||||
|
@ -87,10 +88,17 @@ function incoming(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
function log(msg){
|
||||||
|
const li = document.createElement("li");
|
||||||
|
|
||||||
|
li.appendChild(document.createTextNode(msg));
|
||||||
|
const ol=document.getElementById("msg");
|
||||||
|
ol.insertBefore(li,ol.firstChild)
|
||||||
|
};
|
||||||
function diags(params){
|
function diags(params){
|
||||||
console.log("--",params)
|
console.log("--",params)
|
||||||
let plugin= lsp.LSPPlugin.get(view);
|
let plugin= lsp.LSPPlugin.get(view);
|
||||||
const severities=["error" , "hint" ,"info" ,"warning"]
|
const severities=["error","warning" ,"info","hint" ]
|
||||||
//
|
//
|
||||||
const diagnostics = params.diagnostics
|
const diagnostics = params.diagnostics
|
||||||
.map(({ range, message, severity }) => ({
|
.map(({ range, message, severity }) => ({
|
||||||
|
|
Loading…
Add table
Reference in a new issue