diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-05 16:07:34 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-07-05 16:07:34 +0800 |
commit | 6b882c908d4981949ed2d894e50501d7734d41bd (patch) | |
tree | e533d95671af4d287c7b565b31c79c4e56a5d056 /script | |
parent | e711f30dbcf840e8adec49a78d734d1a0306934b (diff) | |
download | lua-language-server-6b882c908d4981949ed2d894e50501d7734d41bd.zip |
cleanup
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/node.lua | 13 | ||||
-rw-r--r-- | script/vm/type.lua | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua index 5d8bcd75..fdd9a2c0 100644 --- a/script/vm/node.lua +++ b/script/vm/node.lua @@ -227,7 +227,7 @@ function mt:remove(name) or (c.type == 'doc.type.boolean' and name == 'false' and c[1] == false) or (c.type == 'doc.type.table' and name == 'table') or (c.type == 'doc.type.array' and name == 'table') - or (c.type == 'doc.type.sign' and name == 'table') + or (c.type == 'doc.type.sign' and name == c.node[1]) or (c.type == 'doc.type.function' and name == 'function') then table.remove(self, index) self[c] = nil @@ -248,7 +248,7 @@ function mt:narrow(name) or (c.type == 'doc.type.boolean' and name == 'boolean') or (c.type == 'doc.type.table' and name == 'table') or (c.type == 'doc.type.array' and name == 'table') - or (c.type == 'doc.type.sign' and name == 'table') + or (c.type == 'doc.type.sign' and name == c.node[1]) or (c.type == 'doc.type.function' and name == 'function') then goto CONTINUE end @@ -337,10 +337,15 @@ function mt:asTable() local c = self[index] if c.type == 'table' or c.type == 'doc.type.table' - or c.type == 'doc.type.array' - or c.type == 'doc.type.sign' then + or c.type == 'doc.type.array' then goto CONTINUE end + if c.type == 'doc.type.sign' then + if c.node[1] == 'table' + or not guide.isBasicType(c.node[1]) then + goto CONTINUE + end + end if c.type == 'global' and c.cate == 'type' then ---@cast c vm.global if c.name == 'table' diff --git a/script/vm/type.lua b/script/vm/type.lua index e673b2b6..59663b6b 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -259,16 +259,16 @@ end ---@param uri uri ---@param tnode vm.node ---@param vnode vm.node|string|vm.object ----@param inversion? boolean +---@param reverse? boolean ---@return vm.node? -function vm.getTableKey(uri, tnode, vnode, inversion) +function vm.getTableKey(uri, tnode, vnode, reverse) local result = vm.createNode() for tn in tnode:eachObject() do if tn.type == 'doc.type.table' then for _, field in ipairs(tn.fields) do if field.name.type ~= 'doc.field.name' and field.extends then - if inversion then + if reverse then if vm.isSubType(uri, vm.compileNode(field.extends), vnode) then result:merge(vm.compileNode(field.name)) end |