summaryrefslogtreecommitdiff
path: root/script/workspace/scope.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-02-08 19:29:44 +0800
committersumneko <sumneko@hotmail.com>2022-02-08 19:52:17 +0800
commit01fbaf633deb9494c0b72906e71bac9f73b318ae (patch)
tree7cb611771478feeb947ee248d8f681f3ebd16c8e /script/workspace/scope.lua
parent9bce8c2f953d63e7bcb4d847363b5bfd468bd403 (diff)
downloadlua-language-server-01fbaf633deb9494c0b72906e71bac9f73b318ae.zip
cleanup
Diffstat (limited to 'script/workspace/scope.lua')
-rw-r--r--script/workspace/scope.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/script/workspace/scope.lua b/script/workspace/scope.lua
index ab9c3fb9..be112af2 100644
--- a/script/workspace/scope.lua
+++ b/script/workspace/scope.lua
@@ -1,3 +1,5 @@
+local gc = require 'gc'
+
---@alias scope.type '"override"'|'"folder"'|'"fallback"'
---@class scope
@@ -5,6 +7,7 @@
---@field uri? uri
---@field _links table<uri, boolean>
---@field _data table<string, any>
+---@field _gc gc
local mt = {}
mt.__index = mt
@@ -97,6 +100,15 @@ function mt:getName()
return self.uri or ('<' .. self.type .. '>')
end
+function mt:gc(obj)
+ self._gc:add(obj)
+end
+
+function mt:flushGC()
+ self._gc:remove()
+ self._gc = gc()
+end
+
---@param scopeType scope.type
---@return scope
local function createScope(scopeType)
@@ -104,6 +116,7 @@ local function createScope(scopeType)
type = scopeType,
_links = {},
_data = {},
+ _gc = gc(),
}, mt)
return scope