[add] fn completion
This commit is contained in:
parent
9894581d19
commit
24082ad97b
15 changed files with 123 additions and 56 deletions
|
|
@ -1,22 +1,28 @@
|
|||
module namespace comp = 'lsp-completions';
|
||||
import module namespace lspt = 'lsp-typedefs' at "../lsp-typedefs.xqm";
|
||||
import module namespace ctx="lsp/context" at "../context.xqm";
|
||||
|
||||
|
||||
(: (:{"triggerCharacter":":","triggerKind":2.0e0}:):)
|
||||
declare function comp:list($context as map(*))
|
||||
as lspt:CompletionItem*{
|
||||
as lspt:CompletionItem*
|
||||
{
|
||||
message($context,"context: "),
|
||||
(1 to 20)!lspt:CompletionItem("item"||.,.)
|
||||
ctx:functions("fn")!ctx:map(.)=>trace("aaa")
|
||||
};
|
||||
|
||||
declare function comp:dummy($context as map(*))
|
||||
as lspt:CompletionItem*{
|
||||
as lspt:CompletionItem*
|
||||
{
|
||||
message($context,"context: "),
|
||||
map:for-each(
|
||||
$lspt:CompletionItemKindMap,
|
||||
fn($k,$v){
|
||||
let $d:=lspt:MarkupContent(
|
||||
'markdown',
|
||||
'[path](https://quodatum.github.io/basex-xqparse/i-BaseX.xhtml#EQName)'
|
||||
`More about
|
||||
<a href="https://quodatum.github.io/basex-xqparse/i-BaseX.xhtml#EQName" target="_blank">{$k}</a>
|
||||
`
|
||||
)
|
||||
return lspt:CompletionItem($k,$v,detail:="detail",documentation:=$d)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ as lspt:DocumentSymbol*{
|
|||
return $result?result
|
||||
};
|
||||
|
||||
(: for testing only:)
|
||||
declare function syms:dummy($parse as element(),$text as xs:string )
|
||||
as lspt:DocumentSymbol*{
|
||||
let $fr:=(pos:full-range($text),message("dummy"))
|
||||
|
|
@ -38,7 +39,7 @@ as hnd:Result{
|
|||
|
||||
declare function syms:VarDecl($parse as element(VarDecl),$state as hnd:Result )
|
||||
as hnd:Result{
|
||||
let $name:=$parse/VarNameAndType/EQName
|
||||
let $name:=syms:localName($parse/VarNameAndType/EQName)
|
||||
let $length:=string($parse)=>string-length()
|
||||
let $range:=lspt:Range(lspt:Position(0,0),lspt:Position(0,3))
|
||||
let $sym:=lspt:DocumentSymbol($name,$lspt:SymbolKindMap('Variable'),$range,$range,"TODO")
|
||||
|
|
@ -47,11 +48,17 @@ as hnd:Result{
|
|||
|
||||
declare function syms:FunctionDecl($parse as element(FunctionDecl),$state as hnd:Result )
|
||||
as hnd:Result{
|
||||
let $name:=$parse/UnreservedFunctionEQName
|
||||
let $name:=syms:localName($parse/UnreservedFunctionEQName)
|
||||
let $range:=lspt:Range(lspt:Position(0,0),lspt:Position(0,3))
|
||||
let $sym:=lspt:DocumentSymbol($name,$lspt:SymbolKindMap('Method'),$range,$range,"TODO")
|
||||
return ($state?result,$sym)=>hnd:Result(true())
|
||||
};
|
||||
|
||||
|
||||
|
||||
declare function syms:localName($name as xs:string )
|
||||
as xs:string{
|
||||
if(starts-with($name,"Q{"))
|
||||
then substring-after($name,"}")
|
||||
else if(contains($name,":"))
|
||||
then substring-after($name,":")
|
||||
else $name
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ declare function hov:list($uri, $pos as map(*))
|
|||
as xs:string*{
|
||||
let $word:="TODO"
|
||||
return `Hover { pos:ln-col($pos) }, uri: {$uri},
|
||||
[path](https://quodatum.github.io/basex-xqparse/i-BaseX.xhtml#EQName)
|
||||
<a href="https://quodatum.github.io/basex-xqparse/i-BaseX.xhtml#EQName" target="_blank">Path</a>
|
||||
|
||||
WordAt: {$word}`
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue