diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-26 11:04:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-26 11:04:16 +0800 |
commit | c268c130f7eaa493296357b1bd0ce14eb67626a2 (patch) | |
tree | c680fd1d99022a33f040d9ee29f35063010db403 | |
parent | 67f0fb20a3acb616cd700a2cd77afd616a68868d (diff) | |
download | lua-language-server-c268c130f7eaa493296357b1bd0ce14eb67626a2.zip |
in和loop支持doc.param
-rw-r--r-- | script-beta/parser/guide.lua | 16 | ||||
-rw-r--r-- | test-beta/hover/init.lua | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 694d37d0..98146386 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -2546,13 +2546,17 @@ function m.inferCheckDoc(status, source) status.results[#status.results+1] = res end elseif doc.type == 'doc.param' then + -- function (x) 的情况 if source.type == 'local' - and m.getName(source) == doc.param[1] - and source.parent.type == 'funcargs' then - status.results[#status.results+1] = { - type = m.viewInferType(m.getDocTypeNames(doc.extends)), - source = doc, - } + and m.getName(source) == doc.param[1] then + if source.parent.type == 'funcargs' + or source.parent.type == 'in' + or source.parent.type == 'loop' then + status.results[#status.results+1] = { + type = m.viewInferType(m.getDocTypeNames(doc.extends)), + source = doc, + } + end end end end diff --git a/test-beta/hover/init.lua b/test-beta/hover/init.lua index ac38edb5..119e1ee1 100644 --- a/test-beta/hover/init.lua +++ b/test-beta/hover/init.lua @@ -939,7 +939,6 @@ end local t: Class ]] -do return end TEST [[ ---@class Class @@ -948,7 +947,7 @@ for <?k?> in pairs(t) do end ]] [[ -local k<key>: Class {} +local k: Class ]] TEST [[ @@ -959,9 +958,10 @@ for k, <?v?> in pairs(t) do end ]] [[ -local v<value>: *Class {} +local v: Class ]] +do return end TEST [[ ---@return A|B ---@return C |