diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-25 11:29:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-25 11:29:35 +0800 |
commit | 35772e7b833f352a7a36a95b2f6a0486f8738fc3 (patch) | |
tree | 50d558b53c64bee0e01e4866143cab435b783a59 | |
parent | 8b77f43aa98eb8d20dc61ddc382338bc940cc0ea (diff) | |
download | lua-language-server-35772e7b833f352a7a36a95b2f6a0486f8738fc3.zip |
不再暴力合并变量或值
-rw-r--r-- | server/src/core/value.lua | 3 | ||||
-rw-r--r-- | server/src/core/vm.lua | 22 |
2 files changed, 8 insertions, 17 deletions
diff --git a/server/src/core/value.lua b/server/src/core/value.lua index a8b054b5..632f6cd4 100644 --- a/server/src/core/value.lua +++ b/server/src/core/value.lua @@ -100,7 +100,7 @@ function mt:eachField(callback) end end -function mt:addInfo(tp, source) +function mt:addInfo(tp, source, var) if source and not source.start then error('Miss start: ' .. table.dump(source)) end @@ -114,6 +114,7 @@ function mt:addInfo(tp, source) self._info[uri][#self._info[uri]+1] = { type = tp, source = source or DefaultSource, + var = var, } return self end diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua index 6f3a9991..61314add 100644 --- a/server/src/core/vm.lua +++ b/server/src/core/vm.lua @@ -144,13 +144,14 @@ function mt:scopePop() self.scope:pop() end -function mt:addInfo(obj, type, source) +function mt:addInfo(obj, type, source, value) if source and not source.start then error('Miss start: ' .. table.dump(source)) end obj[#obj+1] = { type = type, source = source or DefaultSource, + value = value, } if source then source.uri = self.uri @@ -331,23 +332,12 @@ function mt:setValue(var, value, source) if value and value.type == 'list' then error('Cant set value list') end - value = value or self:createValue('any', source) + value = value or self:createValue('nil', source) if source and source.start then - self:addInfo(var, 'set', source) - value:addInfo('set', source) - end - if var.value then - if value:getType() == 'any' then - self:mergeChild(var.value, value) - elseif value:getType() == 'nil' then - self:mergeValue(var.value, value) - elseif var.value.uri == self.uri then - var.value = value - end - value = var.value - else - var.value = value + self:addInfo(var, 'set', source, value) + value:addInfo('set', source, var) end + var.value = value return value end |