Skip to content

Conversation

kitbellew
Copy link
Collaborator

@kitbellew kitbellew commented Mar 16, 2024

Previously, we'd handle the case of foo(x => { ... }) by:

  1. replacing the ( with a {
  2. "pretending" to replace the { with a (
  3. upon encountering the } for a fake (, removing the ( and changing on the owner of the }
  4. then removing the )

Instead, let's modify steps 2, 3 and 4 as follows:

  1. remove {
  2. remove }
  3. replace the closing ) with a } moving it to the position of the } in step 3, along with token ownership.

Previously, we'd handle the case of `foo(x => { ... })` by:
1. replacing the `(` with a `{`
2. "pretending" to replace the `{` with a `(`
3. upon encountering the `}` for a fake `(`, removing the `(` and
   changing on the owner of the `}`
4. then removing the `)`

Instead, let's modify steps 2, 3 and 4 as follows:
2. remove `{`
3. remove `}`
4. replace the closing `)` with a `}` moving it to the position of the
   `}` in step 3, along with token ownership.
@kitbellew kitbellew changed the title FormatTokens: improve token lookup when rewritten RedundantBraces: fix "moving" braces around func Mar 16, 2024
@kitbellew kitbellew requested a review from tgodzik March 16, 2024 14:44
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

@kitbellew kitbellew merged commit 06d3195 into scalameta:master Mar 16, 2024
@kitbellew kitbellew deleted the 3812_7 branch March 16, 2024 18:32
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