Skip to content

[Refactoring] Preserve comments in async transform #37387

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

Merged
merged 2 commits into from
May 13, 2021

Conversation

hamishknight
Copy link
Contributor

Previously we would drop comments between nodes in a BraceStmt, as we printed each node out individually. To remedy this, always make sure we scan backwards to find any preceding comments attached to a node. In addition, make sure we keep track of any SourceLocs which we don't print, but may have comments attached which we want to preserve.

rdar://77401810

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight requested a review from bnbarham May 12, 2021 17:59
@swiftlang swiftlang deleted a comment from swift-ci May 12, 2021
@swiftlang swiftlang deleted a comment from swift-ci May 12, 2021
Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

This is awesome, thanks Hamish! Just the one small comment, there'll also be some merge conflicts with mine (I also added a SourceFile)

Previously we would drop comments between nodes in
a BraceStmt, as we printed each node out individually.
To remedy this, always make sure we scan backwards
to find any preceding comments attached to a node,
and also keep track of any SourceLocs which we
don't print, but may have comments attached which
we want to preserve.

rdar://77401810
@swiftlang swiftlang deleted a comment from swift-ci May 13, 2021
@hamishknight
Copy link
Contributor Author

hamishknight commented May 13, 2021

Rebased on top of Ben's change and also added an additional test case to make sure we pickup a trailing comment in a function body if we're converting the function, but not if we're just converting a preceding call.

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please smoke test macOS

@swiftlang swiftlang deleted a comment from swift-ci May 13, 2021
@hamishknight hamishknight merged commit ef318a1 into swiftlang:main May 13, 2021
@hamishknight hamishknight deleted the any-comments branch May 13, 2021 20:09
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.

2 participants