diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-30 16:36:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-30 16:36:31 +0800 |
commit | 7f963936a62ff7a138458c50736fcf106cc2fbe3 (patch) | |
tree | 327567938b5394897898dbbba2898511048cd230 /script-beta/vm | |
parent | db3fe02b476bc81bf7b0dc00125a4622346c0b92 (diff) | |
download | lua-language-server-7f963936a62ff7a138458c50736fcf106cc2fbe3.zip |
完成 hover
Diffstat (limited to 'script-beta/vm')
-rw-r--r-- | script-beta/vm/getValue.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/script-beta/vm/getValue.lua b/script-beta/vm/getValue.lua index b0361df7..d5665a8c 100644 --- a/script-beta/vm/getValue.lua +++ b/script-beta/vm/getValue.lua @@ -776,6 +776,42 @@ local function inferByCallReturn(results, source) end end +local function inferByPCallReturn(results, source) + if source.type ~= 'select' then + return + end + local call = source.vararg + if not call or call.type ~= 'call' then + return + end + local node = call.node + local lib = vm.getLibrary(node) + if not lib then + return + end + local func, index + if lib.name == 'pcall' then + func = call.args[1] + index = source.index - 1 + elseif lib.name == 'xpcall' then + func = call.args[1] + index = source.index - 2 + else + return + end + local funcValues = vm.getValue(func) + if not funcValues then + return + end + for i = 1, #funcValues do + local value = funcValues[i] + local src = value.source + if src.type == 'function' then + mergeFunctionReturns(results, src, index) + end + end +end + local function getValue(source) local results = checkLiteral(source) or checkValue(source) @@ -798,6 +834,7 @@ local function getValue(source) inferByUnary(results, source) inferByBinary(results, source) inferByCallReturn(results, source) + inferByPCallReturn(results, source) if #results == 0 then return nil |