diff options
Diffstat (limited to 'script-beta')
-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 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 10 | ||||
-rw-r--r-- | script-beta/vm/eachDef.lua | 9 | ||||
-rw-r--r-- | script-beta/vm/eachRef.lua | 9 | ||||
-rw-r--r-- | script-beta/vm/getGlobals.lua | 8 |
7 files changed, 50 insertions, 45 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 diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 1de15a3b..b24f1cd8 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1476,8 +1476,6 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode) results[#results+1] = doc.extends end end - elseif doc.type == 'doc.overload' then - results[#results+1] = doc.overload elseif doc.type == 'doc.field' then results[#results+1] = doc end @@ -3046,14 +3044,6 @@ function m.inferCheckUpDoc(status, source) return true end end - elseif doc.type == 'doc.overload' then - if source.value and source.value.type == 'function' then - local typeName = getDocTypeUnitName(status, doc.overload) - status.results[#status.results+1] = { - type = typeName, - source = doc.overload, - } - end end end end diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index ab71e7c4..5ff58889 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -27,13 +27,8 @@ end function vm.getDefs(source, deep) if guide.isGlobal(source) then - local name = guide.getKeyName(source) - local cache = vm.getCache('eachDefOfGlobal')[name] - or vm.getCache('eachDef')[source] - or eachDef(source, 'deep') - vm.getCache('eachDefOfGlobal')[name] = cache - vm.getCache('eachDef')[source] = cache - return cache + local key = guide.getKeyName(source) + return vm.getGlobalSets(key) else local cache = vm.getCache('eachDef')[source] or eachDef(source, deep) diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 7d1f2c77..4e735abf 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -26,13 +26,8 @@ end function vm.getRefs(source, deep) if guide.isGlobal(source) then - local name = guide.getKeyName(source) - local cache = vm.getCache('eachRefOfGlobal')[name] - or vm.getCache('eachRef')[source] - or getRefs(source, 'deep') - vm.getCache('eachRefOfGlobal')[name] = cache - vm.getCache('eachRef')[source] = cache - return cache + local key = guide.getKeyName(source) + return vm.getGlobals(key) else local cache = vm.getCache('eachRef')[source] or getRefs(source, deep) diff --git a/script-beta/vm/getGlobals.lua b/script-beta/vm/getGlobals.lua index 9d51ec31..e5165130 100644 --- a/script-beta/vm/getGlobals.lua +++ b/script-beta/vm/getGlobals.lua @@ -96,18 +96,18 @@ function vm.getGlobals(key) return cache end -function vm.getGlobalSets(name) - local cache = vm.getCache('getGlobalSets')[name] +function vm.getGlobalSets(key) + local cache = vm.getCache('getGlobalSets')[key] if cache ~= nil then return cache end cache = {} - local refs = getGlobals(name) + local refs = getGlobals(key) for _, source in ipairs(refs) do if vm.isSet(source) then cache[#cache+1] = source end end - vm.getCache('getGlobalSets')[name] = cache + vm.getCache('getGlobalSets')[key] = cache return cache end |