Xcode Refactor Actions and VS Code Code Actions

Digging the swiftlang repositories I've found two different groups of refactors actions:

swift: swift/lib/Refactoring at main · swiftlang/swift · GitHub
swift-syntax: swift-syntax/Sources/SwiftRefactor at main · swiftlang/swift-syntax · GitHub

But it doesn't seem like the ones in SwiftRefactor are available neither in Xcode nor in VS Code. Will SourceKit-LSP eventually call these instead the swift/lib/Refactoring ones?

Hi Mateus,

The refactoring actions from SwiftRefactor are available in VS Code if you use a Swift 6.0 toolchain, the hook is here: sourcekit-lsp/Sources/SourceKitLSP/Swift/CodeActions/SyntaxCodeActions.swift at 3b16288c6cc9e883587eee254048188536a420c7 · swiftlang/sourcekit-lsp · GitHub

The idea is that the SwiftRefactor actions are syntactic (don’t require information from the type checker) while the ones in swift/lib/Refactoring to require type information. I think lib/Refactoring still contains a few refactoring at the moment that are syntactic because they pre-date swift-syntax.

1 Like

I see, thanks! Is the omission of some of them, like ConvertZeroParameterFunctionToComputedProperty, intentional?