Skip to content

Commit b24a140

Browse files
committed
fix(diagnostics): fix bind doc comments not being detected for a.b = c style in missing-export-doc
1 parent dd52dcc commit b24a140

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ end
3939
---@param functionName string
4040
---@param source parser.object
4141
---@param diagnosticRangeSource? parser.object sometimes the object with the data isn't the one that needs the diagnostics
42+
---@param bindDocsSource? parser.object sometimes the object with the bind docs isn't the value (`a.b = c` syntax)
4243
---@param callback fun(result: any)
4344
---@param commentId string
4445
---@param paramId string
4546
---@param returnId string
46-
local function checkFunctionNamed(functionName, source, diagnosticRangeSource, callback, commentId, paramId, returnId)
47+
local function checkFunctionNamed(functionName, source, diagnosticRangeSource, bindDocsSource, callback, commentId,
48+
paramId, returnId)
4749
diagnosticRangeSource = diagnosticRangeSource or source
50+
bindDocsSource = bindDocsSource or source
4851
local argCount = diagnosticRangeSource.args and #diagnosticRangeSource.args or 0
4952

50-
if argCount == 0 and not source.returns and not source.bindDocs then
53+
if argCount == 0 and not source.returns and not bindDocsSource.bindDocs then
5154
callback {
5255
start = diagnosticRangeSource.start,
5356
finish = diagnosticRangeSource.finish,
@@ -60,7 +63,7 @@ local function checkFunctionNamed(functionName, source, diagnosticRangeSource, c
6063
local argName = arg[1]
6164
if argName ~= 'self'
6265
and argName ~= '_' then
63-
if not findParam(source.bindDocs, argName) then
66+
if not findParam(bindDocsSource.bindDocs, argName) then
6467
callback {
6568
start = arg.start,
6669
finish = arg.finish,
@@ -74,7 +77,7 @@ local function checkFunctionNamed(functionName, source, diagnosticRangeSource, c
7477
if source.returns then
7578
for _, ret in ipairs(source.returns) do
7679
for index, expr in ipairs(ret) do
77-
if not findReturn(source.bindDocs, index) then
80+
if not findReturn(bindDocsSource.bindDocs, index) then
7881
callback {
7982
start = expr.start,
8083
finish = expr.finish,
@@ -93,7 +96,7 @@ end
9396
---@param returnId string
9497
local function checkFunction(source, callback, commentId, paramId, returnId)
9598
local functionName = source.parent[1]
96-
checkFunctionNamed(functionName, source, nil, callback, commentId, paramId, returnId)
99+
checkFunctionNamed(functionName, source, nil, nil, callback, commentId, paramId, returnId)
97100
end
98101

99102

@@ -104,7 +107,7 @@ end
104107
---@param returnId string
105108
local function checkMethod(source, callback, commentId, paramId, returnId)
106109
local functionName = source.method[1]
107-
checkFunctionNamed(functionName, source.value, source.method, callback, commentId, paramId, returnId)
110+
checkFunctionNamed(functionName, source.value, source.method, nil, callback, commentId, paramId, returnId)
108111
end
109112

110113
m.CheckFunction = checkFunction

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ 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, nil, callback,
22+
helper.CheckFunctionNamed(source.field[1], source.value, nil, source, callback,
2323
'DIAG_MISSING_EXPORTED_FIELD_DOC_COMMENT',
2424
'DIAG_MISSING_EXPORTED_FIELD_DOC_PARAM',
2525
'DIAG_MISSING_EXPORTED_FIELD_DOC_RETURN')

0 commit comments

Comments
 (0)