blob: 696f218ecd732121e664d12bdc0b70812a47daba (
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
|
local collector = require 'core.collector'
---@type vm
local vm = require 'vm.vm'
local noder = require 'core.noder'
function vm.hasGlobalSets(name)
local id = ('def:g:%q'):format(name)
return collector.has(id)
end
function vm.getGlobalSets(name)
local cache = vm.getCache 'getGlobalSets'
if cache[name] then
return cache[name]
end
local results = {}
cache[name] = results
local id
if name == '*' then
id = 'def:g:'
else
id = ('def:g:%q'):format(name)
end
for node in collector.each(id) do
for source in noder.eachSource(node) do
results[#results+1] = source
end
end
return results
end
|