summaryrefslogtreecommitdiff
path: root/server/src/core/global.lua
blob: 7be76818c8ba28df7e13d0727efc7c4c708f535d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local mt = {}
mt.__index = mt

function mt:compileVM(uri)
    if not self.set[uri] and not self.get[uri] then
        return
    end
end

function mt:markSet(uri)
    if not uri then
        return
    end
    self.set[uri] = true
end

function mt:markGet(uri)
    if not uri then
        return
    end
    self.get[uri] = true
end

function mt:clearGlobal(uri)
    self.set[uri] = nil
    self.get[uri] = nil
    local globalValue = self.lsp.globalValue
    if not globalValue then
        return
    end
    globalValue:removeUri(uri)
end

function mt:getAllUris()
    local uris = {}
    for uri in pairs(self.set) do
        uris[#uris+1] = uri
    end
    for uri in pairs(self.get) do
        if not self.set[uri] then
            uris[#uris+1] = uri
        end
    end
    return uris
end

return function (lsp)
    return setmetatable({
        get = {},
        set = {},
        lsp = lsp,
    }, mt)
end