diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-22 16:22:23 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-22 16:22:23 +0800 |
commit | 5731df3b2266503fe99bf674110ac19a730ce070 (patch) | |
tree | b1e570cbde22e7d55c9c4ff31a3d0513750352c0 | |
parent | 14a49faa67e15b2b10fb7aa798bb541dec201d88 (diff) | |
download | lua-language-server-5731df3b2266503fe99bf674110ac19a730ce070.zip |
prevent forward in method -> self
-rw-r--r-- | script/core/guide.lua | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/script/core/guide.lua b/script/core/guide.lua index d8c20c64..f3492988 100644 --- a/script/core/guide.lua +++ b/script/core/guide.lua @@ -2107,7 +2107,10 @@ function m.searchSameMethodIntoSelf(ref, mark) return selfRef end -function m.searchSameFieldsCrossMethod(status, ref, start, pushQueue) +function m.searchSameFieldsCrossMethod(status, ref, start, pushQueue, mode) + if status.share.crossMethodMark2 then + return + end local mark = status.crossMethodMark if not mark then mark = {} @@ -2121,7 +2124,15 @@ function m.searchSameFieldsCrossMethod(status, ref, start, pushQueue) tracy.ZoneBeginN 'searchSameFieldsCrossMethod' local _ <close> = tracy.ZoneEnd -- 如果自己是method,则只检查自己内部的self引用 - pushQueue(selfRef, start, true) + status.share.inBeSetValue = (status.share.inBeSetValue or 0) + 1 + status.share.crossMethodMark2 = true + local newStatus = m.status(status) + m.searchRefs(newStatus, selfRef, mode) + for _, res in ipairs(newStatus.results) do + pushQueue(res, start, true) + end + status.share.inBeSetValue = (status.share.inBeSetValue or 0) - 1 + status.share.crossMethodMark2 = nil return end local method = m.searchSameMethodOutSelf(ref, mark) @@ -2916,7 +2927,7 @@ function m.checkSameSimple(status, simple, ref, start, force, mode, pushQueue) m.checkSameSimpleInString(status, ref, i, pushQueue, cmode) if not skipInfer and not skipSearch then -- 穿透 self:func 与 mt:func - m.searchSameFieldsCrossMethod(status, ref, i, pushQueue) + m.searchSameFieldsCrossMethod(status, ref, i, pushQueue, cmode) -- 穿透赋值 m.searchSameFieldsInValue(status, ref, i, pushQueue, cmode) -- 检查自己是字面量表的情况 |