summaryrefslogtreecommitdiff
path: root/script/vm/node.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-22 03:18:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-22 03:18:35 +0800
commit7881d1a3d91b59d2dd8c28a72453e0e6c44a902f (patch)
tree6c2466f3676d813ac9db469815f4af9834d1711a /script/vm/node.lua
parentb85ff57a116fb252a0da35e525264e0940af88c7 (diff)
downloadlua-language-server-7881d1a3d91b59d2dd8c28a72453e0e6c44a902f.zip
new diagnostic `missing-parameter`
Diffstat (limited to 'script/vm/node.lua')
-rw-r--r--script/vm/node.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 87fcc0c5..92604c3c 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -7,6 +7,7 @@ local ws = require 'workspace.workspace'
vm.nodeCache = {}
---@class vm.node
+---@field [integer] vm.object
local mt = {}
mt.__index = mt
mt.type = 'vm.node'
@@ -85,6 +86,7 @@ function mt:isFalsy()
end
for _, c in ipairs(self) do
if c.type == 'nil'
+ or (c.type == 'global' and c.cate == 'type' and c.name == 'nil')
or (c.type == 'boolean' and c[1] == false)
or (c.type == 'doc.type.boolean' and c[1] == false) then
return true
@@ -93,6 +95,20 @@ function mt:isFalsy()
return false
end
+---@return boolean
+function mt:isNullable()
+ if self.optional then
+ return true
+ end
+ for _, c in ipairs(self) do
+ if c.type == 'nil'
+ or (c.type == 'global' and c.cate == 'type' and c.name == 'nil') then
+ return true
+ end
+ end
+ return false
+end
+
---@return vm.node
function mt:copyTruly()
local newNode = vm.createNode()