[mod]
This commit is contained in:
parent
2d99af9389
commit
e9a2d46272
7 changed files with 43 additions and 22 deletions
|
|
@ -81,4 +81,15 @@ as map(*)
|
|||
"method":"window/logMessage",
|
||||
"params":{"type":1, "message": $msg}
|
||||
}
|
||||
};
|
||||
|
||||
(:~ rpc response to $json msg :)
|
||||
declare function rpc:response($result,$json as map(*))
|
||||
as map(*)
|
||||
{
|
||||
map{
|
||||
"jsonrpc": "2.0",
|
||||
"id": $json?id,
|
||||
"result": $result
|
||||
}
|
||||
};
|
||||
|
|
@ -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 array{lsp-diags:parse-xquery($text,$xml)}
|
||||
else array{ lsp-diags:parse-xquery($text,$xml)}
|
||||
|
||||
return {"jsonrpc": "2.0",
|
||||
"method":"textDocument/publishDiagnostics",
|
||||
|
|
@ -55,21 +55,22 @@ lsp-diags:nostic(pos:Range(pos:toPosition($text, $xml/@b),
|
|||
lsp-diags:nostic(pos:Range(pos:toPosition($text, $xml/@e +1 ),
|
||||
pos:toPosition($text, string-length($text)-1)),
|
||||
$lsp-diags:severities('warning'),
|
||||
"Previous parse error")
|
||||
"Unparsed due to previous parser 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(0,0), pos:Position(0, 5)),
|
||||
$lsp-diags:severities('error'),"error"),
|
||||
|
||||
lsp-diags:nostic(pos:Range(pos:Position(1,0), pos:Position(1,5)),
|
||||
$lsp-diags:severities('warning'),"2222"),
|
||||
$lsp-diags:severities('warning'),"warning"),
|
||||
|
||||
lsp-diags:nostic(pos:Range(pos:Position(2,0), pos:Position(2, 5)),
|
||||
$lsp-diags:severities('info'),"333"),
|
||||
$lsp-diags:severities('info'),"info"),
|
||||
|
||||
lsp-diags:nostic(pos:Range(pos:Position(3,0), pos:Position(3, 6)),
|
||||
$lsp-diags:severities('hint'), "hint") :)
|
||||
|
||||
lsp-diags:nostic(pos:Range(pos:Position(3,0), pos:Position(3, 12)),
|
||||
$lsp-diags:severities('hint'), "44")
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@
|
|||
: @author andy bunce
|
||||
:)
|
||||
module namespace lsp-text = 'lsp-text';
|
||||
|
||||
import module namespace docs="lsp/docs" at "docs.xqm";
|
||||
import module namespace rpc = 'rpc' at 'jsonrpc.xqm';
|
||||
import module namespace pos="lsp/position" at "position.xqm";
|
||||
|
||||
declare variable $lsp-text:methods:=map{
|
||||
"textDocument/didOpen": lsp-text:didOpen#1,
|
||||
|
|
@ -21,24 +23,21 @@ declare
|
|||
function lsp-text:hover($json as map(*))
|
||||
as map(*)
|
||||
{
|
||||
map{
|
||||
"jsonrpc": "2.0",
|
||||
"id": $json?id,
|
||||
"result":{
|
||||
"contents": [
|
||||
|
||||
let $r:= [
|
||||
`markdown here, this is **bold**.
|
||||
|
||||
A [link](http://google.com)
|
||||
|
||||
The last line.`
|
||||
,
|
||||
`A hover at \\n\\n{ json:serialize($json?params?position) }
|
||||
`A hover at { pos:ln-col($json?params?position) }
|
||||
uri: {$json?params?textDocument?uri} `
|
||||
]
|
||||
}
|
||||
}
|
||||
return rpc:response($r,$json)
|
||||
};
|
||||
|
||||
|
||||
declare
|
||||
function lsp-text:completion($json as map(*))
|
||||
as map(*)?
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@ declare record pos:Range(
|
|||
end as pos:Position
|
||||
);
|
||||
|
||||
(:~ update $text with changes $chs from didChange
|
||||
:)
|
||||
declare function pos:apply-changes($text as xs:string, $chs as array(*))
|
||||
as xs:string{
|
||||
array:fold-left($chs,$text,pos:apply-change#2)
|
||||
};
|
||||
|
||||
(:~ text updated with $ch changes from didChange :)
|
||||
(:~ text updated single change :)
|
||||
declare function pos:apply-change($text as xs:string, $ch as map(*))
|
||||
as xs:string{
|
||||
if(exists($ch?range))
|
||||
|
|
@ -83,4 +85,8 @@ as xs:integer
|
|||
fn($r){$r?max eq $r?min}
|
||||
)
|
||||
return $s?max
|
||||
};
|
||||
};
|
||||
|
||||
declare function pos:ln-col($pos as pos:Position){
|
||||
`Ln { $pos?line}, Col { $pos?character}`
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue