Skip to content

Commit ca8805a

Browse files
authored
Merge pull request #993 from ahoppen/ahoppen/global-rename
2 parents 5435e87 + e08f0a9 commit ca8805a

File tree

12 files changed

+654
-295
lines changed

12 files changed

+654
-295
lines changed

Sources/SKSupport/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_library(SKSupport STATIC
44
AsyncUtils.swift
55
BuildConfiguration.swift
66
ByteString.swift
7+
Collection+Only.swift
78
Connection+Send.swift
89
dlopen.swift
910
FileSystem.swift
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
public extension Collection {
14+
/// If the collection contains a single element, return it, otherwise `nil`.
15+
var only: Element? {
16+
if !isEmpty && index(after: startIndex) == endIndex {
17+
return self.first!
18+
} else {
19+
return nil
20+
}
21+
}
22+
}

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ public struct DocumentPositions {
336336
}
337337
return position
338338
}
339+
340+
/// Returns all position makers within these `DocumentPositions`.
341+
public var allMarkers: [String] {
342+
return positions.keys.sorted()
343+
}
339344
}
340345

341346
// MARK: - WeakMessageHelper

Sources/SourceKitD/SKDRequestArray.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public final class SKDRequestArray {
4040
public func append(_ value: SKDRequestDictionary) {
4141
sourcekitd.api.request_array_set_value(array, -1, value.dict)
4242
}
43+
44+
public static func += (array: SKDRequestArray, other: some Sequence<SKDRequestDictionary>) {
45+
for item in other {
46+
array.append(item)
47+
}
48+
}
4349
}
4450

4551
extension SKDRequestArray: CustomStringConvertible {

Sources/SourceKitLSP/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_library(SourceKitLSP STATIC
44
DocumentManager.swift
55
IndexStoreDB+MainFilesProvider.swift
66
ResponseError+Init.swift
7+
Rename.swift
78
Sequence+AsyncMap.swift
89
SourceKitIndexDelegate.swift
910
SourceKitLSPCommandMetadata.swift
@@ -25,7 +26,6 @@ target_sources(SourceKitLSP PRIVATE
2526
Swift/EditorPlaceholder.swift
2627
Swift/OpenInterface.swift
2728
Swift/RelatedIdentifiers.swift
28-
Swift/Rename.swift
2929
Swift/SemanticRefactorCommand.swift
3030
Swift/SemanticRefactoring.swift
3131
Swift/SemanticTokens.swift

Sources/SourceKitLSP/Clang/ClangLanguageServer.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,6 @@ extension ClangLanguageServerShim {
597597
func executeCommand(_ req: ExecuteCommandRequest) async throws -> LSPAny? {
598598
return try await forwardRequestToClangd(req)
599599
}
600-
601-
func rename(_ request: RenameRequest) async throws -> WorkspaceEdit? {
602-
return try await forwardRequestToClangd(request)
603-
}
604600
}
605601

606602
/// Clang build settings derived from a `FileBuildSettingsChange`.

0 commit comments

Comments
 (0)