Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/dparse/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,10 @@ class Parser
mixin(parseNodeQ!(`node.constraint`, `Constraint`));

mixin(parseNodeQ!(`node.functionBody`, `FunctionBody`));
if (node.functionBody &&
node.functionBody.specifiedFunctionBody &&
node.functionBody.specifiedFunctionBody.blockStatement)
attachComment(node, node.functionBody.specifiedFunctionBody.blockStatement.tokens[$ - 1].trailingComment);
ownArray(node.memberFunctionAttributes, memberFunctionAttributes);
node.tokens = tokens[startIndex .. index];
return node;
Expand Down Expand Up @@ -8933,21 +8937,26 @@ protected: final:
~ `else {` ~ Exp ~ ` = *t; }}`;
}

T attachCommentFromSemicolon(T)(T node, size_t startIndex)
void attachComment(T)(T node, string comment)
{
auto semicolon = expect(tok!";");
if (semicolon is null)
return null;
if (semicolon.trailingComment !is null)
if (comment !is null)
{
if (node.comment is null)
node.comment = semicolon.trailingComment;
node.comment = comment;
else
{
node.comment ~= "\n";
node.comment ~= semicolon.trailingComment;
node.comment ~= comment;
}
}
}

T attachCommentFromSemicolon(T)(T node, size_t startIndex)
{
auto semicolon = expect(tok!";");
if (semicolon is null)
return null;
attachComment(node, semicolon.trailingComment);
if (node) node.tokens = tokens[startIndex .. index];
return node;
}
Expand Down
1 change: 1 addition & 0 deletions test/ast_checks/oneLineFunctionDoc.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void fun() {} /// Test
1 change: 1 addition & 0 deletions test/ast_checks/oneLineFunctionDoc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//functionDeclaration/ddoc