Skip to content

Commit 15e6ed8

Browse files
Merge branch 'master' into doc-update
2 parents 8d31712 + 85f7e6f commit 15e6ed8

File tree

8 files changed

+50
-16
lines changed

8 files changed

+50
-16
lines changed

script/cli/check.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ if not rootUri then
2727
print(lang.script('CLI_CHECK_ERROR_URI', rootPath))
2828
return
2929
end
30+
rootUri = rootUri:gsub("/$", "")
3031

3132
if CHECKLEVEL then
3233
if not define.DiagnosticSeverity[CHECKLEVEL] then
@@ -70,7 +71,7 @@ lclient():start(function (client)
7071
end
7172
config.set(rootUri, 'Lua.diagnostics.disable', util.getTableKeys(disables, true))
7273

73-
local uris = files.getAllUris(rootUri)
74+
local uris = files.getChildFiles(rootUri)
7475
local max = #uris
7576
for i, uri in ipairs(uris) do
7677
files.open(uri)

script/cli/doc.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,12 @@ local function collectTypes(global, results)
189189
field.rawdesc = getDesc(source, true)
190190
field.extends = packObject(source.value)
191191
field.visible = vm.getVisibleType(source)
192+
if vm.isAsync(source, true) then
193+
field.async = true
194+
end
192195
local depr = vm.getDeprecated(source)
193196
if (depr and not depr.versions) then
194-
field.deprecated = true
197+
field.deprecated = true
195198
end
196199
return
197200
end
@@ -254,9 +257,12 @@ local function collectVars(global, results)
254257
result.rawdesc = result.rawdesc or getDesc(set, true)
255258
result.defines[#result.defines].extends['desc'] = getDesc(set)
256259
result.defines[#result.defines].extends['rawdesc'] = getDesc(set, true)
260+
if vm.isAsync(set, true) then
261+
result.defines[#result.defines].extends['async'] = true
262+
end
257263
local depr = vm.getDeprecated(set)
258264
if (depr and not depr.versions) then
259-
result.defines[#result.defines].extends['deprecated'] = true
265+
result.defines[#result.defines].extends['deprecated'] = true
260266
end
261267
end
262268
end

test/diagnostics/await-in-sync.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ end
119119

120120
TEST [[
121121
local function f(cb)
122-
<!cb!>()
122+
cb()
123123
end
124124
125125
local function af()

test/diagnostics/redundant-parameter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ print(1, 2, 3, 4, 5)
9494

9595
TEST [[
9696
local function f(callback)
97-
callback(<!1!>, <!2!>, <!3!>)
97+
callback(1, 2, 3)
9898
end
9999
f(function () end)
100100
]]

test/hover/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ function string.lower(s: string|number)
276276
-> string
277277
]]
278278

279-
-- 根据传入值推测参数类型
279+
-- 不根据传入值推测参数类型
280280
TEST [[
281281
local function x(a, ...)
282282
end
283283
284284
<?x?>(1, 2, 3, 4, 5, 6, 7)
285285
]]
286286
[[
287-
function x(a: integer, ...any)
287+
function x(a: any, ...any)
288288
]]
289289

290290
TEST [[

test/signature/init.lua

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888
8989
x(1, 2, 3, <??>
9090
]]
91-
{'function x(a: integer, <!...any!>)'}
91+
{'function x(a: any, <!...any!>)'}
9292

9393
TEST [[
9494
(''):sub(<??>
@@ -106,7 +106,7 @@ end
106106
107107
f(1, 'string<??>')
108108
]]
109-
{'function f(a: integer, <!b: string!>, c: any)'}
109+
{'function f(a: any, <!b: any!>, c: any)'}
110110

111111
TEST [[
112112
pcall(function () <??> end)
@@ -156,7 +156,7 @@ end
156156
157157
f({},<??>)
158158
]]
159-
{'function f(a: table, <!b: any!>, c: any)'}
159+
{'function f(a: any, <!b: any!>, c: any)'}
160160

161161
TEST [[
162162
for _ in pairs(<??>) do
@@ -188,31 +188,31 @@ end
188188
189189
x( aaaa <??>, 2)
190190
]]
191-
{"function x(<!a: any!>, b: integer)"}
191+
{"function x(<!a: any!>, b: any)"}
192192

193193
TEST [[
194194
local function x(a, b)
195195
end
196196
197197
x(<??> aaaa , 2)
198198
]]
199-
{'function x(<!a: any!>, b: integer)'}
199+
{'function x(<!a: any!>, b: any)'}
200200

201201
TEST [[
202202
local function x(a, b)
203203
end
204204
205205
x(aaaa ,<??> 2)
206206
]]
207-
{'function x(a: any, <!b: integer!>)'}
207+
{'function x(a: any, <!b: any!>)'}
208208

209209
TEST [[
210210
local function x(a, b)
211211
end
212212
213213
x(aaaa , 2 <??>)
214214
]]
215-
{'function x(a: any, <!b: integer!>)'}
215+
{'function x(a: any, <!b: any!>)'}
216216

217217
TEST [[
218218
local fooC
@@ -372,3 +372,30 @@ t:event("onTimer", <??>)
372372
{
373373
'(method) (ev: "onTimer", <!t: integer!>)',
374374
}
375+
376+
local config = require 'config'
377+
config.set(nil, "Lua.type.inferParamType", true)
378+
379+
TEST [[
380+
local function x(a, b)
381+
end
382+
383+
x("1", <??>)
384+
]]
385+
{
386+
'function x(a: string, <!b: any!>)'
387+
}
388+
389+
TEST [[
390+
local function x(a)
391+
392+
end
393+
x('str')
394+
x(1)
395+
x(<??>)
396+
]]
397+
{
398+
'function x(<!a: string|integer!>)',
399+
}
400+
401+
config.set(nil, "Lua.type.inferParamType", false)

0 commit comments

Comments
 (0)