blob: 270a6875079c9a1af6f40e3f2cda6032d1f94933 (
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 vm = require 'vm.vm'
local guide = require 'parser.guide'
local function eachRef(source, results)
results = results or {}
local lock = vm.lock('eachDef', source)
if not lock then
return results
end
local myResults = guide.requestReference(source)
vm.mergeResults(results, myResults)
lock()
return results
end
function vm.getRefs(source)
local cache = vm.getCache('eachRef')[source] or eachRef(source)
vm.getCache('eachDef')[source] = cache
return cache
end
function vm.eachRef(source, callback)
local results = vm.getRefs(source)
for i = 1, #results do
callback(results[i])
end
end
|