summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-10-23 15:45:34 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-10-23 15:45:34 +0800
commitbb337bbf6c62076de5425966ea41b3cbed6bb987 (patch)
treef7c4aa47e91464d19a78bfecf45ae979a4447aab /script-beta/core
parent465810453208d3af395bc43f4f27791237c5cfdc (diff)
downloadlua-language-server-bb337bbf6c62076de5425966ea41b3cbed6bb987.zip
匿名函数信息更加详细
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/document-symbol.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/script-beta/core/document-symbol.lua b/script-beta/core/document-symbol.lua
index 8c606723..d7eb59ea 100644
--- a/script-beta/core/document-symbol.lua
+++ b/script-beta/core/document-symbol.lua
@@ -176,14 +176,23 @@ local function buildSet(source, text, used, symbols)
end
end
-local function buildAnonymousFunction(source, used, symbols)
+local function buildAnonymousFunction(source, text, used, symbols)
if used[source] then
return
end
used[source] = true
+ local head = ''
+ local parent = source.parent
+ if parent.type == 'return' then
+ head = 'return '
+ elseif parent.type == 'callargs' then
+ local call = parent.parent
+ local node = call.node
+ head = buildName(node, text) .. ' -> '
+ end
symbols[#symbols+1] = {
name = '',
- detail = 'function ()',
+ detail = ('%sfunction (%s)'):format(head, buildFunctionParams(source)),
kind = define.SymbolKind.Function,
range = { source.start, source.finish },
selectionRange = { source.start, source.start },
@@ -202,7 +211,7 @@ local function buildSource(source, text, used, symbols)
buildSet(source, text, used, symbols)
elseif source.type == 'function' then
await.delay()
- buildAnonymousFunction(source, used, symbols)
+ buildAnonymousFunction(source, text, used, symbols)
end
end