Skip to content

Commit 0493221

Browse files
authored
Merge pull request #1590 from ahoppen/build-without-warnings
Make SourceKit-LSP build without warnings
2 parents 7ecae09 + ea9bf37 commit 0493221

13 files changed

+21
-43
lines changed

Sources/Diagnose/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
add_library(Diagnose STATIC
2-
CommandConfiguration+Sendable.swift
32
CommandLineArgumentsReducer.swift
43
DebugCommand.swift
54
DiagnoseCommand.swift

Sources/Diagnose/CommandConfiguration+Sendable.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

Sources/SKTestSupport/RepeatUntilExpectedResult.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import SKTestSupport
1413
import XCTest
1514

1615
/// Runs the body repeatedly once per second until it returns `true`, giving up after `timeout`.

Sources/SKTestSupport/WrappedSemaphore.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import Dispatch
14-
import SKTestSupport
1514
import XCTest
1615

1716
/// Wrapper around `DispatchSemaphore` so that Swift Concurrency doesn't complain about the usage of semaphores in the

Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ package actor DynamicallyLoadedSourceKitD: SourceKitD {
8585
self.api.shutdown()
8686
// FIXME: is it safe to dlclose() sourcekitd? If so, do that here. For now, let the handle leak.
8787
Task.detached(priority: .background) { [dylib] in
88-
await dylib.leak()
88+
dylib.leak()
8989
}
9090
}
9191

Sources/SourceKitD/SourceKitD.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ import Dispatch
1515
import Foundation
1616
import SwiftExtensions
1717

18-
#if compiler(>=6)
19-
extension sourcekitd_api_request_handle_t: @retroactive @unchecked Sendable {}
20-
#else
21-
extension sourcekitd_api_request_handle_t: @unchecked Sendable {}
22-
#endif
18+
fileprivate struct SourceKitDRequestHandle: Sendable {
19+
/// `nonisolated(unsafe)` is fine because we just use the handle as an opaque value.
20+
nonisolated(unsafe) let handle: sourcekitd_api_request_handle_t
21+
}
2322

2423
/// Access to sourcekitd API, taking care of initialization, shutdown, and notification handler
2524
/// multiplexing.
@@ -107,16 +106,19 @@ extension SourceKitD {
107106
log(request: request)
108107

109108
let sourcekitdResponse = try await withTimeout(timeout) {
110-
return try await withCancellableCheckedThrowingContinuation { continuation in
109+
return try await withCancellableCheckedThrowingContinuation { (continuation) -> SourceKitDRequestHandle? in
111110
var handle: sourcekitd_api_request_handle_t? = nil
112111
self.api.send_request(request.dict, &handle) { response in
113112
continuation.resume(returning: SKDResponse(response!, sourcekitd: self))
114113
}
115-
return handle
116-
} cancel: { handle in
114+
if let handle {
115+
return SourceKitDRequestHandle(handle: handle)
116+
}
117+
return nil
118+
} cancel: { (handle: SourceKitDRequestHandle?) in
117119
if let handle {
118120
self.logRequestCancellation(request: request)
119-
self.api.cancel_request(handle)
121+
self.api.cancel_request(handle.handle)
120122
}
121123
}
122124
}

Sources/SourceKitLSP/Rename.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
@preconcurrency import IndexStoreDB
13+
import IndexStoreDB
1414
import LanguageServerProtocol
1515
import SKLogging
1616
import SKSupport

Sources/SourceKitLSP/Swift/CodeActions/PackageManifestEdits.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct PackageManifestEdits: SyntaxCodeActionProvider {
3535
) -> [CodeAction] {
3636
do {
3737
var actions: [CodeAction] = []
38-
let variants: [(TargetDescription.TargetType, String)] = [
38+
let variants: [(TargetDescription.TargetKind, String)] = [
3939
(.regular, "library"),
4040
(.executable, "executable"),
4141
(.macro, "macro"),

Tests/SourceKitLSPTests/DocumentSymbolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ final class DocumentSymbolTests: XCTestCase {
762762
fileprivate func assertDocumentSymbols(
763763
_ markedText: String,
764764
_ expectedDocumentSymbols: (DocumentPositions) -> [DocumentSymbol],
765-
file: StaticString = #file,
765+
file: StaticString = #filePath,
766766
line: UInt = #line
767767
) async throws {
768768
let testClient = try await TestSourceKitLSPClient()

Tests/SourceKitLSPTests/FoldingRangeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func assertFoldingRanges(
4444
expectedRanges: [FoldingRangeSpec],
4545
rangeLimit: Int? = nil,
4646
lineFoldingOnly: Bool = false,
47-
file: StaticString = #file,
47+
file: StaticString = #filePath,
4848
line: UInt = #line
4949
) async throws {
5050
let capabilities = ClientCapabilities(

Tests/SourceKitLSPTests/HoverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ final class HoverTests: XCTestCase {
176176
private func assertHover(
177177
_ markedSource: String,
178178
expectedContent: String,
179-
file: StaticString = #file,
179+
file: StaticString = #filePath,
180180
line: UInt = #line
181181
) async throws {
182182
let testClient = try await TestSourceKitLSPClient()

Tests/SourceKitLSPTests/RenameAssertions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func assertSingleFileRename(
3939
expectedPrepareRenamePlaceholder: String,
4040
expected: String,
4141
testName: String = #function,
42-
file: StaticString = #file,
42+
file: StaticString = #filePath,
4343
line: UInt = #line
4444
) async throws {
4545
try await SkipUnless.sourcekitdSupportsRename()
@@ -99,7 +99,7 @@ func assertRenamedSourceMatches(
9999
in ws: MultiFileTestProject,
100100
message: String,
101101
testName: String = #function,
102-
file: StaticString = #file,
102+
file: StaticString = #filePath,
103103
line: UInt = #line
104104
) throws {
105105
for (expectedFileLocation, expectedRenamed) in expected {
@@ -138,7 +138,7 @@ func assertMultiFileRename(
138138
manifest: String = SwiftPMTestProject.defaultPackageManifest,
139139
preRenameActions: (SwiftPMTestProject) throws -> Void = { _ in },
140140
testName: String = #function,
141-
file: StaticString = #file,
141+
file: StaticString = #filePath,
142142
line: UInt = #line
143143
) async throws {
144144
try await SkipUnless.sourcekitdSupportsRename()

Tests/SourceKitLSPTests/TypeHierarchyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fileprivate extension TypeHierarchyItem {
225225
fileprivate func assertEqualIgnoringData(
226226
_ actual: [TypeHierarchyItem]?,
227227
_ expected: [TypeHierarchyItem],
228-
file: StaticString = #file,
228+
file: StaticString = #filePath,
229229
line: UInt = #line
230230
) {
231231
guard let actual else {

0 commit comments

Comments
 (0)