Skip to content

Commit 6c613e6

Browse files
committed
test(diagnostics): the function node on a method isn't a direct ancestor in the ast so just wrap the args and name in the diagnostic for missing-export-doc
1 parent b24a140 commit 6c613e6

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ end
107107
---@param returnId string
108108
local function checkMethod(source, callback, commentId, paramId, returnId)
109109
local functionName = source.method[1]
110-
checkFunctionNamed(functionName, source.value, source.method, nil, callback, commentId, paramId, returnId)
110+
checkFunctionNamed(functionName, source.value, source, nil, callback, commentId, paramId, returnId)
111111
end
112112

113113
m.CheckFunction = checkFunction

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ 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, source, callback,
22+
23+
-- TODO: find a better way to distinguish a.b = function and function a.b, or alternatively make them both work
24+
-- the same way?
25+
-- the issue is they have very similar ASTs but bindDocs is either inside or outside value
26+
27+
helper.CheckFunctionNamed(source.field[1], source.value, nil, source.bindDocs and source or source.value,
28+
callback,
2329
'DIAG_MISSING_EXPORTED_FIELD_DOC_COMMENT',
2430
'DIAG_MISSING_EXPORTED_FIELD_DOC_PARAM',
2531
'DIAG_MISSING_EXPORTED_FIELD_DOC_RETURN')

test/diagnostics/missing-export-doc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end
7070
TEST [[
7171
local M = {}
7272
73-
<!function M:f1() end!>
73+
function <!M:f1()!> end
7474
7575
---comment
7676
function M:f2()

0 commit comments

Comments
 (0)