Skip to content

Associate comments on the same line as the closing curly brace with the statement #2

@Hubro

Description

@Hubro

Comments on the same line as a closing curly brace should be associated with the statement, much like comments on the same line as a semi-colon is captured in post_comments.

For example:

type enumeration {
  enum foo { value 10; } // Comment associated with "foo"
  enum bar { value 20; } // Comment associated with "bar"
}

Currently the comments are treated as their own nodes, which leads to this formatting:

type enumeration {
  enum foo {
    value 10;
  }
  // Comment associated with "foo"
  enum bar {
    value 20;
  }
  // Comment associated with "bar"
}

Instead, these comments should be captured into post_comments as well, resulting in the following formatting:

type enumeration {
  enum foo { // Comment associated with "foo"
    value 10;
  }
  enum bar { // Comment associated with "bar"
    value 20;
  }
}

This means it's technically possible for the formatter to put two single-line comments on the same line, but that should never happen in practice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions