diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-09 16:32:05 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-09 16:32:05 +0800 |
commit | 916b8563cc327af32a5c3dccfdb5434711d83377 (patch) | |
tree | d21c0503425c168ae019e9e358cc278715639eca /script/core | |
parent | 3827d18e5b84d5372334ee8151362f935edf8ac4 (diff) | |
download | lua-language-server-916b8563cc327af32a5c3dccfdb5434711d83377.zip |
view infer must specify uri
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/completion/completion.lua | 12 | ||||
-rw-r--r-- | script/core/diagnostics/close-non-object.lua | 8 | ||||
-rw-r--r-- | script/core/diagnostics/no-unknown.lua | 2 | ||||
-rw-r--r-- | script/core/diagnostics/not-yieldable.lua | 4 | ||||
-rw-r--r-- | script/core/diagnostics/undefined-field.lua | 2 | ||||
-rw-r--r-- | script/core/hint.lua | 2 | ||||
-rw-r--r-- | script/core/hover/args.lua | 10 | ||||
-rw-r--r-- | script/core/hover/description.lua | 2 | ||||
-rw-r--r-- | script/core/hover/init.lua | 2 | ||||
-rw-r--r-- | script/core/hover/label.lua | 6 | ||||
-rw-r--r-- | script/core/hover/return.lua | 5 | ||||
-rw-r--r-- | script/core/hover/table.lua | 6 | ||||
-rw-r--r-- | script/core/semantic-tokens.lua | 6 |
13 files changed, 34 insertions, 33 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index d2d0a040..009b4297 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -184,7 +184,7 @@ local function buildFunctionSnip(source, value, oop) end local function buildDetail(source) - local types = vm.getInfer(source):view() + local types = vm.getInfer(source):view(guide.getUri(source)) local literals = vm.getInfer(source):viewLiterals() if literals then return types .. ' = ' .. literals @@ -302,7 +302,7 @@ local function checkLocal(state, word, position, results) if name:sub(1, 1) == '@' then goto CONTINUE end - if vm.getInfer(source):hasFunction() then + if vm.getInfer(source):hasFunction(state.uri) then local defs = vm.getDefs(source) -- make sure `function` is before `doc.type.function` local orders = {} @@ -513,7 +513,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent }) return end - if oop and not vm.getInfer(src):hasFunction() then + if oop and not vm.getInfer(src):hasFunction(state.uri) then return end local literal = guide.getLiteral(value) @@ -1440,7 +1440,7 @@ local function tryCallArg(state, position, results) : string() end enums[#enums+1] = { - label = vm.getInfer(src):view(), + label = vm.getInfer(src):view(state.uri), description = description, kind = define.CompletionItemKind.Function, insertText = insertText, @@ -1819,14 +1819,14 @@ local function buildluaDocOfFunction(func) local returns = {} if func.args then for _, arg in ipairs(func.args) do - args[#args+1] = vm.getInfer(arg):view() + args[#args+1] = vm.getInfer(arg):view(guide.getUri(func)) 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] = vm.getInfer(rtns[n]):view() + returns[n] = vm.getInfer(rtns[n]):view(guide.getUri(func)) end end end diff --git a/script/core/diagnostics/close-non-object.lua b/script/core/diagnostics/close-non-object.lua index c97014fa..d07aaebe 100644 --- a/script/core/diagnostics/close-non-object.lua +++ b/script/core/diagnostics/close-non-object.lua @@ -25,10 +25,10 @@ return function (uri, callback) return end local infer = vm.getInfer(source.value) - if not infer:hasClass() - and not infer:hasType 'nil' - and not infer:hasType 'table' - and infer:view('any', uri) ~= 'any' then + if not infer:hasClass(uri) + and not infer:hasType(uri, 'nil') + and not infer:hasType(uri, 'table') + and infer:view(uri, 'any') ~= 'any' then callback { start = source.value.start, finish = source.value.finish, diff --git a/script/core/diagnostics/no-unknown.lua b/script/core/diagnostics/no-unknown.lua index 48aab5da..ff9f7a83 100644 --- a/script/core/diagnostics/no-unknown.lua +++ b/script/core/diagnostics/no-unknown.lua @@ -20,7 +20,7 @@ return function (uri, callback) and source.type ~= 'tableindex' then return end - if vm.getInfer(source):view() == 'unknown' then + if vm.getInfer(source):view(uri) == '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 a1c84276..055025d4 100644 --- a/script/core/diagnostics/not-yieldable.lua +++ b/script/core/diagnostics/not-yieldable.lua @@ -11,7 +11,7 @@ local function isYieldAble(defs, i) local arg = def.args and def.args[i] if arg then hasFuncDef = true - if vm.getInfer(arg):hasType 'any' + if vm.getInfer(arg):hasType(guide.getUri(def), 'any') or vm.isAsync(arg, true) or arg.type == '...' then return true @@ -22,7 +22,7 @@ local function isYieldAble(defs, i) local arg = def.args and def.args[i] if arg then hasFuncDef = true - if vm.getInfer(arg.extends):hasType 'any' + if vm.getInfer(arg.extends):hasType(guide.getUri(def), '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 41fcda48..b03838fd 100644 --- a/script/core/diagnostics/undefined-field.lua +++ b/script/core/diagnostics/undefined-field.lua @@ -34,7 +34,7 @@ return function (uri, callback) local node = src.node if node then local ok - for view in vm.getInfer(node):eachView() do + for view in vm.getInfer(node):eachView(uri) do if not skipCheckClass[view] then ok = true break diff --git a/script/core/hint.lua b/script/core/hint.lua index f97cdcec..350dc114 100644 --- a/script/core/hint.lua +++ b/script/core/hint.lua @@ -38,7 +38,7 @@ local function typeHint(uri, results, start, finish) end end await.delay() - local view = vm.getInfer(source):view() + local view = vm.getInfer(source):view(uri) 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 c485d9b9..21e7c00f 100644 --- a/script/core/hover/args.lua +++ b/script/core/hover/args.lua @@ -9,7 +9,7 @@ local function asFunction(source) methodDef = true end if methodDef then - args[#args+1] = ('self: %s'):format(vm.getInfer(parent.node):view 'any') + args[#args+1] = ('self: %s'):format(vm.getInfer(parent.node):view(guide.getUri(source), 'any')) end if source.args then for i = 1, #source.args do @@ -29,15 +29,15 @@ local function asFunction(source) args[#args+1] = ('%s%s: %s'):format( name, optional and '?' or '', - vm.getInfer(argNode):view('any', guide.getUri(source)) + vm.getInfer(argNode):view(guide.getUri(source), 'any') ) elseif arg.type == '...' then args[#args+1] = ('%s: %s'):format( '...', - vm.getInfer(arg):view 'any' + vm.getInfer(arg):view(guide.getUri(source), 'any') ) else - args[#args+1] = ('%s'):format(vm.getInfer(arg):view 'any') + args[#args+1] = ('%s'):format(vm.getInfer(arg):view(guide.getUri(source), 'any')) end ::CONTINUE:: end @@ -56,7 +56,7 @@ local function asDocFunction(source) args[i] = ('%s%s: %s'):format( name, arg.optional and '?' or '', - arg.extends and vm.getInfer(arg.extends):view 'any' or 'any' + arg.extends and vm.getInfer(arg.extends):view(guide.getUri(source), 'any') or 'any' ) end return args diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index 712ea1ad..e3c3f412 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -152,7 +152,7 @@ local function buildEnumChunk(docType, name) local types = {} local lines = {} for _, tp in ipairs(vm.getDefs(docType)) do - types[#types+1] = vm.getInfer(tp):view() + types[#types+1] = vm.getInfer(tp):view(guide.getUri(docType)) if tp.type == 'doc.type.string' or tp.type == 'doc.type.integer' or tp.type == 'doc.type.boolean' then diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua index 7231944a..949156aa 100644 --- a/script/core/hover/init.lua +++ b/script/core/hover/init.lua @@ -39,7 +39,7 @@ local function getHover(source) end local oop - if vm.getInfer(source):view() == 'function' then + if vm.getInfer(source):view(guide.getUri(source)) == 'function' then local defs = vm.getDefs(source) -- make sure `function` is before `doc.type.function` local orders = {} diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index 2bbfe806..e725f6b0 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -33,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', vm.getInfer(doc.extends):view()) + return '(alias) ' .. doc.alias[1] .. ' ' .. lang.script('HOVER_EXTENDS', vm.getInfer(doc.extends):view(guide.getUri(source))) end end end @@ -42,7 +42,7 @@ end local function asValue(source, title) local name = buildName(source, false) or '' local ifr = vm.getInfer(source) - local type = ifr:view() + local type = ifr:view(guide.getUri(source)) local literal = ifr:viewLiterals() local cont = buildTable(source) local pack = {} @@ -139,7 +139,7 @@ local function asDocFieldName(source) break end end - local view = vm.getInfer(source.extends):view() + local view = vm.getInfer(source.extends):view(guide.getUri(source)) 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 3d8a94a5..2ee234b6 100644 --- a/script/core/hover/return.lua +++ b/script/core/hover/return.lua @@ -1,4 +1,5 @@ local vm = require 'vm.vm' +local guide = require 'parser.guide' ---@param source parser.object ---@return integer @@ -65,7 +66,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 '', - vm.getInfer(rtn):view() + vm.getInfer(rtn):view(guide.getUri(source)) ) if i == 1 then returns[i] = (' -> %s'):format(text) @@ -83,7 +84,7 @@ local function asDocFunction(source) end local returns = {} for i, rtn in ipairs(source.returns) do - local rtnText = vm.getInfer(rtn):view() + local rtnText = vm.getInfer(rtn):view(guide.getUri(source)) 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 16874101..97ace24e 100644 --- a/script/core/hover/table.lua +++ b/script/core/hover/table.lua @@ -30,7 +30,7 @@ local function buildAsHash(uri, keys, nodeMap, reachMax) node:removeOptional() end local ifr = vm.getInfer(node) - local typeView = ifr:view('unknown', uri) + local typeView = ifr:view(uri, 'unknown') local literalView = ifr:viewLiterals() if literalView then lines[#lines+1] = (' %s%s: %s = %s,'):format( @@ -75,7 +75,7 @@ local function buildAsConst(uri, keys, nodeMap, reachMax) node = node:copy() node:removeOptional() end - local typeView = vm.getInfer(node):view('unknown', uri) + local typeView = vm.getInfer(node):view(uri, 'unknown') local literalView = literalMap[key] if literalView then lines[#lines+1] = (' %s%s: %s = %s,'):format( @@ -178,7 +178,7 @@ return function (source) return nil end - for view in vm.getInfer(source):eachView() do + for view in vm.getInfer(source):eachView(uri) do if view == 'string' or vm.isSubType(uri, view, 'string') then return nil diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index 33449013..b16f55fd 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -32,7 +32,7 @@ local Care = util.switch() end options.libGlobals[name] = isLib end - local isFunc = vm.getInfer(source):hasFunction() + local isFunc = vm.getInfer(source):hasFunction(guide.getUri(source)) local type = isFunc and define.TokenTypes['function'] or define.TokenTypes.variable local modifier = isLib and define.TokenModifiers.defaultLibrary or define.TokenModifiers.static @@ -81,7 +81,7 @@ local Care = util.switch() return end end - if vm.getInfer(source):hasFunction() then + if vm.getInfer(source):hasFunction(guide.getUri(source)) then results[#results+1] = { start = source.start, finish = source.finish, @@ -196,7 +196,7 @@ local Care = util.switch() end end -- 6. References to other functions - if vm.getInfer(loc):hasFunction() then + if vm.getInfer(loc):hasFunction(guide.getUri(source)) then results[#results+1] = { start = source.start, finish = source.finish, |