diff options
Diffstat (limited to 'server-beta/src/searcher/eachRef.lua')
-rw-r--r-- | server-beta/src/searcher/eachRef.lua | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua index 8f6b5c2f..3ae020cd 100644 --- a/server-beta/src/searcher/eachRef.lua +++ b/server-beta/src/searcher/eachRef.lua @@ -227,20 +227,35 @@ local function ofLocal(loc, callback) end local function ofGlobal(source, callback) - local key = guide.getKeyName(source) - for uri in files.eachFile() do - local globals = files.getGlobals(uri) - local ast = files.getAst(uri) - if ast and globals and globals[key] then - searcher.eachGlobal(ast.ast, function (info) - if key == info.key then - callback(info) - if info.value then - ofValue(info.value, callback) + local key = guide.getKeyName(source) + local node = source.node + if node.tag == '_ENV' then + for uri in files.eachFile() do + local globals = files.getGlobals(uri) + local ast = files.getAst(uri) + if ast and globals and globals[key] then + searcher.eachGlobal(ast.ast, function (info) + if key == info.key then + callback(info) + if info.value then + ofValue(info.value, callback) + end end - end - end) + end) + end end + else + searcher.eachField(node, function (info) + if key == info.key then + callback { + source = info.source, + mode = info.mode, + } + if info.value then + ofValue(info.value, callback) + end + end + end) end end |