diff options
-rw-r--r-- | server-beta/src/core/diagnostics/undefined-env-child.lua | 5 | ||||
-rw-r--r-- | server-beta/src/core/diagnostics/undefined-global.lua | 5 | ||||
-rw-r--r-- | server-beta/src/searcher/eachRef.lua | 10 | ||||
-rw-r--r-- | server-beta/src/searcher/isGlobal.lua | 7 |
4 files changed, 15 insertions, 12 deletions
diff --git a/server-beta/src/core/diagnostics/undefined-env-child.lua b/server-beta/src/core/diagnostics/undefined-env-child.lua index 5815f9c3..4169a413 100644 --- a/server-beta/src/core/diagnostics/undefined-env-child.lua +++ b/server-beta/src/core/diagnostics/undefined-env-child.lua @@ -14,10 +14,9 @@ return function (uri, callback) if source.node.tag == '_ENV' then return end - local setInENV - searcher.eachRef(source, function (info) + local setInENV = searcher.eachRef(source, function (info) if info.mode == 'set' then - setInENV = true + return true end end) if setInENV then diff --git a/server-beta/src/core/diagnostics/undefined-global.lua b/server-beta/src/core/diagnostics/undefined-global.lua index 586a9955..b39803b8 100644 --- a/server-beta/src/core/diagnostics/undefined-global.lua +++ b/server-beta/src/core/diagnostics/undefined-global.lua @@ -18,10 +18,9 @@ return function (uri, callback) if hasSet[info.source] ~= nil then return end - local mark = false - searcher.eachRef(info.source, function (info) + local mark = searcher.eachRef(info.source, function (info) if info.mode == 'set' then - mark = true + return true end end) searcher.eachRef(info.source, function (info) diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua index b59143ad..e6540b7a 100644 --- a/server-beta/src/searcher/eachRef.lua +++ b/server-beta/src/searcher/eachRef.lua @@ -368,7 +368,10 @@ function searcher.eachRef(source, callback) local cache = searcher.cache.eachRef[source] if cache then for i = 1, #cache do - callback(cache[i]) + local res = callback(cache[i]) + if res ~= nil then + return res + end end return end @@ -393,6 +396,9 @@ function searcher.eachRef(source, callback) searcher.cache.eachRef[src] = cache end for i = 1, #cache do - callback(cache[i]) + local res = callback(cache[i]) + if res ~= nil then + return res + end end end diff --git a/server-beta/src/searcher/isGlobal.lua b/server-beta/src/searcher/isGlobal.lua index d59a6876..72a9448b 100644 --- a/server-beta/src/searcher/isGlobal.lua +++ b/server-beta/src/searcher/isGlobal.lua @@ -5,13 +5,12 @@ local function isGlobal(source) if not node then return false end - local global - searcher.eachRef(node, function (info) + local global = searcher.eachRef(node, function (info) if info.source.tag == '_ENV' then - global = true + return true end end) - return global + return global or false end function searcher.isGlobal(source) |