This project implements Inline Function and Inline Call refactoring actions for SourceKit-LSP, enabling developers to replace a function call with the function's body in a single code action.
This is one of the most fundamental refactoring operations — already present in TypeScript (VS Code), Rust (rust-analyzer), Java (IntelliJ), and Kotlin — but entirely missing from Swift tooling. The only existing "inline" action is source.refactoring.kind.inline.macro, which expands Swift macros, a completely different feature.
The project delivers a production-quality inline refactoring handling Swift's unique features: labeled arguments, default parameters, trailing closures, inout parameters, self references in methods, and generic type parameters — using the existing syntactic code action infrastructure and the swift-syntax AST.
Eliminate tedious manual refactoring Inlining a function currently takes 2–5 minutes of manual copy-paste-substitute-adjust. This reduces it to a single keyboard shortcut.
Parity with other languages TypeScript, Rust, Java, and Kotlin all have inline refactoring built in. Swift developers shouldn't have to do this by hand.
Safer code changes
Manual inlining is error-prone — forgotten substitutions, mishandled return statements, broken self references. AST-based refactoring guarantees correctness.
Completes the Extract / Inline pair SourceKit-LSP already has "Extract to Function" (semantic refactoring via sourcekitd). Inline Function is its inverse. Together they form a complete refactoring pair.
Foundation for future refactorings
The argument matching engine built here directly enables Inline Variable, Inline Into All Callers, and contributes to swift-syntax #2047 — "Add a high-level API to extract an argument from a LabeledExprListSyntax".
SourceKit-LSP routes code action requests through two paths:
Code Action Request (textDocument/codeAction)
|
+----------+----------+
| |
Semantic Path Syntactic Path
(sourcekitd) (pure swift-syntax)
------------- --------------------
Extract Function Integer Literals
Rename String Concatenation
Expand Macro If-let Migration
etc. Opaque → Generic
Add Documentation
** INLINE FUNCTION **
Inline Function belongs in the syntactic path — it operates purely on the swift-syntax AST with no type information from sourcekitd required. This makes it faster (no round-trip) and more reliable (works offline).
| Component | File | Purpose |
|---|---|---|
| Provider protocol | SyntaxCodeActionProvider.swift |
Protocol: codeActions(in scope:) → [CodeAction] |
| Refactoring adapter | SyntaxRefactoringCodeActionProvider.swift |
Adapts EditRefactoringProvider from SwiftRefactor |
| Registration | SyntaxCodeActions.swift (L17–35) |
allSyntaxCodeActions array — add InlineFunction.self here |
| Template | ConvertStringConcatenation…swift |
My PR #2443 — complete reference implementation (227 lines) |