Skip to content

Commit abb5d13

Browse files
committed
cleanup
1 parent 72a4342 commit abb5d13

File tree

6 files changed

+9
-23
lines changed

6 files changed

+9
-23
lines changed

script/core/diagnostics/assign-type-mismatch.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ return function (uri, callback)
6161
await.delay()
6262
if source.type == 'setlocal' then
6363
local locNode = vm.compileNode(source.node)
64-
if not locNode:getData 'hasDefined' then
64+
if not locNode.hasDefined then
6565
return
6666
end
6767
end

script/core/diagnostics/cast-local-type.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ return function (uri, callback)
1818
end
1919
await.delay()
2020
local locNode = vm.compileNode(loc)
21-
if not locNode:getData 'hasDefined' then
21+
if not locNode.hasDefined then
2222
return
2323
end
2424
for _, ref in ipairs(loc.ref) do

script/core/diagnostics/cast-type-mismatch.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ return function (uri, callback)
2222
local loc = defs[1]
2323
if loc then
2424
local defNode = vm.compileNode(loc)
25-
if defNode:getData 'hasDefined' then
25+
if defNode.hasDefined then
2626
for _, cast in ipairs(doc.casts) do
2727
if not cast.mode and cast.extends then
2828
local refNode = vm.compileNode(cast.extends)

script/core/signature.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ local function makeSignatures(text, call, pos)
134134
local signs = {}
135135
local node = vm.compileNode(func)
136136
---@type vm.node
137-
node = node:getData 'originNode' or node
137+
node = node.originNode or node
138138
local mark = {}
139139
for src in node:eachObject() do
140140
if (src.type == 'function' and not vm.isVarargFunctionWithOverloads(src))

script/vm/compiler.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ local function matchCall(source)
538538
if needRemove then
539539
local newNode = myNode:copy()
540540
newNode:removeNode(needRemove)
541-
newNode:setData('originNode', myNode)
541+
newNode.originNode = myNode
542542
vm.setNode(source, newNode, true)
543543
end
544544
end
@@ -1043,7 +1043,7 @@ local function compileLocal(source)
10431043
end
10441044
end
10451045

1046-
myNode:setData('hasDefined', hasMarkDoc or hasMarkParam or hasMarkValue)
1046+
myNode.hasDefined = hasMarkDoc or hasMarkParam or hasMarkValue
10471047
end
10481048

10491049
---@param source parser.object
@@ -1187,7 +1187,7 @@ local compilerSwitch = util.switch()
11871187
end
11881188
local valueNode = vm.compileNode(source.value)
11891189
vm.setNode(source, valueNode)
1190-
if locNode:getData 'hasDefined'
1190+
if locNode.hasDefined
11911191
and guide.isLiteral(source.value) then
11921192
vm.setNode(source, locNode)
11931193
vm.getNode(source):narrow(guide.getUri(source), source.value.type)

script/vm/node.lua

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ mt.id = 0
2020
mt.type = 'vm.node'
2121
mt.optional = nil
2222
mt.data = nil
23-
mt.resolved = nil
23+
mt.hasDefined = nil
24+
mt.originNode = nil
2425

2526
---@param node vm.node | vm.node.object
2627
---@return vm.node
@@ -70,21 +71,6 @@ function mt:get(n)
7071
return self[n]
7172
end
7273

73-
function mt:setData(k, v)
74-
if not self.data then
75-
self.data = {}
76-
end
77-
self.data[k] = v
78-
end
79-
80-
---@return any
81-
function mt:getData(k)
82-
if not self.data then
83-
return nil
84-
end
85-
return self.data[k]
86-
end
87-
8874
function mt:addOptional()
8975
self.optional = true
9076
end

0 commit comments

Comments
 (0)