Skip to content

Attach nearby comments to AST elements #16

@nilium

Description

@nilium

To support tooling that retains comments, like a format tool (such as gofmt), AST nodes should have comments attached to them. How they'll be attached is another question -- possilby with Before []*Comment and Line *Comment fields? That way commends preceding a node are bundled up in before, along with an end-of-line comment.

Reformatting would want to preserve at least one line break between comment blocks, but comment tokens should already retain their line number to make that easier.

This one needs some thinking to determine how to support it, since initial codf design supports comment tokens but does not preserve them in the AST. (Maybe tools shouldn't use the parser?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions