Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing newlines after docComments in generated code #55128

Closed
DanTup opened this issue Mar 7, 2024 · 3 comments
Closed

Missing newlines after docComments in generated code #55128

DanTup opened this issue Mar 7, 2024 · 3 comments
Assignees
Labels
area-fe-analyzer-shared Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer. cfe-feature-macros Implement macros features in the CFE feature-macros Implementation of the macros feature

Comments

@DanTup
Copy link
Collaborator

DanTup commented Mar 7, 2024

Given this macro:

macro class WithDoc implements MethodDefinitionMacro {
  const WithDoc();

  @override
  void buildDefinitionForMethod(
    MethodDeclaration method,
    FunctionDefinitionBuilder builder,
  )  {
    builder.augment(
      FunctionBodyCode.fromString('''
{
  throw UnimplementedError();
}
'''),
      docComments: CommentCode.fromString('  /// This is an empty method'),
    );
  }
}

You get generated code like this:

augment class B {
  /// This is an empty method  augment void a() {
  throw UnimplementedError();
}

}

There is no newline after the doc comment so augment void a() { is commented out and the code is invalid.

image

@lrhn lrhn added area-front-end Use area-front-end for front end / CFE / kernel format related issues. feature-macros Implementation of the macros feature labels Mar 7, 2024
@lrhn
Copy link
Member

lrhn commented Mar 7, 2024

(Should we have an "area-macros" for the implementation of macros?)

@johnniwinther johnniwinther added area-fe-analyzer-shared Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer. and removed area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Mar 7, 2024
@johnniwinther
Copy link
Member

@jakemac53 I think this comes from the shared code.

@johnniwinther johnniwinther added the cfe-feature-macros Implement macros features in the CFE label Mar 7, 2024
@jakemac53 jakemac53 self-assigned this Mar 7, 2024
@jakemac53
Copy link
Contributor

copybara-service bot pushed a commit that referenced this issue Mar 7, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-fe-analyzer-shared Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer. cfe-feature-macros Implement macros features in the CFE feature-macros Implementation of the macros feature
Projects
Development

No branches or pull requests

4 participants