summaryrefslogtreecommitdiff
path: root/script-beta/vm
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta/vm')
-rw-r--r--script-beta/vm/eachRef.lua39
-rw-r--r--script-beta/vm/guideInterface.lua2
2 files changed, 22 insertions, 19 deletions
diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua
index c5d3c845..8df63022 100644
--- a/script-beta/vm/eachRef.lua
+++ b/script-beta/vm/eachRef.lua
@@ -1,27 +1,30 @@
local vm = require 'vm.vm'
local guide = require 'parser.guide'
-local function eachRef(source)
- local results = guide.requestReference(source)
+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.cache.eachRef[source] or eachRef(source)
+ vm.cache.eachDef[source] = cache
+ return cache
+end
+
function vm.eachRef(source, callback)
- local cache = vm.cache.eachRef[source]
- if cache ~= nil then
- for i = 1, #cache do
- callback(cache[i])
- end
- return
- end
- local unlock = vm.lock('eachRef', source)
- if not unlock then
- return
- end
- cache = eachRef(source) or false
- vm.cache.eachRef[source] = cache
- unlock()
- for i = 1, #cache do
- callback(cache[i])
+ local results = vm.getRefs(source)
+ for i = 1, #results do
+ callback(results[i])
end
end
diff --git a/script-beta/vm/guideInterface.lua b/script-beta/vm/guideInterface.lua
index ca949d59..f3ce2740 100644
--- a/script-beta/vm/guideInterface.lua
+++ b/script-beta/vm/guideInterface.lua
@@ -13,7 +13,7 @@ function m.searchFileReturn(results, ast, index)
if exp.type == 'table' then
vm.mergeResults(results, { exp })
else
- local newRes = vm.getDefs(exp)
+ local newRes = vm.getRefs(exp)
if #newRes > 0 then
vm.mergeResults(results, newRes)
else