-
Notifications
You must be signed in to change notification settings - Fork 338
Description
Implementing refactoring actions in swift-syntax instead of in sourcekitd makes them more robust and easier to maintain going forward. A full list of refactoring actions implemented in sourcekitd is at https://github.com/swiftlang/swift/blob/9b452820367ccc7b5d9effbc1565bcd945c81768/include/swift/Refactoring/RefactoringKinds.def#L21-L92. Only refactoring actions that don’t require (too much) semantic knowledge about types can be implemented in swift-syntax. I think the following can be implemented in swift-syntax. Once these are implemented in swift-syntax, we should suppress the corresponding sourcekitd refactoring in SourceKit-LSP based on its ID. The original implementation of these refactoring actions can be found in https://github.com/swiftlang/swift by searching for the refactoring’s name.
No type information required (easier to implement):
- ConvertToComputedProperty (Add new features to ConvertStoredPropertyToComputed swift-syntax#3229)
- CollapseNestedIfStmt
- ConvertToSwitchStmt
- ConvertToTernaryExpr (Refactor ConvertToTernaryExpr swift-syntax#3252)
- ExpandTernaryExpr (Implement ExpandTernaryExpr mirroring sourcekitd implementation swift-syntax#3247)
- MoveMembersToExtension
Require type information that can be retrived using a cursor info (harder to implement because we don’t have a blueprint for this at the moment):
- ExtractExpr
- ExtractFunction
- ExtractRepeatedExpr
- MemberwiseInitLocalRefactoring
If you are interested in working on this, please open a separate PR for each refactoring action.