Skip to content

Move SwiftRefactor code actions from swift-syntax into sourcekit-lsp #2639

Description

@rintaro

Per the Code Action contributor documentation, code actions should generally be implemented in sourcekit-lsp since they are primarily a language-server feature, and should only be implemented in swift-syntax when the functionality needs to be reused outside of the language server.

Several code actions are currently implemented as SyntaxRefactoringProvider conformances in swift-syntax/Sources/SwiftRefactor/, but their only consumer is sourcekit-lsp, which wraps them via the SyntaxRefactoringCodeActionProvider adapter. These should be moved to sourcekit-lsp directly as SyntaxCodeActionProvider types.

Actions to move:

  • AddSeparatorsToIntegerLiteral — "Add digit separators"
  • ConvertComputedPropertyToStored — "Convert to stored property"
  • ConvertComputedPropertyToZeroParameterFunction — "Convert to zero parameter function"
  • ConvertStoredPropertyToComputed — "Convert to computed property" (currently not wired up)
  • ConvertZeroParameterFunctionToComputedProperty — "Convert to computed property"
  • FormatRawStringLiteral — "Convert string literal to minimal number of '#'s"
  • MigrateToNewIfLetSyntax — "Migrate to shorthand 'if let' syntax"
  • OpaqueParameterToGeneric — "Expand 'some' parameters to generic parameters"
  • RemoveRedundantParentheses — "Remove Redundant Parentheses"
  • RemoveSeparatorsFromIntegerLiteral — "Remove digit separators"

Out of scope:

  • ExpandEditorPlaceholdersToLiteralClosures and its supporting types (ExpandEditorPlaceholder, ExpandSingleEditorPlaceholder) — used directly in sourcekit-lsp's code completion, not as a code action
  • CallToTrailingClosures — used as an internal implementation detail of ExpandEditorPlaceholder within swift-syntax
  • PackageManifest/ refactorings (AddPackageDependency, AddPackageTarget, AddProduct, etc.) — used as building blocks for structured manifest editing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions