Files
sourcekit-lsp/Sources/SourceKitLSP/Swift/RefactorCommand.swift
Lokesh T R fd50560998 Add LSP support for @freestanding Macro Expansions.
------
Simplify `SemanticRefactoring` with new `Refactoring` protocol to handle sourcekitd requests

Create and implement `ExpandMacroCommand` while temporarily storing generated expansions.

Create test case `testFreestandingMacroExpansion`

Manually inject `ExpandMacroCommand` into `retrieveRefactorCodeActions` upon an "Inline Macro" from sourcekitd

Address Review Comments

Mark `@_spi(Testing) public` for `MacroExpansionEdit`

Address Review Comments

Create separate directory for each buffer with its name, containing a generated file named as the source file along with position range

Fixed generated macro expansion file extension not recognised, by switching to file names which don't contain fragments

Address Review Comments

Wrap the entire feature under `ExperimentalFeatures`

Address Review Comments

Make Swift Lint Pass

Fix Windows Build not passing
2024-06-20 18:14:45 +00:00

32 lines
1.2 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import LanguageServerProtocol
import SourceKitD
/// A protocol to be utilised by all commands that are served by sourcekitd refactorings.
protocol RefactorCommand: SwiftCommand {
/// The response type of the refactor command
associatedtype Response: RefactoringResponse
/// The sourcekitd identifier of the refactoring action.
var actionString: String { get set }
/// The range to refactor.
var positionRange: Range<Position> { get set }
/// The text document related to the refactoring action.
var textDocument: TextDocumentIdentifier { get set }
init(title: String, actionString: String, positionRange: Range<Position>, textDocument: TextDocumentIdentifier)
}