diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 16:17:34 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-26 16:17:34 +0800 |
commit | 08135e067336d2767029c4a7b907e5df0a0d942b (patch) | |
tree | 1a29da5ccaad9e8715e65a6173a48fe25d22982a /script/core | |
parent | 6632a278360065a24081a85df23498b9b7bc838b (diff) | |
download | lua-language-server-08135e067336d2767029c4a7b907e5df0a0d942b.zip |
cleanup
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/completion/completion.lua | 19 | ||||
-rw-r--r-- | script/core/diagnostics/duplicate-doc-field.lua | 1 | ||||
-rw-r--r-- | script/core/diagnostics/no-unknown.lua | 4 | ||||
-rw-r--r-- | script/core/diagnostics/not-yieldable.lua | 5 | ||||
-rw-r--r-- | script/core/diagnostics/undefined-field.lua | 3 | ||||
-rw-r--r-- | script/core/hint.lua | 3 | ||||
-rw-r--r-- | script/core/hover/args.lua | 11 | ||||
-rw-r--r-- | script/core/hover/description.lua | 5 | ||||
-rw-r--r-- | script/core/hover/init.lua | 3 | ||||
-rw-r--r-- | script/core/hover/label.lua | 7 | ||||
-rw-r--r-- | script/core/hover/name.lua | 4 | ||||
-rw-r--r-- | script/core/hover/return.lua | 6 | ||||
-rw-r--r-- | script/core/hover/table.lua | 11 | ||||
-rw-r--r-- | script/core/semantic-tokens.lua | 7 | ||||
-rw-r--r-- | script/core/type-definition.lua | 1 |
15 files changed, 38 insertions, 52 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 0f720684..8987592d 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -16,7 +16,6 @@ local rpath = require 'workspace.require-path' local lang = require 'language' local lookBackward = require 'core.look-backward' local guide = require 'parser.guide' -local infer = require 'vm.infer' local await = require 'await' local postfix = require 'core.completion.postfix' local globalMgr = require 'vm.global-manager' @@ -186,8 +185,8 @@ local function buildFunctionSnip(source, value, oop) end local function buildDetail(source) - local types = infer.getInfer(source):view() - local literals = infer.getInfer(source):viewLiterals() + local types = vm.getInfer(source):view() + local literals = vm.getInfer(source):viewLiterals() if literals then return types .. ' = ' .. literals else @@ -304,7 +303,7 @@ local function checkLocal(state, word, position, results) if name:sub(1, 1) == '@' then goto CONTINUE end - if infer.getInfer(source):hasFunction() then + if vm.getInfer(source):hasFunction() then for _, def in ipairs(vm.getDefs(source)) do if def.type == 'function' or def.type == 'doc.type.function' then @@ -499,7 +498,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent }) return end - if oop and not infer.getInfer(src):hasFunction() then + if oop and not vm.getInfer(src):hasFunction() then return end local literal = guide.getLiteral(value) @@ -1118,7 +1117,7 @@ local function checkTypingEnum(state, position, defs, str, results) or def.type == 'doc.type.integer' or def.type == 'doc.type.boolean' then enums[#enums+1] = { - label = infer.viewObject(def), + label = vm.viewObject(def), description = def.comment and def.comment.text, kind = define.CompletionItemKind.EnumMember, } @@ -1407,7 +1406,7 @@ local function tryCallArg(state, position, results) or src.type == 'doc.type.integer' or src.type == 'doc.type.boolean' then enums[#enums+1] = { - label = infer.viewObject(src), + label = vm.viewObject(src), description = src.comment, kind = define.CompletionItemKind.EnumMember, } @@ -1426,7 +1425,7 @@ local function tryCallArg(state, position, results) : string() end enums[#enums+1] = { - label = infer.getInfer(src):view(), + label = vm.getInfer(src):view(), description = description, kind = define.CompletionItemKind.Function, insertText = insertText, @@ -1805,14 +1804,14 @@ local function buildluaDocOfFunction(func) local returns = {} if func.args then for _, arg in ipairs(func.args) do - args[#args+1] = infer.getInfer(arg):view() + args[#args+1] = vm.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.getInfer(rtns[n]):view() + returns[n] = vm.getInfer(rtns[n]):view() end end end diff --git a/script/core/diagnostics/duplicate-doc-field.lua b/script/core/diagnostics/duplicate-doc-field.lua index 8d355aac..d4116b9b 100644 --- a/script/core/diagnostics/duplicate-doc-field.lua +++ b/script/core/diagnostics/duplicate-doc-field.lua @@ -1,6 +1,5 @@ local files = require 'files' local lang = require 'language' -local infer = require 'vm.infer' local function getFieldEventName(doc) if not doc.extends then diff --git a/script/core/diagnostics/no-unknown.lua b/script/core/diagnostics/no-unknown.lua index 2199b6a8..48aab5da 100644 --- a/script/core/diagnostics/no-unknown.lua +++ b/script/core/diagnostics/no-unknown.lua @@ -1,7 +1,7 @@ local files = require 'files' local guide = require 'parser.guide' local lang = require 'language' -local infer = require 'vm.infer' +local vm = require 'vm' return function (uri, callback) local ast = files.getState(uri) @@ -20,7 +20,7 @@ return function (uri, callback) and source.type ~= 'tableindex' then return end - if infer.getInfer(source):view() == 'unknown' then + if vm.getInfer(source):view() == 'unknown' then callback { start = source.start, finish = source.finish, diff --git a/script/core/diagnostics/not-yieldable.lua b/script/core/diagnostics/not-yieldable.lua index 0588bbde..a1c84276 100644 --- a/script/core/diagnostics/not-yieldable.lua +++ b/script/core/diagnostics/not-yieldable.lua @@ -3,7 +3,6 @@ local await = require 'await' local guide = require 'parser.guide' local vm = require 'vm' local lang = require 'language' -local infer = require 'vm.infer' local function isYieldAble(defs, i) local hasFuncDef @@ -12,7 +11,7 @@ local function isYieldAble(defs, i) local arg = def.args and def.args[i] if arg then hasFuncDef = true - if infer.getInfer(arg):hasType 'any' + if vm.getInfer(arg):hasType 'any' or vm.isAsync(arg, true) or arg.type == '...' then return true @@ -23,7 +22,7 @@ local function isYieldAble(defs, i) local arg = def.args and def.args[i] if arg then hasFuncDef = true - if infer.getInfer(arg.extends):hasType 'any' + if vm.getInfer(arg.extends):hasType 'any' or vm.isAsync(arg.extends, true) then return true end diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua index 025c217a..41fcda48 100644 --- a/script/core/diagnostics/undefined-field.lua +++ b/script/core/diagnostics/undefined-field.lua @@ -3,7 +3,6 @@ local vm = require 'vm' local lang = require 'language' local guide = require 'parser.guide' local await = require 'await' -local infer = require 'vm.infer' local skipCheckClass = { ['unknown'] = true, @@ -35,7 +34,7 @@ return function (uri, callback) local node = src.node if node then local ok - for view in infer.getInfer(node):eachView() do + for view in vm.getInfer(node):eachView() do if not skipCheckClass[view] then ok = true break diff --git a/script/core/hint.lua b/script/core/hint.lua index f6774d2a..f97cdcec 100644 --- a/script/core/hint.lua +++ b/script/core/hint.lua @@ -1,5 +1,4 @@ local files = require 'files' -local infer = require 'vm.infer' local vm = require 'vm' local config = require 'config' local guide = require 'parser.guide' @@ -39,7 +38,7 @@ local function typeHint(uri, results, start, finish) end end await.delay() - local view = infer.getInfer(source):view() + local view = vm.getInfer(source):view() if view == 'any' or view == 'unknown' or view == 'nil' then diff --git a/script/core/hover/args.lua b/script/core/hover/args.lua index d943d11f..c485d9b9 100644 --- a/script/core/hover/args.lua +++ b/script/core/hover/args.lua @@ -1,5 +1,4 @@ local guide = require 'parser.guide' -local infer = require 'vm.infer' local vm = require 'vm' local function asFunction(source) @@ -10,7 +9,7 @@ local function asFunction(source) methodDef = true end if methodDef then - args[#args+1] = ('self: %s'):format(infer.getInfer(parent.node):view 'any') + args[#args+1] = ('self: %s'):format(vm.getInfer(parent.node):view 'any') end if source.args then for i = 1, #source.args do @@ -30,15 +29,15 @@ local function asFunction(source) args[#args+1] = ('%s%s: %s'):format( name, optional and '?' or '', - infer.getInfer(argNode):view('any', guide.getUri(source)) + vm.getInfer(argNode):view('any', guide.getUri(source)) ) elseif arg.type == '...' then args[#args+1] = ('%s: %s'):format( '...', - infer.getInfer(arg):view 'any' + vm.getInfer(arg):view 'any' ) else - args[#args+1] = ('%s'):format(infer.getInfer(arg):view 'any') + args[#args+1] = ('%s'):format(vm.getInfer(arg):view 'any') end ::CONTINUE:: end @@ -57,7 +56,7 @@ local function asDocFunction(source) args[i] = ('%s%s: %s'):format( name, arg.optional and '?' or '', - arg.extends and infer.getInfer(arg.extends):view 'any' or 'any' + arg.extends and vm.getInfer(arg.extends):view 'any' or 'any' ) end return args diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index 03f6128a..e9267c0f 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -6,7 +6,6 @@ local lang = require 'language' local util = require 'utility' local guide = require 'parser.guide' local rpath = require 'workspace.require-path' -local infer = require 'vm.infer' local function collectRequire(mode, literal, uri) local result, searchers @@ -153,7 +152,7 @@ local function buildEnumChunk(docType, name) local types = {} local lines = {} for _, tp in ipairs(vm.getDefs(docType)) do - types[#types+1] = infer.getInfer(tp):view() + types[#types+1] = vm.getInfer(tp):view() if tp.type == 'doc.type.string' or tp.type == 'doc.type.integer' or tp.type == 'doc.type.boolean' then @@ -175,7 +174,7 @@ local function buildEnumChunk(docType, name) (enum.default and '->') or (enum.additional and '+>') or ' |', - infer.viewObject(enum) + vm.viewObject(enum) ) if enum.comment then local first = true diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua index 89e3cc94..9d855894 100644 --- a/script/core/hover/init.lua +++ b/script/core/hover/init.lua @@ -5,7 +5,6 @@ local getDesc = require 'core.hover.description' local util = require 'utility' local findSource = require 'core.find-source' local markdown = require 'provider.markdown' -local infer = require 'vm.infer' local guide = require 'parser.guide' ---@async @@ -40,7 +39,7 @@ local function getHover(source) end local oop - if infer.getInfer(source):view() == 'function' then + if vm.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 f19bca10..2bbfe806 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -2,7 +2,6 @@ local buildName = require 'core.hover.name' local buildArgs = require 'core.hover.args' local buildReturn = require 'core.hover.return' local buildTable = require 'core.hover.table' -local infer = require 'vm.infer' local vm = require 'vm' local util = require 'utility' local lang = require 'language' @@ -34,7 +33,7 @@ local function asDocTypeName(source) return '(class) ' .. doc.class[1] end if doc.type == 'doc.alias' then - return '(alias) ' .. doc.alias[1] .. ' ' .. lang.script('HOVER_EXTENDS', infer.getInfer(doc.extends):view()) + return '(alias) ' .. doc.alias[1] .. ' ' .. lang.script('HOVER_EXTENDS', vm.getInfer(doc.extends):view()) end end end @@ -42,7 +41,7 @@ end ---@async local function asValue(source, title) local name = buildName(source, false) or '' - local ifr = infer.getInfer(source) + local ifr = vm.getInfer(source) local type = ifr:view() local literal = ifr:viewLiterals() local cont = buildTable(source) @@ -140,7 +139,7 @@ local function asDocFieldName(source) break end end - local view = infer.getInfer(source.extends):view() + local view = vm.getInfer(source.extends):view() if not class then return ('(field) ?.%s: %s'):format(name, view) end diff --git a/script/core/hover/name.lua b/script/core/hover/name.lua index 905c5ec7..f8473638 100644 --- a/script/core/hover/name.lua +++ b/script/core/hover/name.lua @@ -1,5 +1,5 @@ -local infer = require 'vm.infer' local guide = require 'parser.guide' +local vm = require 'vm' local buildName @@ -19,7 +19,7 @@ end local function asField(source, oop) local class if source.node.type ~= 'getglobal' then - class = infer.getInfer(source.node):viewClass() + class = vm.getInfer(source.node):viewClass() end local node = class or buildName(source.node, false) diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua index 93ff1f6c..3d8a94a5 100644 --- a/script/core/hover/return.lua +++ b/script/core/hover/return.lua @@ -1,5 +1,3 @@ -local infer = require 'vm.infer' -local guide = require 'parser.guide' local vm = require 'vm.vm' ---@param source parser.object @@ -67,7 +65,7 @@ local function asFunction(source) local name = doc and doc.name and doc.name[1] and (doc.name[1] .. ': ') local text = ('%s%s'):format( name or '', - infer.getInfer(rtn):view() + vm.getInfer(rtn):view() ) if i == 1 then returns[i] = (' -> %s'):format(text) @@ -85,7 +83,7 @@ local function asDocFunction(source) end local returns = {} for i, rtn in ipairs(source.returns) do - local rtnText = infer.getInfer(rtn):view() + local rtnText = vm.getInfer(rtn):view() if i == 1 then returns[#returns+1] = (' -> %s'):format(rtnText) else diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua index 264caa64..16874101 100644 --- a/script/core/hover/table.lua +++ b/script/core/hover/table.lua @@ -1,7 +1,6 @@ local vm = require 'vm' local util = require 'utility' local config = require 'config' -local infer = require 'vm.infer' local await = require 'await' local guide = require 'parser.guide' @@ -30,7 +29,7 @@ local function buildAsHash(uri, keys, nodeMap, reachMax) node = node:copy() node:removeOptional() end - local ifr = infer.getInfer(node) + local ifr = vm.getInfer(node) local typeView = ifr:view('unknown', uri) local literalView = ifr:viewLiterals() if literalView then @@ -62,7 +61,7 @@ end local function buildAsConst(uri, keys, nodeMap, reachMax) local literalMap = {} for _, key in ipairs(keys) do - literalMap[key] = infer.getInfer(nodeMap[key]):viewLiterals() + literalMap[key] = vm.getInfer(nodeMap[key]):viewLiterals() end table.sort(keys, function (a, b) return tonumber(literalMap[a]) < tonumber(literalMap[b]) @@ -76,7 +75,7 @@ local function buildAsConst(uri, keys, nodeMap, reachMax) node = node:copy() node:removeOptional() end - local typeView = infer.getInfer(node):view('unknown', uri) + local typeView = vm.getInfer(node):view('unknown', uri) local literalView = literalMap[key] if literalView then lines[#lines+1] = (' %s%s: %s = %s,'):format( @@ -179,7 +178,7 @@ return function (source) return nil end - for view in infer.getInfer(source):eachView() do + for view in vm.getInfer(source):eachView() do if view == 'string' or vm.isSubType(uri, view, 'string') then return nil @@ -206,7 +205,7 @@ return function (source) for i = 1, #keys do await.delay() local key = keys[i] - local literal = infer.getInfer(nodeMap[key]):viewLiterals() + local literal = vm.getInfer(nodeMap[key]):viewLiterals() if not tonumber(literal) then isConsts = false end diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index d42e5b04..bcba27a9 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -5,7 +5,6 @@ local vm = require 'vm' local util = require 'utility' local guide = require 'parser.guide' local converter = require 'proto.converter' -local infer = require 'vm.infer' local config = require 'config' local linkedTable = require 'linked-table' local globalMgr = require 'vm.global-manager' @@ -34,7 +33,7 @@ local Care = util.switch() end options.libGlobals[name] = isLib end - local isFunc = infer.getInfer(source):hasFunction() + local isFunc = vm.getInfer(source):hasFunction() local type = isFunc and define.TokenTypes['function'] or define.TokenTypes.variable local modifier = isLib and define.TokenModifiers.defaultLibrary or define.TokenModifiers.static @@ -83,7 +82,7 @@ local Care = util.switch() return end end - if infer.getInfer(source):hasFunction() then + if vm.getInfer(source):hasFunction() then results[#results+1] = { start = source.start, finish = source.finish, @@ -198,7 +197,7 @@ local Care = util.switch() end end -- 6. References to other functions - if infer.getInfer(loc):hasFunction() then + if vm.getInfer(loc):hasFunction() then results[#results+1] = { start = source.start, finish = source.finish, diff --git a/script/core/type-definition.lua b/script/core/type-definition.lua index 92f81997..d8434c8c 100644 --- a/script/core/type-definition.lua +++ b/script/core/type-definition.lua @@ -3,7 +3,6 @@ local files = require 'files' local vm = require 'vm' local findSource = require 'core.find-source' local guide = require 'parser.guide' -local infer = require 'vm.infer' local rpath = require 'workspace.require-path' local function sortResults(results) |