summaryrefslogtreecommitdiff
path: root/script-beta/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-14 15:35:02 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-14 15:35:02 +0800
commit073cb7d520f288f28f3abd74571b4bd575597877 (patch)
tree6c3caec53c7192c67f0ddf6302413d5172d0f1e7 /script-beta/parser
parent1302aa460db48fca165ed4b2603e7ba085cf77ad (diff)
downloadlua-language-server-073cb7d520f288f28f3abd74571b4bd575597877.zip
更新锁的设计
Diffstat (limited to 'script-beta/parser')
-rw-r--r--script-beta/parser/guide.lua37
1 files changed, 32 insertions, 5 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 8f2fe1bf..484184c3 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1354,7 +1354,32 @@ function m.checkSameSimpleAsReturnTableField(status, ref, start, queue)
end
function m.checkSameSimpleAsSetValue(status, ref, start, queue)
-
+ local parent = ref.parent
+ if m.getObjectValue(parent) ~= ref then
+ return
+ end
+ local obj
+ if parent.type == 'local'
+ or parent.type == 'setglobal'
+ or parent.type == 'setlocal' then
+ obj = parent
+ elseif parent.type == 'setfield' then
+ obj = parent.field
+ elseif parent.type == 'setmethod' then
+ obj = parent.method
+ end
+ if not obj then
+ return
+ end
+ local newStatus = m.status(status)
+ m.searchRefs(newStatus, obj, '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)
@@ -1488,10 +1513,10 @@ function m.searchSameFields(status, simple, mode)
for obj in pairs(status.lock) do
mark[obj] = true
end
- for i = 1, #queue do
- local data = queue[i]
- status.lock[data.obj] = true
- end
+ --for i = 1, #queue do
+ -- local data = queue[i]
+ -- status.lock[data.obj] = true
+ --end
-- 对初始对象进行预处理
if simple.global then
for i = 1, #queue do
@@ -1530,9 +1555,11 @@ function m.searchSameFields(status, simple, mode)
return
end
if not mark[data.obj] then
+ -- TODO 改一下锁
status.lock[data.obj] = true
mark[data.obj] = true
m.checkSameSimple(status, simple, data, mode, status.results, queue)
+ status.lock[data.obj] = nil
end
end
end