Skip to content

Handle chained addition in PreferIncrementOperator#816

Merged
greg-at-moderne merged 4 commits intomainfrom
greg-prefer-increment-complex
Apr 17, 2026
Merged

Handle chained addition in PreferIncrementOperator#816
greg-at-moderne merged 4 commits intomainfrom
greg-prefer-increment-complex

Conversation

@greg-at-moderne
Copy link
Copy Markdown
Contributor

@greg-at-moderne greg-at-moderne commented Feb 20, 2026

What

Enhancing the PreferIncrementOperator recipe to handle more complex expressions of incrementing the value of the variable.

Why

Closes #696

Walk the left spine of binary +/- expressions to find the assigned
variable as the leftmost operand, enabling transformations like
`x = x + a + b + 1` → `x += a + b + 1`.
@greg-at-moderne greg-at-moderne marked this pull request as ready for review April 17, 2026 07:14
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Apr 17, 2026
@greg-at-moderne greg-at-moderne merged commit 47094c2 into main Apr 17, 2026
1 check passed
@greg-at-moderne greg-at-moderne deleted the greg-prefer-increment-complex branch April 17, 2026 09:01
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

PreferIncrementOperator could be amended to handle more complex expressions

2 participants