summaryrefslogtreecommitdiff
path: root/server-beta/src/searcher/eachRef.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-10 21:44:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-10 21:44:05 +0800
commitcae5af4f384ce07da6dd5616c369d50356edee38 (patch)
treea276f8dd54d33581ce538b45c299bd9644ad9f74 /server-beta/src/searcher/eachRef.lua
parent80f8f5bdda5a0401f28a83ea9dd649309ad16c55 (diff)
downloadlua-language-server-cae5af4f384ce07da6dd5616c369d50356edee38.zip
优化性能
Diffstat (limited to 'server-beta/src/searcher/eachRef.lua')
-rw-r--r--server-beta/src/searcher/eachRef.lua18
1 files changed, 8 insertions, 10 deletions
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua
index dca1c636..b1023f52 100644
--- a/server-beta/src/searcher/eachRef.lua
+++ b/server-beta/src/searcher/eachRef.lua
@@ -234,17 +234,15 @@ local function ofGlobal(source, 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 uris = files.findGlobals(key)
+ for _, uri in ipairs(uris) do
local ast = files.getAst(uri)
- if ast and globals and globals[key] then
- globals = searcher.getGlobals(ast.ast)
- if globals[key] then
- for _, info in ipairs(globals[key]) do
- callback(info)
- if info.value then
- ofValue(info.value, callback)
- end
+ local globals = searcher.getGlobals(ast.ast)
+ if globals[key] then
+ for _, info in ipairs(globals[key]) do
+ callback(info)
+ if info.value then
+ ofValue(info.value, callback)
end
end
end