diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-12-16 15:56:24 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-12-16 15:56:24 +0800 |
commit | abb5d1339f638e78bde32707261b2f255b64c9c1 (patch) | |
tree | 28bd5cfe43ceff38e941bd8b0e770c935fdd6edf /script | |
parent | 72a4342c054851b19b6b82105d34c2184414cd60 (diff) | |
download | lua-language-server-abb5d1339f638e78bde32707261b2f255b64c9c1.zip |
cleanup
Diffstat (limited to 'script')
-rw-r--r-- | script/core/diagnostics/assign-type-mismatch.lua | 2 | ||||
-rw-r--r-- | script/core/diagnostics/cast-local-type.lua | 2 | ||||
-rw-r--r-- | script/core/diagnostics/cast-type-mismatch.lua | 2 | ||||
-rw-r--r-- | script/core/signature.lua | 2 | ||||
-rw-r--r-- | script/vm/compiler.lua | 6 | ||||
-rw-r--r-- | script/vm/node.lua | 18 |
6 files changed, 9 insertions, 23 deletions
diff --git a/script/core/diagnostics/assign-type-mismatch.lua b/script/core/diagnostics/assign-type-mismatch.lua index 566f4a27..8472e87c 100644 --- a/script/core/diagnostics/assign-type-mismatch.lua +++ b/script/core/diagnostics/assign-type-mismatch.lua @@ -61,7 +61,7 @@ return function (uri, callback) await.delay() if source.type == 'setlocal' then local locNode = vm.compileNode(source.node) - if not locNode:getData 'hasDefined' then + if not locNode.hasDefined then return end end diff --git a/script/core/diagnostics/cast-local-type.lua b/script/core/diagnostics/cast-local-type.lua index 1b1c8432..1998b915 100644 --- a/script/core/diagnostics/cast-local-type.lua +++ b/script/core/diagnostics/cast-local-type.lua @@ -18,7 +18,7 @@ return function (uri, callback) end await.delay() local locNode = vm.compileNode(loc) - if not locNode:getData 'hasDefined' then + if not locNode.hasDefined then return end for _, ref in ipairs(loc.ref) do diff --git a/script/core/diagnostics/cast-type-mismatch.lua b/script/core/diagnostics/cast-type-mismatch.lua index c0483459..b2d2bdf3 100644 --- a/script/core/diagnostics/cast-type-mismatch.lua +++ b/script/core/diagnostics/cast-type-mismatch.lua @@ -22,7 +22,7 @@ return function (uri, callback) local loc = defs[1] if loc then local defNode = vm.compileNode(loc) - if defNode:getData 'hasDefined' then + if defNode.hasDefined then for _, cast in ipairs(doc.casts) do if not cast.mode and cast.extends then local refNode = vm.compileNode(cast.extends) diff --git a/script/core/signature.lua b/script/core/signature.lua index 3465fda2..63b0cd0d 100644 --- a/script/core/signature.lua +++ b/script/core/signature.lua @@ -134,7 +134,7 @@ local function makeSignatures(text, call, pos) local signs = {} local node = vm.compileNode(func) ---@type vm.node - node = node:getData 'originNode' or node + node = node.originNode or node local mark = {} for src in node:eachObject() do if (src.type == 'function' and not vm.isVarargFunctionWithOverloads(src)) diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 0bac71af..f16cadd8 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -538,7 +538,7 @@ local function matchCall(source) if needRemove then local newNode = myNode:copy() newNode:removeNode(needRemove) - newNode:setData('originNode', myNode) + newNode.originNode = myNode vm.setNode(source, newNode, true) end end @@ -1043,7 +1043,7 @@ local function compileLocal(source) end end - myNode:setData('hasDefined', hasMarkDoc or hasMarkParam or hasMarkValue) + myNode.hasDefined = hasMarkDoc or hasMarkParam or hasMarkValue end ---@param source parser.object @@ -1187,7 +1187,7 @@ local compilerSwitch = util.switch() end local valueNode = vm.compileNode(source.value) vm.setNode(source, valueNode) - if locNode:getData 'hasDefined' + if locNode.hasDefined and guide.isLiteral(source.value) then vm.setNode(source, locNode) vm.getNode(source):narrow(guide.getUri(source), source.value.type) diff --git a/script/vm/node.lua b/script/vm/node.lua index 2e408128..65d752df 100644 --- a/script/vm/node.lua +++ b/script/vm/node.lua @@ -20,7 +20,8 @@ mt.id = 0 mt.type = 'vm.node' mt.optional = nil mt.data = nil -mt.resolved = nil +mt.hasDefined = nil +mt.originNode = nil ---@param node vm.node | vm.node.object ---@return vm.node @@ -70,21 +71,6 @@ function mt:get(n) return self[n] end -function mt:setData(k, v) - if not self.data then - self.data = {} - end - self.data[k] = v -end - ----@return any -function mt:getData(k) - if not self.data then - return nil - end - return self.data[k] -end - function mt:addOptional() self.optional = true end |