Skip to content

Commit f644444

Browse files
committed
fix(diagnostics): fix methods never being accepted for missing-export-doc
1 parent 6743fbd commit f644444

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

script/core/diagnostics/helper/missing-doc-helper.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ end
3838

3939
---@param functionName string
4040
---@param source parser.object
41+
---@param bindDocsSource parser.object? sometimes the object with the bindDocs isn't the function, use this to specify what has them
4142
---@param callback fun(result: any)
4243
---@param commentId string
4344
---@param paramId string
4445
---@param returnId string
45-
local function checkFunctionNamed(functionName, source, callback, commentId, paramId, returnId)
46+
local function checkFunctionNamed(functionName, source, bindDocsSource, callback, commentId, paramId, returnId)
4647
local argCount = source.args and #source.args or 0
48+
bindDocsSource = bindDocsSource or source
4749

48-
if argCount == 0 and not source.returns and not source.bindDocs then
50+
if argCount == 0 and not source.returns and not bindDocsSource.bindDocs then
4951
callback {
5052
start = source.start,
5153
finish = source.finish,
@@ -58,7 +60,7 @@ local function checkFunctionNamed(functionName, source, callback, commentId, par
5860
local argName = arg[1]
5961
if argName ~= 'self'
6062
and argName ~= '_' then
61-
if not findParam(source.bindDocs, argName) then
63+
if not findParam(bindDocsSource.bindDocs, argName) then
6264
callback {
6365
start = arg.start,
6466
finish = arg.finish,
@@ -91,7 +93,7 @@ end
9193
---@param returnId string
9294
local function checkFunction(source, callback, commentId, paramId, returnId)
9395
local functionName = source.parent[1]
94-
checkFunctionNamed(functionName, source, callback, commentId, paramId, returnId)
96+
checkFunctionNamed(functionName, source, nil, callback, commentId, paramId, returnId)
9597
end
9698

9799

@@ -101,8 +103,8 @@ end
101103
---@param paramId string
102104
---@param returnId string
103105
local function checkMethod(source, callback, commentId, paramId, returnId)
104-
local functionName = source[1]
105-
checkFunctionNamed(functionName, source, callback, commentId, paramId, returnId)
106+
local functionName = source.method[1]
107+
checkFunctionNamed(functionName, source.method, source.value, callback, commentId, paramId, returnId)
106108
end
107109

108110
m.CheckFunction = checkFunction

script/core/diagnostics/missing-export-doc.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ return function (uri, callback)
1919
guide.eachSourceType(state.ast, 'setfield', function (source)
2020
await.delay()
2121
if source.value.type ~= "function" then return end
22-
helper.CheckFunctionNamed(source.field[1], source.value, callback, 'DIAG_MISSING_EXPORTED_FIELD_DOC_COMMENT',
22+
helper.CheckFunctionNamed(source.field[1], source.value, source.value, callback,
23+
'DIAG_MISSING_EXPORTED_FIELD_DOC_COMMENT',
2324
'DIAG_MISSING_EXPORTED_FIELD_DOC_PARAM',
2425
'DIAG_MISSING_EXPORTED_FIELD_DOC_RETURN')
2526
end)
2627

2728
---@async
2829
guide.eachSourceType(state.ast, 'setmethod', function (source)
2930
await.delay()
30-
helper.CheckMethod(source.method, callback, 'DIAG_MISSING_EXPORTED_METHOD_DOC_COMMENT',
31+
helper.CheckMethod(source, callback, 'DIAG_MISSING_EXPORTED_METHOD_DOC_COMMENT',
3132
'DIAG_MISSING_EXPORTED_METHOD_DOC_PARAM',
3233
'DIAG_MISSING_EXPORTED_METHOD_DOC_RETURN')
3334
end)

0 commit comments

Comments
 (0)