Skip to content

Rewrite syntactic refactoring actions in sourcekitd using swift-syntax #2424

@ahoppen

Description

@ahoppen

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):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions