summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-23 17:18:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-23 17:18:26 +0800
commitf345904350c074438b25941fb29d00eb4f84e7a0 (patch)
tree7310ba1f8f6076627d73d5e0af1f7c54070fbb54
parent7a9c274c01e50684d4c094c7d5db45670336ff2f (diff)
downloadlua-language-server-f345904350c074438b25941fb29d00eb4f84e7a0.zip
部分 global
-rw-r--r--script-beta/parser/guide.lua22
-rw-r--r--script-beta/vm/getGlobals.lua2
2 files changed, 11 insertions, 13 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index b10490dc..048c6db2 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1225,15 +1225,11 @@ function m.checkSameSimpleInCall(status, ref, start, queue)
end
end
-function m.checkSameSimpleInGlobal(status, ref, start, queue)
+function m.checkSameSimpleInGlobal(status, name, 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)
+ local objs = status.interface.global(name)
if objs then
for _, obj in ipairs(objs) do
queue[#queue+1] = {
@@ -1264,8 +1260,6 @@ function m.checkSameSimple(status, simple, data, mode, results, queue)
m.checkSameSimpleInBranch(status, ref, i, queue)
-- 检查形如 a = f() 的分支情况,需要业务层传入 interface.call
m.checkSameSimpleInCall(status, ref, i, queue)
- -- 检查全局变量的分支情况,需要业务层传入 interface.global
- m.checkSameSimpleInGlobal(status, ref, i, queue)
ref = m.getNextRef(ref)
if not ref then
return
@@ -1332,10 +1326,14 @@ function m.searchSameFields(status, simple, mode)
data.obj = nxt
end
end
- if first and first.tag ~= '_ENV' then
- m.checkSameSimpleInBranch(status, first, 0, queue)
- m.checkSameSimpleInCall(status, first, 0, queue)
- m.checkSameSimpleInGlobal(status, first, 0, queue)
+ if first then
+ if first.tag == '_ENV' then
+ -- 检查全局变量的分支情况,需要业务层传入 interface.global
+ m.checkSameSimpleInGlobal(status, simple[1], 1, queue)
+ else
+ -- local _ENV 的情况
+ m.checkSameSimpleInBranch(status, first, 0, queue)
+ end
end
else
queue[#queue+1] = {
diff --git a/script-beta/vm/getGlobals.lua b/script-beta/vm/getGlobals.lua
index ec575e8e..8ac63090 100644
--- a/script-beta/vm/getGlobals.lua
+++ b/script-beta/vm/getGlobals.lua
@@ -11,7 +11,7 @@ local function getGlobalsOfFile(uri)
local env = guide.getENV(ast.ast)
local results = guide.requestFields(env)
for _, res in ipairs(results) do
- local name = guide.getName(res)
+ local name = guide.getSimpleName(res)
if not globals[name] then
globals[name] = {}
end