Skip to content

[AST] don't break a doc comment with a regular comment - #66136

Merged
QuietMisdreavus merged 1 commit into
mainfrom
QuietMisdreavus/comment-attachment
May 30, 2023
Merged

QuietMisdreavus merged 1 commit into
mainfrom
QuietMisdreavus/comment-attachment

Conversation

@QuietMisdreavus

Copy link
Copy Markdown
Contributor

Resolves rdar://95307936

When a declaration has a regular comment between its doc comment and the declaration itself, that doc comment is lost:

/// This is documentation
// This is a comment
public func myFunc() {}

This PR changes the comment attachment rules to skip over ordinary comments instead of using them to break them apart like a blank line would.

Notably, this change surfaced a bug in the standard library documentation: The default implementation of the != operator in Equatable had a regular comment between the doc comment and the declaration, causing that documentation to be lost. (This is why i had to update the tests in test/SourceKit/DocSupport, because the documentation for != started showing up!)

@QuietMisdreavus

Copy link
Copy Markdown
Contributor Author

@swift-ci Please test

@bnbarham bnbarham left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me, thanks @QuietMisdreavus! I don't think I had any good reason for not doing this in 22f5983, probably just went with keeping the current behavior assuming there was a good reason for it.

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Makes sense to me

@QuietMisdreavus

Copy link
Copy Markdown
Contributor Author

@swift-ci Please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants