feat(parser): Support SymbolInformation[]
-- https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol Some lsp like vuels, pyls etc dont support the newer DocumentSymbol[] data structure so add minimal support for the old way. This is not hierarchical so not really a tree Addresses #13
This commit is contained in:
@@ -33,16 +33,28 @@ function M.parse(result, depth, heirarchy)
|
|||||||
children = M.parse(value.children, level + 1, child_hir)
|
children = M.parse(value.children, level + 1, child_hir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- support SymbolInformation[]
|
||||||
|
-- https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol
|
||||||
|
local selectionRange = value.selectionRange
|
||||||
|
if value.selectionRange == nil then
|
||||||
|
selectionRange = value.location.range
|
||||||
|
end
|
||||||
|
|
||||||
|
local range = value.range
|
||||||
|
if value.range == nil then
|
||||||
|
range = value.location.range
|
||||||
|
end
|
||||||
|
|
||||||
table.insert(ret, {
|
table.insert(ret, {
|
||||||
deprecated = value.deprecated,
|
deprecated = value.deprecated,
|
||||||
kind = value.kind,
|
kind = value.kind,
|
||||||
icon = symbols.icon_from_kind(value.kind),
|
icon = symbols.icon_from_kind(value.kind),
|
||||||
name = value.name,
|
name = value.name,
|
||||||
detail = value.detail,
|
detail = value.detail,
|
||||||
line = value.selectionRange.start.line,
|
line = selectionRange.start.line,
|
||||||
range_start = value.range.start.line,
|
character = selectionRange.start.character,
|
||||||
range_end = value.range["end"].line,
|
range_start = range.start.line,
|
||||||
character = value.selectionRange.start.character,
|
range_end = range["end"].line,
|
||||||
children = children,
|
children = children,
|
||||||
depth = level,
|
depth = level,
|
||||||
isLast = isLast,
|
isLast = isLast,
|
||||||
|
|||||||
Reference in New Issue
Block a user