Skip to content

Commit 3b68a53

Browse files
committed
Allow forwarding of the indexedRename request to clangd
The main purpose of this is so we can invoke it from `SkipUnless` to see if `clangd` supports the `workspace/indexedRename` request.
1 parent c340e63 commit 3b68a53

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

Sources/SourceKitLSP/Clang/ClangLanguageServer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ extension ClangLanguageServerShim {
609609
throw ResponseError.unknown("unsupported method")
610610
}
611611

612+
func indexedRename(_ request: IndexedRenameRequest) async throws -> WorkspaceEdit? {
613+
return try await forwardRequestToClangd(request)
614+
}
615+
612616
// MARK: - Other
613617

614618
func executeCommand(_ req: ExecuteCommandRequest) async throws -> LSPAny? {

Sources/SourceKitLSP/Rename.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,14 @@ extension SourceKitServer {
759759
prepareRenameResult.placeholder = oldName.definitionName
760760
return prepareRenameResult
761761
}
762+
763+
func indexedRename(
764+
_ request: IndexedRenameRequest,
765+
workspace: Workspace,
766+
languageService: ToolchainLanguageServer
767+
) async throws -> WorkspaceEdit? {
768+
return try await languageService.indexedRename(request)
769+
}
762770
}
763771

764772
// MARK: - Swift

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ extension SourceKitServer: MessageHandler {
919919
await self.handleRequest(for: request, requestHandler: self.documentDiagnostic)
920920
case let request as RequestAndReply<PrepareRenameRequest>:
921921
await self.handleRequest(for: request, requestHandler: self.prepareRename)
922+
case let request as RequestAndReply<IndexedRenameRequest>:
923+
await self.handleRequest(for: request, requestHandler: self.indexedRename)
922924
// IMPORTANT: When adding a new entry to this switch, also add it to the `TaskMetadata` initializer.
923925
default:
924926
await request.reply { throw ResponseError.methodNotFound(R.method) }

Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,10 @@ extension SwiftLanguageServer {
812812
}
813813
}
814814

815+
public func indexedRename(_ request: IndexedRenameRequest) async throws -> WorkspaceEdit? {
816+
throw ResponseError.unknown("unsupported method")
817+
}
818+
815819
public func executeCommand(_ req: ExecuteCommandRequest) async throws -> LSPAny? {
816820
// TODO: If there's support for several types of commands, we might need to structure this similarly to the code actions request.
817821
guard let sourceKitServer else {

Sources/SourceKitLSP/ToolchainLanguageServer.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public protocol ToolchainLanguageServer: AnyObject {
165165
/// Return compound decl name that will be used as a placeholder for a rename request at a specific position.
166166
func prepareRename(_ request: PrepareRenameRequest) async throws -> PrepareRenameResponse?
167167

168+
func indexedRename(_ request: IndexedRenameRequest) async throws -> WorkspaceEdit?
169+
168170
// MARK: - Other
169171

170172
func executeCommand(_ req: ExecuteCommandRequest) async throws -> LSPAny?

0 commit comments

Comments
 (0)