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

Preserve semicolons between call expressions and dead lambdas. #276

Closed
wants to merge 1 commit into from

Conversation

nreid260
Copy link
Contributor

@nreid260 nreid260 commented Feb 9, 2022

It's possible that removing such semicolons can change the behaviour of the code by reinterpreting the dead lambda as a trailing lambda.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 9, 2022
@cgrushko
Copy link
Contributor

cgrushko commented Feb 9, 2022

This addresses #262 if I'm not mistaken?

@cgrushko
Copy link
Contributor

cgrushko commented Feb 9, 2022

I'm going to import this so it's easier to review and test it on our repo.

@facebook-github-bot
Copy link
Contributor

@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

prevLeaf is KtContainerNodeForControlStructureBody &&
prevLeaf.text.isEmpty()) {
return false
}
val nextConcreteSibling = element.getNextSiblingIgnoringWhitespaceAndComments()
if (prevConcreteSibling is KtCallExpression && nextConcreteSibling is KtLambdaExpression) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment with an example that this clause catches? it makes it easier to navigate the code afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

It's possible that removing such semicolons can change the behaviour of the code by reinterpreting the dead lambda as a trailing lambda.

This change also improves semicolon preservation when there are comments and whitespace adjacent to the semicolon.
@facebook-github-bot
Copy link
Contributor

@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@nreid260 nreid260 deleted the nreid260 branch February 10, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants