diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-17 04:29:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-17 04:29:18 +0800 |
commit | a988a48919dd752b04ec692d90e942ba21e9f62f (patch) | |
tree | 4a456948c2baae13aa4269503bc96bd892412657 /script | |
parent | fbb028fa8ac1c1d146e4e6aecda03442af9ddee8 (diff) | |
download | lua-language-server-a988a48919dd752b04ec692d90e942ba21e9f62f.zip |
cleanup
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/node.lua | 89 |
1 files changed, 4 insertions, 85 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua index 6ef7c9d5..0cb5e0f9 100644 --- a/script/vm/node.lua +++ b/script/vm/node.lua @@ -13,9 +13,6 @@ mt.type = 'vm.node' mt.optional = nil mt.lastInfer = nil mt.data = nil ----@type vm.node[] -mt._childs = nil -mt._locked = false ---@param node vm.node | vm.object function mt:merge(node) @@ -29,20 +26,10 @@ function mt:merge(node) if node:isOptional() then self.optional = true end - if node._locked then - if not self._childs then - self._childs = {} - end - if not self._childs[node] then - self._childs[#self._childs+1] = node - self._childs[node] = true - end - else - for _, obj in ipairs(node) do - if not self[obj] then - self[obj] = true - self[#self+1] = obj - end + for _, obj in ipairs(node) do + if not self[obj] then + self[obj] = true + self[#self+1] = obj end end else @@ -53,84 +40,17 @@ function mt:merge(node) end end -function mt:_each(mark, callback) - if mark[self] then - return - end - mark[self] = true - for i = 1, #self do - callback(self[i]) - end - local childs = self._childs - if not childs then - return - end - for i = 1, #childs do - local child = childs[i] - if not child:isLocked() then - child:_each(mark, callback) - end - end -end - -function mt:_expand() - local childs = self._childs - if not childs then - return - end - self._childs = nil - - local mark = {} - mark[self] = true - - local function insert(obj) - if not self[obj] then - self[obj] = true - self[#self+1] = obj - end - end - - for i = 1, #childs do - local child = childs[i] - if child:isLocked() then - if not self._childs then - self._childs = {} - end - if not self._childs[child] then - self._childs[#self._childs+1] = child - self._childs[child] = true - end - else - child:_each(mark, insert) - end - end -end - ---@return boolean function mt:isEmpty() - self:_expand() return #self == 0 end ---@param n integer ---@return vm.object? function mt:get(n) - self:_expand() return self[n] end -function mt:lock() - self._locked = true -end - -function mt:unlock() - self._locked = false -end - -function mt:isLocked() - return self._locked == true -end - function mt:setData(k, v) if not self.data then self.data = {} @@ -175,7 +95,6 @@ end ---@return fun():vm.object function mt:eachObject() - self:_expand() local i = 0 return function () i = i + 1 |