summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-21 16:07:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-21 16:07:21 +0800
commit70da60a80f2d00c235560f235d3f5ded703dfe4e (patch)
treeb4bcba29ccdade33d14dd6a636f646f2c1dd280f /server/src
parent0c5c97f10baba4cfbfb2f7e7de3503ff239004ba (diff)
downloadlua-language-server-70da60a80f2d00c235560f235d3f5ded703dfe4e.zip
还是要用merge,否则child的引用会丢失
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/vm.lua34
1 files changed, 2 insertions, 32 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 647b99c3..413b9291 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -35,24 +35,6 @@ local function orderTable()
})
end
-local function deepCopy(t, mark, new)
- mark = mark or {}
- new = new or orderTable()
- for k, v in pairs(t) do
- if type(v) == 'table' then
- if mark[v] then
- new[k] = mark[v]
- else
- mark[v] = orderTable()
- new[k] = deepCopy(v, mark, mark[v])
- end
- else
- new[k] = v
- end
- end
- return new
-end
-
local mt = {}
mt.__index = mt
@@ -189,18 +171,6 @@ function mt:buildTable(source)
return tbl
end
-function mt:coverValue(a, b)
- if a == b then
- return
- end
- for k in pairs(a) do
- a[k] = nil
- end
- for k, v in pairs(b) do
- a[k] = v
- end
-end
-
function mt:mergeValue(a, b, mark)
if a == b then
return
@@ -1263,7 +1233,7 @@ function mt:mergeRequire(value, strValue, destVM)
else
mainValue = main.returns[1]
end
- self:coverValue(value, mainValue)
+ self:mergeValue(value, mainValue)
-- 支持 require 'xxx' 的转到定义
local strSource = strValue.source
@@ -1276,7 +1246,7 @@ function mt:mergeLoadFile(value, strValue, destVM)
local main = destVM.results.main
-- loadfile 的返回值就是对方的主函数
local mainValue = main
- self:coverValue(value, mainValue)
+ self:mergeValue(value, mainValue)
-- 支持 loadfile 'xxx.lua' 的转到定义
local strSource = strValue.source