summaryrefslogtreecommitdiff
path: root/script-beta/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-23 15:11:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-23 15:11:03 +0800
commita27677a6d4beca0e898d691e36d94df498ffb1d1 (patch)
tree14e8d23d91fb7f4436b86534ecd0a4449a01fc73 /script-beta/parser
parentd60ad2c5826162c480dba8f1bc810758bb090327 (diff)
downloadlua-language-server-a27677a6d4beca0e898d691e36d94df498ffb1d1.zip
getGlobals
Diffstat (limited to 'script-beta/parser')
-rw-r--r--script-beta/parser/guide.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index ee5bb425..f3224e4c 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1204,7 +1204,7 @@ function m.searchSameFieldsCrossMethod(status, ref, start, queue)
end
end
-function m.checkSameSimpleIncall(status, ref, start, queue)
+function m.checkSameSimpleInCall(status, ref, start, queue)
if not status.interface.call then
return
end
@@ -1224,6 +1224,26 @@ function m.checkSameSimpleIncall(status, ref, start, queue)
end
end
+function m.checkSameSimpleInGlobal(status, ref, start, queue)
+ if not status.interface.global then
+ return
+ end
+ if ref.type ~= 'setglobal' and ref.type ~= 'getglobal' then
+ return
+ end
+ local globalName = ref[1]
+ local objs = status.interface.global(globalName)
+ if objs then
+ for _, obj in ipairs(objs) do
+ queue[#queue+1] = {
+ obj = obj,
+ start = start,
+ force = true,
+ }
+ end
+ end
+end
+
function m.checkSameSimple(status, simple, data, mode, results, queue)
local ref = data.obj
local start = data.start
@@ -1242,7 +1262,9 @@ function m.checkSameSimple(status, simple, data, mode, results, queue)
-- 检查形如 a = {} 的分支情况
m.checkSameSimpleInBranch(status, ref, i, queue)
-- 检查形如 a = f() 的分支情况,需要业务层传入 interface.call
- m.checkSameSimpleIncall(status, ref, i, queue)
+ m.checkSameSimpleInCall(status, ref, i, queue)
+ -- 检查全局变量的分支情况,需要业务层传入 interface.global
+ m.checkSameSimpleInGlobal(status, ref, i, queue)
ref = m.getNextRef(ref)
if not ref then
return