Skip to content

Commit

Permalink
add newline after doc comments, add tests for doc comments
Browse files Browse the repository at this point in the history
Bug: #55128
Change-Id: I6897e33ad291093d460e28a0b0f374d6504418e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356260
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
jakemac53 authored and Commit Queue committed Mar 7, 2024
1 parent 0f1addd commit f2e8464
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ DeclarationCode _buildFunctionAugmentation(
assert(initializers == null || declaration is ConstructorDeclaration);

return new DeclarationCode.fromParts([
if (docComments != null) docComments,
if (docComments != null) ...[docComments, '\n'],
if (declaration is MethodDeclaration) ' ',
'augment ',
if (declaration is ConstructorDeclaration) ...[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ class LibraryInfo {
expect(
result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
// A comment!
augment String myFunction() {
print('isExternal: false');
print('isGetter: false');
Expand Down Expand Up @@ -733,6 +734,7 @@ class LibraryInfo {
expect(
result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
// A comment!
augment String get myVariable {
print('isExternal: false');
print('isGetter: true');
Expand All @@ -754,6 +756,7 @@ class LibraryInfo {
expect(
result.libraryAugmentations.single.debugString().toString(),
equalsIgnoringWhitespace('''
// A comment!
augment void set myVariable(String value, ) {
print('isExternal: false');
print('isGetter: false');
Expand Down Expand Up @@ -1020,6 +1023,7 @@ final fieldDefinitionMatchers = [

final methodDefinitionMatchers = [
equalsIgnoringWhitespace('''
// A comment!
augment (String, bool? hello, {String world}) myMethod() {
print('definingClass: MyClass');
print('isExternal: false');
Expand Down Expand Up @@ -1050,6 +1054,7 @@ final methodDefinitionMatchers = [

final mixinMethodDefinitionMatchers = [
equalsIgnoringWhitespace('''
// A comment!
augment (String, bool? hello, {String world}) myMixinMethod() {
print('definingClass: MyMixin');
print('isExternal: false');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ class SimpleMacro
@override
Future<void> buildDefinitionForFunction(
FunctionDeclaration function, FunctionDefinitionBuilder builder) async {
builder.augment(await _buildFunctionAugmentation(function, builder));
builder.augment(await _buildFunctionAugmentation(function, builder),
docComments: CommentCode.fromString('// A comment!'));
}

@override
Expand Down

0 comments on commit f2e8464

Please sign in to comment.