summaryrefslogtreecommitdiff
path: root/server/src/matcher/vm.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-11 20:18:02 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-11 20:18:02 +0800
commit33bf4c53397253fa3ce643e88fcdd05faf005617 (patch)
treef56852cfc7fc47fa1e7730d286de3928ec6a58f7 /server/src/matcher/vm.lua
parentfebe2ee50eb8f13063e0e2f04bd40bbf38073a30 (diff)
downloadlua-language-server-33bf4c53397253fa3ce643e88fcdd05faf005617.zip
整理代码
Diffstat (limited to 'server/src/matcher/vm.lua')
-rw-r--r--server/src/matcher/vm.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index f090d502..d84f9062 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -96,10 +96,6 @@ function mt:mergeValue(a, b, mark)
end
mark[a] = true
mark[b] = true
- for i, info in ipairs(a) do
- a[i] = nil
- b[#b+1] = info
- end
self:mergeChild(a, b, mark)
for k in pairs(a) do
a[k] = nil
@@ -109,6 +105,20 @@ function mt:mergeValue(a, b, mark)
end
end
+function mt:mergeField(a, b, mark)
+ if not mark then
+ mark = {}
+ end
+ for i, info in ipairs(a) do
+ a[i] = nil
+ b[#b+1] = info
+ end
+ for i, v in ipairs(b) do
+ a[i] = v
+ end
+ self:mergeValue(a.value, b.value, mark)
+end
+
function mt:mergeChild(a, b, mark)
if not a.child and not b.child then
return
@@ -122,7 +132,7 @@ function mt:mergeChild(a, b, mark)
b.child = nil
for k, v in pairs(other) do
if child[k] then
- self:mergeValue(v.value, child[k].value, mark)
+ self:mergeField(v, child[k], mark)
else
child[k] = v
end
@@ -146,7 +156,6 @@ function mt:setValue(var, value, source)
end
if source and source.start then
self:addInfo(var, 'set', source)
- self:addInfo(value, 'set', source)
end
return value
end