Skip to content

Create a SwiftExtensions module #1410

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
Jun 4, 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
18 changes: 18 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ let package = Package(
"SKSupport",
"SourceKitD",
"SourceKitLSP",
"SwiftExtensions",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftIDEUtils", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
Expand Down Expand Up @@ -183,6 +184,7 @@ let package = Package(
"LanguageServerProtocol",
"LanguageServerProtocolJSONRPC",
"SKSupport",
"SwiftExtensions",
]
),

Expand All @@ -195,6 +197,7 @@ let package = Package(
"LanguageServerProtocol",
"LSPLogging",
"SKCore",
"SwiftExtensions",
.product(name: "IndexStoreDB", package: "indexstore-db"),
],
exclude: ["CMakeLists.txt"]
Expand All @@ -221,6 +224,7 @@ let package = Package(
"LSPLogging",
"SKSupport",
"SourceKitD",
"SwiftExtensions",
.product(name: "SwiftPMDataModel-auto", package: "swift-package-manager"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
],
Expand All @@ -246,6 +250,7 @@ let package = Package(
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
"LanguageServerProtocol",
"LSPLogging",
"SwiftExtensions",
],
exclude: ["CMakeLists.txt"],
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
Expand All @@ -257,6 +262,7 @@ let package = Package(
"LSPTestSupport",
"SKSupport",
"SKTestSupport",
"SwiftExtensions",
]
),

Expand All @@ -269,6 +275,7 @@ let package = Package(
"LanguageServerProtocol",
"LSPLogging",
"SKCore",
"SwiftExtensions",
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
],
Expand Down Expand Up @@ -302,6 +309,7 @@ let package = Package(
"LSPLogging",
"SKCore",
"SourceKitLSP",
"SwiftExtensions",
.product(name: "ISDBTestSupport", package: "indexstore-db"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
],
Expand All @@ -319,6 +327,7 @@ let package = Package(
"Csourcekitd",
"LSPLogging",
"SKSupport",
"SwiftExtensions",
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
],
exclude: ["CMakeLists.txt", "sourcekitd_uids.swift.gyb"],
Expand All @@ -331,6 +340,7 @@ let package = Package(
"SourceKitD",
"SKCore",
"SKTestSupport",
"SwiftExtensions",
]
),

Expand All @@ -349,6 +359,7 @@ let package = Package(
"SKSupport",
"SKSwiftPMWorkspace",
"SourceKitD",
"SwiftExtensions",
.product(name: "IndexStoreDB", package: "indexstore-db"),
.product(name: "SwiftBasicFormat", package: "swift-syntax"),
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
Expand Down Expand Up @@ -387,6 +398,13 @@ let package = Package(
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
]
),

// MARK: SwiftExtensions

.target(
name: "SwiftExtensions",
exclude: ["CMakeLists.txt"]
),
]
)

Expand Down
1 change: 1 addition & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ add_subdirectory(SKSwiftPMWorkspace)
add_subdirectory(SourceKitLSP)
add_subdirectory(SourceKitD)
add_subdirectory(sourcekit-lsp)
add_subdirectory(SwiftExtensions)
1 change: 1 addition & 0 deletions Sources/Diagnose/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_link_libraries(Diagnose PUBLIC
LSPLogging
SKCore
SourceKitD
SwiftExtensions
ArgumentParser
SwiftSyntax::SwiftIDEUtils
SwiftSyntax::SwiftSyntax
Expand Down
1 change: 1 addition & 0 deletions Sources/Diagnose/IndexCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import LanguageServerProtocol
import SKCore
import SKSupport
import SourceKitLSP
import SwiftExtensions

import struct TSCBasic.AbsolutePath
import class TSCBasic.Process
Expand Down
1 change: 1 addition & 0 deletions Sources/LSPTestSupport/TestJSONRPCConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import InProcessClient
import LanguageServerProtocol
import LanguageServerProtocolJSONRPC
import SKSupport
import SwiftExtensions
import XCTest

import class Foundation.Pipe
Expand Down
1 change: 1 addition & 0 deletions Sources/SKCore/BuildServerBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import LSPLogging
import LanguageServerProtocol
import LanguageServerProtocolJSONRPC
import SKSupport
import SwiftExtensions

import struct TSCBasic.AbsolutePath
import protocol TSCBasic.FileSystem
Expand Down
1 change: 1 addition & 0 deletions Sources/SKCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ target_link_libraries(SKCore PUBLIC
LSPLogging
SKSupport
SourceKitD
SwiftExtensions
PackageModel
TSCBasic)
1 change: 1 addition & 0 deletions Sources/SKCore/TaskScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CAtomics
import Foundation
import LSPLogging
import SKSupport
import SwiftExtensions

/// See comment on ``TaskDescriptionProtocol/dependencies(to:taskPriority:)``
public enum TaskDependencyAction<TaskDescription: TaskDescriptionProtocol> {
Expand Down
1 change: 1 addition & 0 deletions Sources/SKCore/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import LSPLogging
import LanguageServerProtocol
import RegexBuilder
import SKSupport
import SwiftExtensions

import enum PackageLoading.Platform
import struct TSCBasic.AbsolutePath
Expand Down
8 changes: 1 addition & 7 deletions Sources/SKSupport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@

add_library(SKSupport STATIC
AsyncQueue.swift
AsyncUtils.swift
BuildConfiguration.swift
ByteString.swift
Collection+Only.swift
Collection+PartitionIntoBatches.swift
Connection+Send.swift
dlopen.swift
DocumentURI+CustomLogStringConvertible.swift
Expand All @@ -16,16 +12,14 @@ add_library(SKSupport STATIC
Process+WaitUntilExitWithCancellation.swift
Random.swift
Result.swift
Sequence+AsyncMap.swift
SwitchableProcessResultExitStatus.swift
Task+WithPriorityChangedHandler.swift
ThreadSafeBox.swift
WorkspaceType.swift
)
set_target_properties(SKSupport PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
target_link_libraries(SKSupport PRIVATE
LanguageServerProtocol
LSPLogging
SwiftExtensions
TSCBasic
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>)
1 change: 1 addition & 0 deletions Sources/SKSupport/Connection+Send.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

import LanguageServerProtocol
import SwiftExtensions

extension Connection {
/// Send the given request to the connection and await its result.
Expand Down
1 change: 1 addition & 0 deletions Sources/SKSupport/PipeAsStringHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

import Foundation
import SwiftExtensions

/// Gathers data from a stdout or stderr pipe. When it has accumulated a full line, calls the handler to handle the
/// string.
Expand Down
1 change: 1 addition & 0 deletions Sources/SKSwiftPMWorkspace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target_link_libraries(SKSwiftPMWorkspace PRIVATE
LanguageServerProtocol
LSPLogging
SKCore
SwiftExtensions
TSCBasic)
target_link_libraries(SKSwiftPMWorkspace PUBLIC
Build
Expand Down
5 changes: 4 additions & 1 deletion Sources/SKSwiftPMWorkspace/SwiftPMBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import SKCore
import SKSupport
import SourceControl
import SourceKitLSPAPI
import SwiftExtensions
import Workspace

import struct Basics.AbsolutePath
Expand Down Expand Up @@ -113,7 +114,9 @@ public actor SwiftPMBuildSystem {
private let fileSystem: FileSystem
private let toolchainRegistry: ToolchainRegistry

private let swiftBuildSupportsPrepareForIndexingTask = SKSupport.ThreadSafeBox<Task<Bool, Never>?>(initialValue: nil)
private let swiftBuildSupportsPrepareForIndexingTask = SwiftExtensions.ThreadSafeBox<Task<Bool, Never>?>(
initialValue: nil
)

private var fileToTarget: [DocumentURI: SwiftBuildTarget] = [:]
private var sourceDirToTarget: [DocumentURI: SwiftBuildTarget] = [:]
Expand Down
1 change: 1 addition & 0 deletions Sources/SKTestSupport/TestSourceKitLSPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import LanguageServerProtocolJSONRPC
@_spi(Testing) import SKCore
import SKSupport
import SourceKitLSP
import SwiftExtensions
import SwiftSyntax
import XCTest

Expand Down
1 change: 1 addition & 0 deletions Sources/SemanticIndex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ set_target_properties(SemanticIndex PROPERTIES
target_link_libraries(SemanticIndex PRIVATE
LSPLogging
SKCore
SwiftExtensions
IndexStoreDB
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import LSPLogging
import LanguageServerProtocol
import SKCore
import SKSupport
import SwiftExtensions

import struct TSCBasic.AbsolutePath
import class TSCBasic.Process
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ target_link_libraries(SourceKitD PUBLIC
target_link_libraries(SourceKitD PRIVATE
LSPLogging
SKSupport
SwiftExtensions
TSCBasic
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>)
1 change: 1 addition & 0 deletions Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import Foundation
import LSPLogging
import SKSupport
import SwiftExtensions

import struct TSCBasic.AbsolutePath

Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitD/SourceKitD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import Dispatch
import Foundation
import SKSupport
import SwiftExtensions

#if compiler(>=6)
extension sourcekitd_api_request_handle_t: @retroactive @unchecked Sendable {}
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ target_link_libraries(SourceKitLSP PUBLIC
SKSupport
SKSwiftPMWorkspace
SourceKitD
SwiftExtensions
IndexStoreDB
SwiftSyntax::SwiftBasicFormat
SwiftSyntax::SwiftDiagnostics
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/Clang/ClangLanguageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import LanguageServerProtocol
import LanguageServerProtocolJSONRPC
import SKCore
import SKSupport
import SwiftExtensions

import struct TSCBasic.AbsolutePath

Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/IndexProgressManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import LanguageServerProtocol
import SKCore
import SKSupport
import SemanticIndex
import SwiftExtensions

/// Listens for index status updates from `SemanticIndexManagers`. From that information, it manages a
/// `WorkDoneProgress` that communicates the index progress to the editor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import LSPLogging
import LanguageServerProtocol
import SKSupport
import SwiftExtensions

/// A lightweight way of describing tasks that are created from handling LSP
/// requests or notifications for the purpose of dependency tracking.
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/SourceKitIndexDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import IndexStoreDB
import LSPLogging
import SKCore
import SKSupport
import SwiftExtensions

/// `IndexDelegate` for the SourceKit workspace.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/SourceKitLSPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import SKSupport
import SKSwiftPMWorkspace
import SemanticIndex
import SourceKitD
import SwiftExtensions

import struct PackageModel.BuildFlags
import struct TSCBasic.AbsolutePath
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/Swift/CodeCompletionSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import LSPLogging
import LanguageServerProtocol
import SKSupport
import SourceKitD
import SwiftExtensions
import SwiftParser
@_spi(SourceKitLSP) import SwiftRefactor
import SwiftSyntax
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/Swift/DiagnosticReportManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import LSPLogging
import LanguageServerProtocol
import SKSupport
import SourceKitD
import SwiftExtensions
import SwiftParserDiagnostics

actor DiagnosticReportManager {
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/Swift/SwiftLanguageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import SKCore
import SKSupport
import SemanticIndex
import SourceKitD
import SwiftExtensions
import SwiftParser
import SwiftParserDiagnostics
import SwiftSyntax
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/Swift/SyntacticTestIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Foundation
import LSPLogging
import LanguageServerProtocol
import SKSupport
import SwiftExtensions

/// Task metadata for `SyntacticTestIndexer.indexingQueue`
fileprivate enum TaskMetadata: DependencyTracker, Equatable {
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/WorkDoneProgressManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import Foundation
import LanguageServerProtocol
import SKSupport
import SwiftExtensions

/// Represents a single `WorkDoneProgress` task that gets communicated with the client.
///
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/WorkDoneProgressState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import LSPLogging
import LanguageServerProtocol
import SKSupport
import SwiftExtensions

/// Keeps track of the state to send work done progress updates to the client
final actor WorkDoneProgressState {
Expand Down
1 change: 1 addition & 0 deletions Sources/SourceKitLSP/Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import LanguageServerProtocol
import SKCore
import SKSupport
import SemanticIndex
import SwiftExtensions

import struct TSCBasic.AbsolutePath
import struct TSCBasic.RelativePath
Expand Down
14 changes: 14 additions & 0 deletions Sources/SwiftExtensions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

add_library(SwiftExtensions STATIC
AsyncQueue.swift
AsyncUtils.swift
Collection+Only.swift
Collection+PartitionIntoBatches.swift
Sequence+AsyncMap.swift
Task+WithPriorityChangedHandler.swift
ThreadSafeBox.swift
)
set_target_properties(SwiftExtensions PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
target_link_libraries(SwiftExtensions PRIVATE
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>)
Loading