diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-08-14 18:07:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-08-14 18:07:57 +0800 |
commit | 7f735dff2b5fcadb39973e3d2144fd1a3630a090 (patch) | |
tree | 98d848c59b02363d2df001e8cc8ac42c6e2e1667 /script-beta/parser/guide.lua | |
parent | cf1846dce0c42d599c31b95af1a3e1825c931909 (diff) | |
download | lua-language-server-7f735dff2b5fcadb39973e3d2144fd1a3630a090.zip |
整理代码
Diffstat (limited to 'script-beta/parser/guide.lua')
-rw-r--r-- | script-beta/parser/guide.lua | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index a6e0deef..8d7c3d9c 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1283,18 +1283,27 @@ function m.checkSameSimpleInGlobal(status, name, start, queue) end end +function m.checkValueMark(status, a, b) + if not status.cache.valueMark then + status.cache.valueMark = {} + end + if status.cache.valueMark[a] + or status.cache.valueMark[b] then + return true + end + status.cache.valueMark[a] = true + status.cache.valueMark[b] = true + return false +end + function m.searchSameFieldsInValue(status, ref, start, queue, mode) local value = m.getObjectValue(ref) if not value then return end - if not status.cache.valueMark then - status.cache.valueMark = {} - end - if status.cache.valueMark[value] then + if m.checkValueMark(status, ref, value) then return end - status.cache.valueMark[value] = true local newStatus = m.status(status) m.searchRefs(newStatus, value, mode) for _, res in ipairs(newStatus.results) do @@ -1368,13 +1377,9 @@ function m.checkSameSimpleAsSetValue(status, ref, start, queue) if m.getObjectValue(parent) ~= ref then return end - if not status.cache.valueMark then - status.cache.valueMark = {} - end - if status.cache.valueMark[ref] then + if m.checkValueMark(status, ref, parent) then return end - status.cache.valueMark[ref] = true local obj if parent.type == 'local' or parent.type == 'setglobal' |