summaryrefslogtreecommitdiff
path: root/server-beta/src/searcher
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-05 16:10:33 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-05 16:10:33 +0800
commit4d91852b04e050ee958ee2b22a0219d48fcc7c20 (patch)
treebbe9aa2d0de215ecfeee453059a87b24252fefd0 /server-beta/src/searcher
parentcef2f9749c982d588eca71cdee8aed582b92539e (diff)
downloadlua-language-server-4d91852b04e050ee958ee2b22a0219d48fcc7c20.zip
更新诊断
Diffstat (limited to 'server-beta/src/searcher')
-rw-r--r--server-beta/src/searcher/eachRef.lua39
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