[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": [ "\"", ":" ],
|
||||
"documentSelector": [{ "language": "xquery" }]
|
||||
},
|
||||
"hoverProvider": false,
|
||||
"hoverProvider": true,
|
||||
"documentSymbolProvider": false,
|
||||
"documentRangeFormattingProvider": false,
|
||||
"colorProvider": {},
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ declare record lsp-diags:nostic(
|
|||
|
||||
declare variable $lsp-diags:severities:={
|
||||
'error':1,
|
||||
'hint':2,
|
||||
'hint':4,
|
||||
'info':3,
|
||||
'warning':4
|
||||
'warning':2
|
||||
};
|
||||
|
||||
declare function lsp-diags:publish(
|
||||
|
|
@ -33,7 +33,7 @@ declare function lsp-diags:publish(
|
|||
as map(*){
|
||||
let $diagnostics:=if($xml/self::ERROR)
|
||||
then array{lsp-diags:parse-error($text, $xml)}
|
||||
else []
|
||||
else array{lsp-diags:parse-xquery($text,$xml)}
|
||||
|
||||
return {"jsonrpc": "2.0",
|
||||
"method":"textDocument/publishDiagnostics",
|
||||
|
|
@ -47,13 +47,29 @@ as map(*){
|
|||
declare function lsp-diags:parse-error($text as xs:string, $xml as element(ERROR))
|
||||
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)),
|
||||
1,
|
||||
$lsp-diags:severities('error'),
|
||||
$xml/string()),
|
||||
|
||||
lsp-diags:nostic(pos:Range(pos:toPosition($text, $xml/@e +1 ),
|
||||
pos:toPosition($text, string-length($text)-1)),
|
||||
2,
|
||||
$lsp-diags:severities('warning'),
|
||||
"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")
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue