Skip to content

Commit 916b856

Browse files
committed
view infer must specify uri
1 parent 3827d18 commit 916b856

File tree

15 files changed

+71
-68
lines changed

15 files changed

+71
-68
lines changed

script/core/completion/completion.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ local function buildFunctionSnip(source, value, oop)
184184
end
185185

186186
local function buildDetail(source)
187-
local types = vm.getInfer(source):view()
187+
local types = vm.getInfer(source):view(guide.getUri(source))
188188
local literals = vm.getInfer(source):viewLiterals()
189189
if literals then
190190
return types .. ' = ' .. literals
@@ -302,7 +302,7 @@ local function checkLocal(state, word, position, results)
302302
if name:sub(1, 1) == '@' then
303303
goto CONTINUE
304304
end
305-
if vm.getInfer(source):hasFunction() then
305+
if vm.getInfer(source):hasFunction(state.uri) then
306306
local defs = vm.getDefs(source)
307307
-- make sure `function` is before `doc.type.function`
308308
local orders = {}
@@ -513,7 +513,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent
513513
})
514514
return
515515
end
516-
if oop and not vm.getInfer(src):hasFunction() then
516+
if oop and not vm.getInfer(src):hasFunction(state.uri) then
517517
return
518518
end
519519
local literal = guide.getLiteral(value)
@@ -1440,7 +1440,7 @@ local function tryCallArg(state, position, results)
14401440
: string()
14411441
end
14421442
enums[#enums+1] = {
1443-
label = vm.getInfer(src):view(),
1443+
label = vm.getInfer(src):view(state.uri),
14441444
description = description,
14451445
kind = define.CompletionItemKind.Function,
14461446
insertText = insertText,
@@ -1819,14 +1819,14 @@ local function buildluaDocOfFunction(func)
18191819
local returns = {}
18201820
if func.args then
18211821
for _, arg in ipairs(func.args) do
1822-
args[#args+1] = vm.getInfer(arg):view()
1822+
args[#args+1] = vm.getInfer(arg):view(guide.getUri(func))
18231823
end
18241824
end
18251825
if func.returns then
18261826
for _, rtns in ipairs(func.returns) do
18271827
for n = 1, #rtns do
18281828
if not returns[n] then
1829-
returns[n] = vm.getInfer(rtns[n]):view()
1829+
returns[n] = vm.getInfer(rtns[n]):view(guide.getUri(func))
18301830
end
18311831
end
18321832
end

script/core/diagnostics/close-non-object.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ return function (uri, callback)
2525
return
2626
end
2727
local infer = vm.getInfer(source.value)
28-
if not infer:hasClass()
29-
and not infer:hasType 'nil'
30-
and not infer:hasType 'table'
31-
and infer:view('any', uri) ~= 'any' then
28+
if not infer:hasClass(uri)
29+
and not infer:hasType(uri, 'nil')
30+
and not infer:hasType(uri, 'table')
31+
and infer:view(uri, 'any') ~= 'any' then
3232
callback {
3333
start = source.value.start,
3434
finish = source.value.finish,

script/core/diagnostics/no-unknown.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ return function (uri, callback)
2020
and source.type ~= 'tableindex' then
2121
return
2222
end
23-
if vm.getInfer(source):view() == 'unknown' then
23+
if vm.getInfer(source):view(uri) == 'unknown' then
2424
callback {
2525
start = source.start,
2626
finish = source.finish,

script/core/diagnostics/not-yieldable.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local function isYieldAble(defs, i)
1111
local arg = def.args and def.args[i]
1212
if arg then
1313
hasFuncDef = true
14-
if vm.getInfer(arg):hasType 'any'
14+
if vm.getInfer(arg):hasType(guide.getUri(def), 'any')
1515
or vm.isAsync(arg, true)
1616
or arg.type == '...' then
1717
return true
@@ -22,7 +22,7 @@ local function isYieldAble(defs, i)
2222
local arg = def.args and def.args[i]
2323
if arg then
2424
hasFuncDef = true
25-
if vm.getInfer(arg.extends):hasType 'any'
25+
if vm.getInfer(arg.extends):hasType(guide.getUri(def), 'any')
2626
or vm.isAsync(arg.extends, true) then
2727
return true
2828
end

script/core/diagnostics/undefined-field.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ return function (uri, callback)
3434
local node = src.node
3535
if node then
3636
local ok
37-
for view in vm.getInfer(node):eachView() do
37+
for view in vm.getInfer(node):eachView(uri) do
3838
if not skipCheckClass[view] then
3939
ok = true
4040
break

script/core/hint.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ local function typeHint(uri, results, start, finish)
3838
end
3939
end
4040
await.delay()
41-
local view = vm.getInfer(source):view()
41+
local view = vm.getInfer(source):view(uri)
4242
if view == 'any'
4343
or view == 'unknown'
4444
or view == 'nil' then

script/core/hover/args.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local function asFunction(source)
99
methodDef = true
1010
end
1111
if methodDef then
12-
args[#args+1] = ('self: %s'):format(vm.getInfer(parent.node):view 'any')
12+
args[#args+1] = ('self: %s'):format(vm.getInfer(parent.node):view(guide.getUri(source), 'any'))
1313
end
1414
if source.args then
1515
for i = 1, #source.args do
@@ -29,15 +29,15 @@ local function asFunction(source)
2929
args[#args+1] = ('%s%s: %s'):format(
3030
name,
3131
optional and '?' or '',
32-
vm.getInfer(argNode):view('any', guide.getUri(source))
32+
vm.getInfer(argNode):view(guide.getUri(source), 'any')
3333
)
3434
elseif arg.type == '...' then
3535
args[#args+1] = ('%s: %s'):format(
3636
'...',
37-
vm.getInfer(arg):view 'any'
37+
vm.getInfer(arg):view(guide.getUri(source), 'any')
3838
)
3939
else
40-
args[#args+1] = ('%s'):format(vm.getInfer(arg):view 'any')
40+
args[#args+1] = ('%s'):format(vm.getInfer(arg):view(guide.getUri(source), 'any'))
4141
end
4242
::CONTINUE::
4343
end
@@ -56,7 +56,7 @@ local function asDocFunction(source)
5656
args[i] = ('%s%s: %s'):format(
5757
name,
5858
arg.optional and '?' or '',
59-
arg.extends and vm.getInfer(arg.extends):view 'any' or 'any'
59+
arg.extends and vm.getInfer(arg.extends):view(guide.getUri(source), 'any') or 'any'
6060
)
6161
end
6262
return args

script/core/hover/description.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ local function buildEnumChunk(docType, name)
152152
local types = {}
153153
local lines = {}
154154
for _, tp in ipairs(vm.getDefs(docType)) do
155-
types[#types+1] = vm.getInfer(tp):view()
155+
types[#types+1] = vm.getInfer(tp):view(guide.getUri(docType))
156156
if tp.type == 'doc.type.string'
157157
or tp.type == 'doc.type.integer'
158158
or tp.type == 'doc.type.boolean' then

script/core/hover/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ local function getHover(source)
3939
end
4040

4141
local oop
42-
if vm.getInfer(source):view() == 'function' then
42+
if vm.getInfer(source):view(guide.getUri(source)) == 'function' then
4343
local defs = vm.getDefs(source)
4444
-- make sure `function` is before `doc.type.function`
4545
local orders = {}

script/core/hover/label.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ local function asDocTypeName(source)
3333
return '(class) ' .. doc.class[1]
3434
end
3535
if doc.type == 'doc.alias' then
36-
return '(alias) ' .. doc.alias[1] .. ' ' .. lang.script('HOVER_EXTENDS', vm.getInfer(doc.extends):view())
36+
return '(alias) ' .. doc.alias[1] .. ' ' .. lang.script('HOVER_EXTENDS', vm.getInfer(doc.extends):view(guide.getUri(source)))
3737
end
3838
end
3939
end
@@ -42,7 +42,7 @@ end
4242
local function asValue(source, title)
4343
local name = buildName(source, false) or ''
4444
local ifr = vm.getInfer(source)
45-
local type = ifr:view()
45+
local type = ifr:view(guide.getUri(source))
4646
local literal = ifr:viewLiterals()
4747
local cont = buildTable(source)
4848
local pack = {}
@@ -139,7 +139,7 @@ local function asDocFieldName(source)
139139
break
140140
end
141141
end
142-
local view = vm.getInfer(source.extends):view()
142+
local view = vm.getInfer(source.extends):view(guide.getUri(source))
143143
if not class then
144144
return ('(field) ?.%s: %s'):format(name, view)
145145
end

0 commit comments

Comments
 (0)