diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-15 15:54:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-15 15:54:18 +0800 |
commit | 4e68872ea96a53f9c7ad5e11c83794b92f477fb4 (patch) | |
tree | e18475aefccae62be35ba93d6a600e036fd0cdab /script/parser/luadoc.lua | |
parent | ba041ed17bac8a00a0e83ee289e7a257bf6f3d8b (diff) | |
download | lua-language-server-4e68872ea96a53f9c7ad5e11c83794b92f477fb4.zip |
#close 289
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r-- | script/parser/luadoc.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index dad32378..1b48719d 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -1103,6 +1103,47 @@ local function bindDocsBetween(sources, binded, bindSources, start, finish) end end +local function bindParamAndReturnIndex(binded) + local func + for _, source in ipairs(binded[1].bindSources) do + if source.type == 'function' then + func = source + break + end + end + if not func then + return + end + if not func.args then + return + end + local paramIndex = 0 + local parent = func.parent + if parent.type == 'setmethod' then + paramIndex = paramIndex + 1 + end + local paramMap = {} + for _, param in ipairs(func.args) do + paramIndex = paramIndex + 1 + if param[1] then + paramMap[param[1]] = paramIndex + end + end + local returnIndex = 0 + for _, doc in ipairs(binded) do + if doc.type == 'doc.param' then + if doc.extends then + doc.extends.paramIndex = paramMap[doc.param[1]] + end + elseif doc.type == 'doc.return' then + for _, rtn in ipairs(doc.returns) do + returnIndex = returnIndex + 1 + rtn.returnIndex = returnIndex + end + end + end +end + local function bindDoc(sources, lns, binded) if not binded then return @@ -1124,6 +1165,7 @@ local function bindDoc(sources, lns, binded) if #bindSources == 0 then bindDocsBetween(sources, binded, bindSources, nstart, nfinish) end + bindParamAndReturnIndex(binded) end local function bindDocs(state) |