summaryrefslogtreecommitdiff
path: root/script/vm/getGlobals.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/vm/getGlobals.lua')
-rw-r--r--script/vm/getGlobals.lua30
1 files changed, 22 insertions, 8 deletions
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua
index 5d64cef6..d794a394 100644
--- a/script/vm/getGlobals.lua
+++ b/script/vm/getGlobals.lua
@@ -1,4 +1,5 @@
local collector = require 'core.collector'
+local guide = require 'parser.guide'
---@diagnostic disable-next-line
---@class vm
local vm = require 'vm.vm'
@@ -21,19 +22,32 @@ function vm.getGlobalSets(name)
end
local results = {}
cache[name] = results
- local id
if name == '*' then
- id = 'def:g:'
+ for noders in collector.each('def:g:') do
+ for id in noder.eachID(noders) do
+ if id:sub(1, 2) == 'g:'
+ and not id:find(noder.SPLIT_CHAR) then
+ for source in noder.eachSource(noders, id) do
+ if guide.isSet(source) then
+ results[#results+1] = source
+ end
+ end
+ end
+ end
+ end
else
+ local id
if type(name) == 'string' then
- id = ('def:g:%s%s'):format(noder.STRING_CHAR, name)
+ id = ('g:%s%s'):format(noder.STRING_CHAR, name)
else
- id = ('def:g:%s'):format(noder.STRING_CHAR, name)
+ id = ('g:%s'):format(noder.STRING_CHAR, name)
end
- end
- for noders in collector.each(id) do
- for source in noder.eachSource(noders, id) do
- results[#results+1] = source
+ for noders in collector.each('def:' .. id) do
+ for source in noder.eachSource(noders, id) do
+ if guide.isSet(source) then
+ results[#results+1] = source
+ end
+ end
end
end
return results