summaryrefslogtreecommitdiff
path: root/script/parser/guide.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-05 15:40:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-05 15:40:25 +0800
commit5641c17faaed10409a476558dde8e15f4f91f9cb (patch)
tree41e4981290a942b2ac6a273a47730f2386246040 /script/parser/guide.lua
parentd704ebf543af4e9ae2aa115f24193d4d5012ac73 (diff)
downloadlua-language-server-5641c17faaed10409a476558dde8e15f4f91f9cb.zip
guess `self`
Diffstat (limited to 'script/parser/guide.lua')
-rw-r--r--script/parser/guide.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 354a5eed..6ba7e903 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1506,6 +1506,29 @@ function m.checkSameSimpleInSpecialBranch(status, obj, start, pushQueue)
end
end
+function m.checkSameSimpleInParamSelf(status, obj, start, pushQueue)
+ if obj.type ~= 'getlocal' or obj[1] ~= 'self' then
+ return
+ end
+ local node = obj.node
+ if node.tag == 'self' then
+ return
+ end
+ if node.parent.type ~= 'funcargs' then
+ return
+ end
+ local func = node.parent.parent
+ if func.type ~= 'function' or func.parent.type ~= 'setfield' then
+ return
+ end
+ local fieldNode = func.parent.node
+ local newStatus = m.status(status)
+ m.searchRefs(newStatus, fieldNode, 'ref')
+ for _, ref in ipairs(newStatus.results) do
+ pushQueue(ref, start, true)
+ end
+end
+
local function appendValidGenericType(results, status, typeName, obj)
if typeName.parent.type == 'doc.type.typeliteral' then
if obj.type == 'string' and status.interface.docType then
@@ -2415,6 +2438,8 @@ function m.checkSameSimple(status, simple, ref, start, force, mode, pushQueue)
m.checkSameSimpleInValueOfCallMetaTable(status, ref, i, pushQueue)
-- 检查自己是特殊变量的分支的情况
m.checkSameSimpleInSpecialBranch(status, ref, i, pushQueue)
+ -- self 的特殊处理
+ m.checkSameSimpleInParamSelf(status, ref, i, pushQueue)
if cmode == 'ref' then
-- 检查形如 { a = f } 的情况
m.checkSameSimpleAsTableField(status, ref, i, pushQueue)