summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-05-30 15:54:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-05-30 15:54:13 +0800
commit245c99bb1ca69dab538c3106b640a478f963d6ed (patch)
treeac94261beaf5ca526316fbe9223057c1da518fe5 /script-beta
parentfee8530cfa83c11e76def4f2ab891a9a7cb25c81 (diff)
downloadlua-language-server-245c99bb1ca69dab538c3106b640a478f963d6ed.zip
整理代码
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/hover/label.lua6
-rw-r--r--script-beta/vm/eachDef.lua4
-rw-r--r--script-beta/vm/getValue.lua15
3 files changed, 17 insertions, 8 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index 58189755..942abe20 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -19,11 +19,11 @@ local function asValue(source, title)
local name = buildName(source)
local class, type, literal, cont
vm.eachDef(source, function (src)
- class = vm.mergeViews(vm.getClass(src), class)
- type = vm.mergeViews(vm.getType(src), type)
+ class = vm.mergeViews(class, vm.getClass(src))
+ type = vm.mergeViews(type, vm.getType(src))
local sl = vm.getLiteral(src)
if sl then
- literal = vm.mergeViews(util.viewLiteral(sl), literal)
+ literal = vm.mergeViews(literal, util.viewLiteral(sl))
end
if type == 'table' then
cont = buildTable(source)
diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua
index e30e3b51..2f29aa83 100644
--- a/script-beta/vm/eachDef.lua
+++ b/script-beta/vm/eachDef.lua
@@ -3,10 +3,14 @@ local guide = require 'parser.guide'
local function eachDef(source)
local lib = vm.getLibrary(source)
+ local value = guide.getObjectValue(source)
local results = guide.requestDefinition(source)
if lib then
results[#results+1] = lib
end
+ if value then
+ results[#results+1] = value
+ end
return results
end
diff --git a/script-beta/vm/getValue.lua b/script-beta/vm/getValue.lua
index d091bf32..b0361df7 100644
--- a/script-beta/vm/getValue.lua
+++ b/script-beta/vm/getValue.lua
@@ -2,6 +2,7 @@ local vm = require 'vm.vm'
local util = require 'utility'
local guide = require 'parser.guide'
local library = require 'library'
+local select = select
local typeSort = {
['boolean'] = 1,
@@ -952,12 +953,16 @@ function vm.viewType(values)
end
function vm.mergeViews(...)
+ local max = select('#', ...)
local views = {}
- for _, view in ipairs {...} do
- for tp in view:gmatch '[^|]+' do
- if not views[tp] and tp ~= 'any' then
- views[tp] = true
- views[#views+1] = tp
+ for i = 1, max do
+ local view = select(i, ...)
+ if view then
+ for tp in view:gmatch '[^|]+' do
+ if not views[tp] and tp ~= 'any' then
+ views[tp] = true
+ views[#views+1] = tp
+ end
end
end
end