diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/definition.lua | 12 | ||||
-rw-r--r-- | server/src/matcher/vm.lua | 21 | ||||
-rw-r--r-- | server/test/main.lua | 2 |
3 files changed, 17 insertions, 18 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index e8cfe4c0..57e4b237 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -10,21 +10,11 @@ local function parseResult(result) end end elseif tp == 'field' then - local mark = {} for _, info in ipairs(result.object) do - if info.type == 'set' and not mark[info.source] then - mark[info.source] = true + if info.type == 'set' then positions[#positions+1] = {info.source.start, info.source.finish} end end - if result.object.value then - for _, info in ipairs(result.object.value) do - if info.type == 'set' and not mark[info.source] then - mark[info.source] = true - positions[#positions+1] = {info.source.start, info.source.finish} - end - end - end elseif tp == 'label' then for _, info in ipairs(result.object) do if info.type == 'set' then 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 diff --git a/server/test/main.lua b/server/test/main.lua index c16346c9..c5f57ced 100644 --- a/server/test/main.lua +++ b/server/test/main.lua @@ -27,7 +27,7 @@ local function main() test 'compile' --test 'type_inference' test 'definition' - test 'find_lib' + --test 'find_lib' print('测试完成') end |