summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-05-30 15:42:45 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-05-30 15:42:45 +0800
commitfee8530cfa83c11e76def4f2ab891a9a7cb25c81 (patch)
treeba343991d395ef5fc1e963fb4acaecaa1b56e7ef /script-beta/core
parent529440f6a2d642d7df47cf4b5d54d9e538761f7a (diff)
downloadlua-language-server-fee8530cfa83c11e76def4f2ab891a9a7cb25c81.zip
整理代码
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/hover/label.lua37
-rw-r--r--script-beta/core/hover/table.lua2
2 files changed, 19 insertions, 20 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index 63479e6d..58189755 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -17,31 +17,30 @@ end
local function asValue(source, title)
local name = buildName(source)
- local lib = vm.getLibrary(source)
- local class = vm.getClass(source)
- local type = vm.getType(source)
- local literal = vm.getLiteral(source)
- local cont
- if type == 'table' then
- cont = buildTable(source)
- type = nil
- end
- if lib then
- local libName = buildName(lib)
- if name ~= libName then
- name = ('%s<%s>'):format(name, buildName(lib))
+ local class, type, literal, cont
+ vm.eachDef(source, function (src)
+ class = vm.mergeViews(vm.getClass(src), class)
+ type = vm.mergeViews(vm.getType(src), type)
+ local sl = vm.getLiteral(src)
+ if sl then
+ literal = vm.mergeViews(util.viewLiteral(sl), literal)
end
- end
+ if type == 'table' then
+ cont = buildTable(source)
+ end
+ end)
local pack = {}
pack[#pack+1] = title
pack[#pack+1] = name .. ':'
+ if cont then
+ type = nil
+ else
+ type = type or 'any'
+ end
pack[#pack+1] = class or type
if literal then
- local literalView = util.viewLiteral(literal)
- if literalView then
- pack[#pack+1] = '='
- pack[#pack+1] = util.viewLiteral(literal)
- end
+ pack[#pack+1] = '='
+ pack[#pack+1] = literal
end
if cont then
pack[#pack+1] = cont
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua
index 7856c154..d1598f02 100644
--- a/script-beta/core/hover/table.lua
+++ b/script-beta/core/hover/table.lua
@@ -121,7 +121,7 @@ return function (source)
local intValue = true
vm.eachField(source, function (src)
local key, class, literal = getField(src)
- classes[key] = vm.mergeTypeViews(class, classes[key])
+ classes[key] = vm.mergeViews(class, classes[key])
literals[key] = mergeLiteral(literal, literals[key])
if class ~= 'integer'
or not literals[key]