diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-27 10:36:32 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-27 10:36:32 +0800 |
commit | 10ed5c9e5946b36b7d75afb3855afa0cacc42543 (patch) | |
tree | e50a4ce88368f1dc5b4febe215a12dd3c01df966 /script-beta/parser/guide.lua | |
parent | 95a6fd7121fab859249ac015f7bfa1e0fbb09e8e (diff) | |
download | lua-language-server-10ed5c9e5946b36b7d75afb3855afa0cacc42543.zip |
更新
Diffstat (limited to 'script-beta/parser/guide.lua')
-rw-r--r-- | script-beta/parser/guide.lua | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 8bf01fc4..cc0bcdfe 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1434,6 +1434,21 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode) results[#results+1] = res end end + elseif doc.type == 'doc.param' then + -- function (x) 的情况 + if obj.type == 'local' + and m.getName(obj) == doc.param[1] then + if obj.parent.type == 'funcargs' + or obj.parent.type == 'in' + or obj.parent.type == 'loop' then + for _, piece in ipairs(doc.extends.types) do + local pieceResult = stepRefOfDocType(status, piece, mode) + for _, res in ipairs(pieceResult) do + results[#results+1] = res + end + end + end + end end end local mark = {} @@ -2610,8 +2625,8 @@ function m.inferCheckUpDoc(status, source) if m.inferCheckUpDocOfVararg(status, source) then return true end - while source.type == 'select' or source.type == 'call' do - local parent = source.parent + local parent = source.parent + if parent then if parent.type == 'local' or parent.type == 'setlocal' or parent.type == 'setglobal' @@ -2621,8 +2636,6 @@ function m.inferCheckUpDoc(status, source) or parent.type == 'tablefield' or parent.type == 'tableindex' then source = parent - else - break end end local binds = source.bindDocs @@ -2636,6 +2649,15 @@ function m.inferCheckUpDoc(status, source) type = doc.class[1], source = doc, } + -- ---@class Class + -- local x = { field = 1 } + -- 这种情况下,将字面量表接受为Class的定义 + if source.value and source.value.type == 'table' then + status.results[#status.results+1] = { + type = source.value.type, + source = source.value, + } + end return true elseif doc.type == 'doc.type' then local results = m.getDocTypeNames(doc) |