Skip to content

Make SourceKit-LSP build without warnings #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Sources/Diagnose/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
add_library(Diagnose STATIC
CommandConfiguration+Sendable.swift
CommandLineArgumentsReducer.swift
DebugCommand.swift
DiagnoseCommand.swift
Expand Down
21 changes: 0 additions & 21 deletions Sources/Diagnose/CommandConfiguration+Sendable.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/SKTestSupport/RepeatUntilExpectedResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//
//===----------------------------------------------------------------------===//

import SKTestSupport
import XCTest

/// Runs the body repeatedly once per second until it returns `true`, giving up after `timeout`.
Expand Down
1 change: 0 additions & 1 deletion Sources/SKTestSupport/WrappedSemaphore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//

import Dispatch
import SKTestSupport
import XCTest

/// Wrapper around `DispatchSemaphore` so that Swift Concurrency doesn't complain about the usage of semaphores in the
Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ package actor DynamicallyLoadedSourceKitD: SourceKitD {
self.api.shutdown()
// FIXME: is it safe to dlclose() sourcekitd? If so, do that here. For now, let the handle leak.
Task.detached(priority: .background) { [dylib] in
await dylib.leak()
dylib.leak()
}
}

Expand Down
20 changes: 11 additions & 9 deletions Sources/SourceKitD/SourceKitD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import Dispatch
import Foundation
import SwiftExtensions

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

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

let sourcekitdResponse = try await withTimeout(timeout) {
return try await withCancellableCheckedThrowingContinuation { continuation in
return try await withCancellableCheckedThrowingContinuation { (continuation) -> SourceKitDRequestHandle? in
var handle: sourcekitd_api_request_handle_t? = nil
self.api.send_request(request.dict, &handle) { response in
continuation.resume(returning: SKDResponse(response!, sourcekitd: self))
}
return handle
} cancel: { handle in
if let handle {
return SourceKitDRequestHandle(handle: handle)
}
return nil
} cancel: { (handle: SourceKitDRequestHandle?) in
if let handle {
self.logRequestCancellation(request: request)
self.api.cancel_request(handle)
self.api.cancel_request(handle.handle)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SourceKitLSP/Rename.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

@preconcurrency import IndexStoreDB
import IndexStoreDB
import LanguageServerProtocol
import SKLogging
import SKSupport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct PackageManifestEdits: SyntaxCodeActionProvider {
) -> [CodeAction] {
do {
var actions: [CodeAction] = []
let variants: [(TargetDescription.TargetType, String)] = [
let variants: [(TargetDescription.TargetKind, String)] = [
(.regular, "library"),
(.executable, "executable"),
(.macro, "macro"),
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/DocumentSymbolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ final class DocumentSymbolTests: XCTestCase {
fileprivate func assertDocumentSymbols(
_ markedText: String,
_ expectedDocumentSymbols: (DocumentPositions) -> [DocumentSymbol],
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) async throws {
let testClient = try await TestSourceKitLSPClient()
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/FoldingRangeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func assertFoldingRanges(
expectedRanges: [FoldingRangeSpec],
rangeLimit: Int? = nil,
lineFoldingOnly: Bool = false,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) async throws {
let capabilities = ClientCapabilities(
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/HoverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ final class HoverTests: XCTestCase {
private func assertHover(
_ markedSource: String,
expectedContent: String,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) async throws {
let testClient = try await TestSourceKitLSPClient()
Expand Down
6 changes: 3 additions & 3 deletions Tests/SourceKitLSPTests/RenameAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func assertSingleFileRename(
expectedPrepareRenamePlaceholder: String,
expected: String,
testName: String = #function,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) async throws {
try await SkipUnless.sourcekitdSupportsRename()
Expand Down Expand Up @@ -99,7 +99,7 @@ func assertRenamedSourceMatches(
in ws: MultiFileTestProject,
message: String,
testName: String = #function,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) throws {
for (expectedFileLocation, expectedRenamed) in expected {
Expand Down Expand Up @@ -138,7 +138,7 @@ func assertMultiFileRename(
manifest: String = SwiftPMTestProject.defaultPackageManifest,
preRenameActions: (SwiftPMTestProject) throws -> Void = { _ in },
testName: String = #function,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) async throws {
try await SkipUnless.sourcekitdSupportsRename()
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/TypeHierarchyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fileprivate extension TypeHierarchyItem {
fileprivate func assertEqualIgnoringData(
_ actual: [TypeHierarchyItem]?,
_ expected: [TypeHierarchyItem],
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) {
guard let actual else {
Expand Down