diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-05 16:10:33 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-05 16:10:33 +0800 |
commit | 4d91852b04e050ee958ee2b22a0219d48fcc7c20 (patch) | |
tree | bbe9aa2d0de215ecfeee453059a87b24252fefd0 /server-beta/src/searcher | |
parent | cef2f9749c982d588eca71cdee8aed582b92539e (diff) | |
download | lua-language-server-4d91852b04e050ee958ee2b22a0219d48fcc7c20.zip |
更新诊断
Diffstat (limited to 'server-beta/src/searcher')
-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 |