diff options
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/completion.lua | 4 | ||||
-rw-r--r-- | script-beta/core/diagnostics/redundant-parameter.lua | 3 | ||||
-rw-r--r-- | script-beta/core/hover/init.lua | 52 |
3 files changed, 42 insertions, 17 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 610279db..e0bdfd64 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -203,6 +203,7 @@ local function getSnip(source) end local defs = vm.getRefs(source, 'deep') for _, def in ipairs(defs) do + def = guide.getObjectValue(def) or def if def ~= source and def.type == 'function' then local uri = guide.getUri(def) local text = files.getText(uri) @@ -442,7 +443,7 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res local last = fields[name] if not last then if guide.isGlobal(src) then - fields[name] = vm.getDefs(src, 'deep')[1] or src + fields[name] = vm.getGlobalSets(key)[1] or src else fields[name] = src end @@ -1050,6 +1051,7 @@ local function tryCallArg(ast, text, offset, results) end local defs = vm.getDefs(call.node, 'deep') for _, def in ipairs(defs) do + def = guide.getObjectValue(def) or def local enums = getCallEnums(def, argIndex) if enums then mergeEnums(myResults, enums, text, arg) diff --git a/script-beta/core/diagnostics/redundant-parameter.lua b/script-beta/core/diagnostics/redundant-parameter.lua index 074e7f7c..dda6c014 100644 --- a/script-beta/core/diagnostics/redundant-parameter.lua +++ b/script-beta/core/diagnostics/redundant-parameter.lua @@ -65,6 +65,9 @@ return function (uri, callback) local funcArgs local defs = vm.getDefs(func) for _, def in ipairs(defs) do + if def.value then + def = def.value + end if def.type == 'function' then local args = countFuncArgs(def) if not funcArgs or args > funcArgs then diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua index 92197ab6..a332cec0 100644 --- a/script-beta/core/hover/init.lua +++ b/script-beta/core/hover/init.lua @@ -7,6 +7,18 @@ local util = require 'utility' local findSource = require 'core.find-source' local lang = require 'language' +local function eachFunctionAndOverload(value, callback) + callback(value) + if not value.bindDocs then + return + end + for _, doc in ipairs(value.bindDocs) do + if doc.type == 'doc.overload' then + callback(doc.overload) + end + end +end + local function getHoverAsFunction(source) local values = vm.getDefs(source, 'deep') local desc = getDesc(source) @@ -17,24 +29,32 @@ local function getHoverAsFunction(source) local oop = source.type == 'method' or source.type == 'getmethod' or source.type == 'setmethod' - for _, value in ipairs(values) do - if value.type == 'function' - or value.type == 'doc.type.function' then - local label = getLabel(value, oop) - if label then - defs = defs + 1 - labels[label] = (labels[label] or 0) + 1 - if labels[label] == 1 then - protos = protos + 1 + local mark = {} + for _, def in ipairs(values) do + def = guide.getObjectValue(def) or def + if def.type == 'function' + or def.type == 'doc.type.function' then + eachFunctionAndOverload(def, function (value) + if mark[value] then + return + end + mark[value] =true + local label = getLabel(value, oop) + if label then + defs = defs + 1 + labels[label] = (labels[label] or 0) + 1 + if labels[label] == 1 then + protos = protos + 1 + end end - end - desc = desc or getDesc(value) - elseif value.type == 'table' - or value.type == 'boolean' - or value.type == 'string' - or value.type == 'number' then + desc = desc or getDesc(value) + end) + elseif def.type == 'table' + or def.type == 'boolean' + or def.type == 'string' + or def.type == 'number' then other = other + 1 - desc = desc or getDesc(value) + desc = desc or getDesc(def) end end |