[add] symbols
This commit is contained in:
parent
17d440865e
commit
47b49c36f4
2 changed files with 69 additions and 7 deletions
64
webapp/lsp/documentSymbols.xqm
Normal file
64
webapp/lsp/documentSymbols.xqm
Normal file
|
@ -0,0 +1,64 @@
|
|||
xquery version '4.0';
|
||||
(:~ Symbols from XQuery source file :)
|
||||
module namespace syms="lsp/symbols";
|
||||
import module namespace pos="lsp/position" at "position.xqm";
|
||||
declare type syms:SymbolKind as xs:integer;
|
||||
declare type syms:SymbolTag as xs:string;
|
||||
|
||||
declare variable $syms:SymbolKindMap :={
|
||||
'File': 1 ,
|
||||
'Module': 2 ,
|
||||
'Namespace': 3 ,
|
||||
'Package': 4 ,
|
||||
'Class': 5 ,
|
||||
'Method': 6 ,
|
||||
'Property': 7 ,
|
||||
'Field': 8 ,
|
||||
'Constructor': 9 ,
|
||||
'Enum': 10 ,
|
||||
'Interface': 11 ,
|
||||
'Function': 12 ,
|
||||
'Variable': 13 ,
|
||||
'Constant': 14 ,
|
||||
'String': 15 ,
|
||||
'Number': 16 ,
|
||||
'Boolean': 17 ,
|
||||
'Array': 18 ,
|
||||
'Object': 19 ,
|
||||
'Key': 20 ,
|
||||
'Null': 21 ,
|
||||
'EnumMember': 22 ,
|
||||
'Struct': 23 ,
|
||||
'Event': 24 ,
|
||||
'Operator': 25 ,
|
||||
'TypeParameter': 26
|
||||
};
|
||||
|
||||
declare record syms:DocumentSymbol(
|
||||
(: The name of this symbol. Will be displayed in the user interface and
|
||||
therefore must not be an empty string or a string only consisting of white spaces.
|
||||
:)
|
||||
name as xs:string,
|
||||
|
||||
(: The kind of this symbol. :)
|
||||
kind as syms:SymbolKind,
|
||||
|
||||
(:
|
||||
* The range enclosing this symbol not including leading/trailing whitespace
|
||||
* but everything else like comments. This information is typically used to
|
||||
* determine if the clients cursor is inside the symbol to reveal it in the
|
||||
* UI. :)
|
||||
range as pos:Range,
|
||||
|
||||
(:The range that should be selected and revealed when this symbol is being
|
||||
* picked, e.g. the name of a function. Must be contained by the `range`. :)
|
||||
selectionRange as pos:Range,
|
||||
(: More detail for this symbol, e.g the signature of a function.:)
|
||||
detail? as xs:string,
|
||||
|
||||
(: Tags for this document symbol. @since 3.16.0 :)
|
||||
tags? as syms:SymbolTag*,
|
||||
|
||||
(: Children of this symbol, e.g. properties of a class. :)
|
||||
children? as syms:DocumentSymbol*
|
||||
);
|
|
@ -58,11 +58,9 @@ as map(*)?
|
|||
then rpc:error("Syntax errors found.",$json)
|
||||
else
|
||||
let $xml:=$xml update {lsp-text:tidy(.)}
|
||||
let $fmt:=`(: formatting to do :)
|
||||
`
|
||||
return rpc:result([{
|
||||
"range":pos:full-range($text),
|
||||
"newText": $fmt || string($xml)
|
||||
"newText": string($xml)
|
||||
}],$json)
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue