summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-12 20:06:00 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-12 20:06:00 +0800
commit769b86902f12fe9b91659ad1ba9abab81ccf5baa (patch)
tree3c2d7adf27cf8b0cfddffec52465688f5ca5bb2e /script-beta
parentde37c136fb0423794bdc8fcdc76eb5772d2bcaa7 (diff)
downloadlua-language-server-769b86902f12fe9b91659ad1ba9abab81ccf5baa.zip
锁复制错了
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/parser/guide.lua40
1 files changed, 28 insertions, 12 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 1c3d0460..b8d2fe67 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1230,18 +1230,17 @@ function m.checkSameSimpleInCallInSameFile(status, func, args, index)
end
function m.checkSameSimpleInCall(status, ref, start, queue, mode)
- if not status.interface.call then
- return
- end
local func, args, index = m.getCallValue(ref)
if not func then
return
end
local objs = m.checkSameSimpleInCallInSameFile(status, func, args, index)
- local cobjs = status.interface.call(func, args, index)
- if cobjs then
- for _, obj in ipairs(cobjs) do
- objs[#objs+1] = obj
+ if status.interface.call then
+ local cobjs = status.interface.call(func, args, index)
+ if cobjs then
+ for _, obj in ipairs(cobjs) do
+ objs[#objs+1] = obj
+ end
end
end
local newStatus = m.status(status)
@@ -1299,6 +1298,22 @@ function m.searchSameFieldsInValue(status, ref, start, queue)
end
end
+function m.checkSameSimpleAsTableField(status, ref, start, queue)
+ local parent = ref.parent
+ if parent.type ~= 'tablefield' then
+ return
+ end
+ local newStatus = m.status(status)
+ m.searchRefs(newStatus, parent.field, 'ref')
+ for _, res in ipairs(newStatus.results) do
+ queue[#queue+1] = {
+ obj = res,
+ start = start,
+ force = true,
+ }
+ end
+end
+
function m.checkSameSimple(status, simple, data, mode, results, queue)
local ref = data.obj
local start = data.start
@@ -1315,6 +1330,10 @@ function m.checkSameSimple(status, simple, data, mode, results, queue)
m.searchSameFieldsInValue(status, ref, i, queue)
-- 检查形如 a = f() 的分支情况,需要业务层传入 interface.call
m.checkSameSimpleInCall(status, ref, i, queue, mode)
+ if i < #simple or mode ~= 'def' then
+ -- 检查形如 { a = f } 的情况
+ m.checkSameSimpleAsTableField(status, ref, i, queue)
+ end
if i == #simple then
break
end
@@ -1417,11 +1436,8 @@ function m.searchSameFields(status, simple, mode)
end
-- 防止无限递归
local mark = {}
- for i = 1, #queue do
- local data = queue[i]
- if status.lock[data.obj] then
- mark[data.obj] = true
- end
+ for obj in pairs(status.lock) do
+ mark[obj] = true
end
for i = 1, #queue do
local data = queue[i]