summaryrefslogtreecommitdiff
path: root/server/src/core/document_symbol.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-28 16:57:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-28 16:57:46 +0800
commitebdfb86387f51fd29ec37b6ca586a062b086f525 (patch)
treee7f84d82687c544f14ea484c067fa561f59672bf /server/src/core/document_symbol.lua
parent08ad84a4f6c579a12e7a7e92d438f60c5c360044 (diff)
downloadlua-language-server-ebdfb86387f51fd29ec37b6ca586a062b086f525.zip
支持部分函数写法
Diffstat (limited to 'server/src/core/document_symbol.lua')
-rw-r--r--server/src/core/document_symbol.lua32
1 files changed, 23 insertions, 9 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua
index 4dc0ebac..b67a97db 100644
--- a/server/src/core/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -1,4 +1,5 @@
-local hover = require 'core.hover'
+local hoverFunction = require 'core.hover_function'
+local hoverName = require 'core.hover_name'
local SymbolKind = {
File = 1,
@@ -31,21 +32,34 @@ local SymbolKind = {
local function buildFunc(vm, func, nextFunction, nextFinish)
local source = func.source
- local var = vm.results.sources[source.name] or vm.results.sources[source]
- if not var then
- return
+ local name
+ if source.name then
+ local var = vm.results.sources[source.name]
+ if var then
+ name = hoverName(var, source.name)
+ else
+ name = ''
+ end
+ else
+ name = ''
end
- local hvr = hover(var, source.name or source)
- if not hvr then
+ local hover = hoverFunction(name, func)
+ if not hover then
return
end
+ local selectionRange
+ if source.name then
+ selectionRange = { source.name.start, source.name.finish }
+ else
+ selectionRange = { source.start, source.start }
+ end
return {
- name = hvr.name,
+ name = name,
-- 前端不支持多行
- detail = hvr.label:gsub('[\r\n]', ''),
+ detail = hover.label:gsub('[\r\n]', ''),
kind = SymbolKind.Function,
range = { source.start, source.finish },
- selectionRange = { source.name.start, source.name.finish },
+ selectionRange = selectionRange,
}
end