From c1ca4d8af0cefd6222b76f83341774857cef44ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 31 Mar 2022 23:00:02 +0800 Subject: cleanup --- script/core/completion/completion.lua | 6 +++--- script/core/diagnostics/no-implicit-any.lua | 2 +- script/core/hint.lua | 3 ++- script/core/hover/arg.lua | 10 +++++----- script/core/hover/init.lua | 2 +- script/core/hover/label.lua | 10 +++++----- script/core/hover/return.lua | 4 ++-- 7 files changed, 19 insertions(+), 18 deletions(-) (limited to 'script/core') diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index f54bd2d1..133b262d 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -167,7 +167,7 @@ local function buildDetail(source) if source.type == 'dummy' then return end - local types = infer.viewType(source) + local types = infer.getInfer(source):view() local literals = infer.viewLiterals(source) if literals then return types .. ' = ' .. literals @@ -1819,14 +1819,14 @@ local function buildluaDocOfFunction(func) local returns = {} if func.args then for _, arg in ipairs(func.args) do - args[#args+1] = infer.viewType(arg) + args[#args+1] = infer.getInfer(arg):view() end end if func.returns then for _, rtns in ipairs(func.returns) do for n = 1, #rtns do if not returns[n] then - returns[n] = infer.viewType(rtns[n]) + returns[n] = infer.getInfer(rtns[n]):view() end end end diff --git a/script/core/diagnostics/no-implicit-any.lua b/script/core/diagnostics/no-implicit-any.lua index 47f1b997..5c14d211 100644 --- a/script/core/diagnostics/no-implicit-any.lua +++ b/script/core/diagnostics/no-implicit-any.lua @@ -20,7 +20,7 @@ return function (uri, callback) and source.type ~= 'tableindex' then return end - if infer.viewType(source) == 'any' then + if infer.getInfer(source):view() == 'unknown' then callback { start = source.start, finish = source.finish, diff --git a/script/core/hint.lua b/script/core/hint.lua index 3b5db3e5..51842126 100644 --- a/script/core/hint.lua +++ b/script/core/hint.lua @@ -41,8 +41,9 @@ local function typeHint(uri, results, start, finish) end end await.delay() - local view = infer.viewType(source) + local view = infer.getInfer(source):view() if view == 'any' + or view == 'unknown' or view == 'nil' then return end diff --git a/script/core/hover/arg.lua b/script/core/hover/arg.lua index c9c81a85..7611a895 100644 --- a/script/core/hover/arg.lua +++ b/script/core/hover/arg.lua @@ -21,7 +21,7 @@ local function asFunction(source, oop) methodDef = true end if methodDef then - args[#args+1] = ('self: %s'):format(infer.viewType(parent.node)) + args[#args+1] = ('self: %s'):format(infer.getInfer(parent.node)) end if source.args then for i = 1, #source.args do @@ -34,15 +34,15 @@ local function asFunction(source, oop) args[#args+1] = ('%s%s: %s'):format( name, optionalArg(arg) and '?' or '', - infer.viewType(arg, 'any') + infer.getInfer(arg):view 'any' ) elseif arg.type == '...' then args[#args+1] = ('%s: %s'):format( '...', - infer.viewType(arg, 'any') + infer.getInfer(arg):view 'any' ) else - args[#args+1] = ('%s'):format(infer.viewType(arg, 'any')) + args[#args+1] = ('%s'):format(infer.getInfer(arg):view 'any') end ::CONTINUE:: end @@ -65,7 +65,7 @@ local function asDocFunction(source, oop) args[i] = ('%s%s: %s'):format( name, arg.optional and '?' or '', - arg.extends and infer.viewType(arg.extends) or 'any' + arg.extends and infer.getInfer(arg.extends):view 'any' or 'any' ) end if oop then diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua index fdfbd73d..bc2f40eb 100644 --- a/script/core/hover/init.lua +++ b/script/core/hover/init.lua @@ -40,7 +40,7 @@ local function getHover(source) end local oop - if infer.viewType(source) == 'function' then + if infer.getInfer(source):view() == 'function' then local hasFunc for _, def in ipairs(vm.getDefs(source)) do if guide.isOOP(def) then diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index 01dd1143..150f0f24 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -35,7 +35,7 @@ local function asDocTypeName(source) end if doc.type == 'doc.alias.name' then local extends = doc.parent.extends - return lang.script('HOVER_EXTENDS', infer.viewType(extends)) + return lang.script('HOVER_EXTENDS', infer.getInfer(extends):view()) end end end @@ -43,12 +43,12 @@ end ---@async local function asValue(source, title) local name = buildName(source, false) or '' - local type = infer.viewType(source) + local type = infer.getInfer(source):view() local literal = infer.viewLiterals(source) local cont - if not infer.hasType(source, 'string') + if not infer.getInfer(source):hasType 'string' and not type:find('%[%]$') then - if infer.hasType(source, 'table') then + if infer.getInfer(source):hasType 'table' then cont = buildTable(source) end end @@ -131,7 +131,7 @@ local function asDocFieldName(source) break end end - local view = infer.viewType(docField.extends) + local view = infer.getInfer(docField.extends):view() if not class then return ('field ?.%s: %s'):format(name, view) end diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua index e48febf3..cb8fa76f 100644 --- a/script/core/hover/return.lua +++ b/script/core/hover/return.lua @@ -67,7 +67,7 @@ local function asFunction(source) local name = doc and doc.name and doc.name[1] and (doc.name[1] .. ': ') local text = ('%s%s%s'):format( name or '', - infer.viewType(rtn), + infer.getInfer(rtn):view(), doc and doc.optional and '?' or '' ) if i == 1 then @@ -87,7 +87,7 @@ local function asDocFunction(source) local returns = {} for i, rtn in ipairs(source.returns) do local rtnText = ('%s%s'):format( - infer.viewType(rtn), + infer.getInfer(rtn):view(), rtn.optional and '?' or '' ) if i == 1 then -- cgit v1.2.3