Skip to content

Feat(SwiftRefactor): Implement InvertIfCondition refactoring - #3424

Open
amanmaurya92 wants to merge 1 commit into
swiftlang:mainfrom
amanmaurya92:feat/invert-if-condition
Open

amanmaurya92 wants to merge 1 commit into
swiftlang:mainfrom
amanmaurya92:feat/invert-if-condition

Conversation

@amanmaurya92

Copy link
Copy Markdown

Description

This PR implements the InvertIfCondition refactoring action in SwiftRefactor, which supersedes stale PR #3263 and addresses maintainer review feedback for swiftlang/sourcekit-lsp#2408.

Transformation:

// Before
if !x {
  foo()
} else {
  bar()
}

// After
if x {
  bar()
} else {
  foo()
}

Implement the InvertIfCondition refactoring action in SwiftRefactor
which inverts a negated if condition and swaps the then and else branches.

Co-authored-by: Rick Hohler <rick.hohler@gmail.com>
Resolves swiftlang/sourcekit-lsp#2408
@amanmaurya92

Copy link
Copy Markdown
Author

@rintaro @hborla @hamishknight can you please review this implementation and approve the workflows?

@amanmaurya92

Copy link
Copy Markdown
Author

@ahoppen can you please approve the workflows?

@ahoppen

ahoppen commented Sep 14, 2026

Copy link
Copy Markdown
Member

Since #3263 was opened, we have decided that refactoring actions should generally be implemented in SourceKit-LSP. Could you open a PR in that repo? Thanks!

@amanmaurya92

Copy link
Copy Markdown
Author

Since #3263 was opened, we have decided that refactoring actions should generally be implemented in SourceKit-LSP. Could you open a PR in that repo? Thanks!

Yes, no problem

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