summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-12 13:16:58 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-12 13:16:58 +0800
commit882c3cf491e9449cbfb0d24f3f556fde313fb7ea (patch)
tree9a12486bbd64a02ff292e8434b2bc088c5a57659 /server
parent15315a7214ba58207d3f5128785ab0937882dd19 (diff)
downloadlua-language-server-882c3cf491e9449cbfb0d24f3f556fde313fb7ea.zip
修正文件符号的一些问题
Diffstat (limited to 'server')
-rw-r--r--server/src/core/document_symbol.lua35
1 files changed, 33 insertions, 2 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua
index fdd34360..404afed7 100644
--- a/server/src/core/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -31,6 +31,27 @@ local SymbolKind = {
TypeParameter = 26,
}
+local function isFirstSet(source, value)
+ if source:action() ~= 'set' then
+ return false
+ end
+ local firstSet = value:eachInfo(function (info)
+ if info.type == 'set' then
+ return info
+ end
+ end)
+ if not firstSet then
+ return false
+ end
+ if firstSet.type ~= 'set' then
+ return false
+ end
+ if firstSet.source ~= source then
+ return false
+ end
+ return true
+end
+
local function buildLocal(vm, source, callback)
local loc = source:bindLocal()
local value = loc:getInitValue()
@@ -98,7 +119,7 @@ local function buildSet(vm, source, callback)
elseif source:get 'table index' then
kind = SymbolKind.Class
else
- return
+ kind = SymbolKind.Property
end
local valueSource = value.source
if valueSource.start == 0 or value.uri ~= vm.uri then
@@ -121,7 +142,7 @@ local function buildSet(vm, source, callback)
selectionRange = { source.start, source.finish },
valueRange = { valueSource.start, valueSource.finish },
}
- else
+ elseif isFirstSet(source, value) then
callback {
name = name,
-- 前端不支持多行
@@ -131,6 +152,16 @@ local function buildSet(vm, source, callback)
selectionRange = { source.start, source.finish },
valueRange = { valueSource.start, valueSource.finish },
}
+ else
+ callback {
+ name = name,
+ -- 前端不支持多行
+ detail = hvr.label:gsub('[\r\n]', ''),
+ kind = kind,
+ range = { source.start, source.finish },
+ selectionRange = { source.start, source.finish },
+ valueRange = { source.start, source.finish },
+ }
end
end