diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-27 14:12:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-27 14:12:15 +0800 |
commit | 6269a0c2d108e288bb5c637d86cb0cd62396209b (patch) | |
tree | 872d69974852daa49c448ab4e6b5c0ef7f2d4fc4 /script-beta | |
parent | 03e3cd15f9673e13537eee9d6b71bb45c22318eb (diff) | |
download | lua-language-server-6269a0c2d108e288bb5c637d86cb0cd62396209b.zip |
过基础的 hover
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/parser/guide.lua | 33 | ||||
-rw-r--r-- | script-beta/parser/luadoc.lua | 3 |
2 files changed, 26 insertions, 10 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index a1b73306..0760c441 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -3268,6 +3268,9 @@ local function mergeLibraryFunctionReturns(status, source, index) end local function mergeFunctionReturnsByDoc(status, source, index, call) + if not source or source.type ~= 'function' then + return + end if not source.bindDocs then return end @@ -3308,15 +3311,16 @@ local function mergeFunctionReturnsByDoc(status, source, index, call) end end end) + if #results == 0 then + return + end for _, res in ipairs(results) do status.results[#status.results+1] = res end + return true end local function mergeFunctionReturns(status, source, index, call) - if mergeFunctionReturnsByDoc(status, source, index, call) then - return - end local returns = source.returns if not returns then return @@ -3372,17 +3376,26 @@ function m.inferByCallReturnAndIndex(status, call, index) local node = call.node local newStatus = m.status(nil, status.interface) m.searchRefs(newStatus, node, 'def') + local hasDocReturn for _, src in ipairs(newStatus.results) do - if src.value and src.value.type == 'function' then - if src.type == 'library' then - mergeLibraryFunctionReturns(status, src.value, index) - else - if not m.checkReturnMark(status, src.value, true) then - mergeFunctionReturns(status, src.value, index, call) + if mergeDocTypeFunctionReturns(status, src, index) then + hasDocReturn = true + elseif mergeFunctionReturnsByDoc(status, src.value, index, call) then + hasDocReturn = true + end + end + if not hasDocReturn then + for _, src in ipairs(newStatus.results) do + if src.value and src.value.type == 'function' then + if src.type == 'library' then + mergeLibraryFunctionReturns(status, src.value, index) + else + if not m.checkReturnMark(status, src.value, true) then + mergeFunctionReturns(status, src.value, index, call) + end end end end - mergeDocTypeFunctionReturns(status, src, index) end end diff --git a/script-beta/parser/luadoc.lua b/script-beta/parser/luadoc.lua index 72974d28..ad2dea14 100644 --- a/script-beta/parser/luadoc.lua +++ b/script-beta/parser/luadoc.lua @@ -720,6 +720,9 @@ local function bindDoc(state, lns, binded) return end guide.eachSourceBetween(state.ast, start, finish, function (src) + if src.start and src.start < start then + return + end if src.type == 'local' or src.type == 'setlocal' or src.type == 'setglobal' |