diff --git a/Package.resolved b/Package.resolved index 2b42a72..ebdcc9d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,7 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/ChimeHQ/SwiftTreeSitter", "state" : { - "revision" : "f01316eaf3aae07e30478f8afa76192ab4a96420" + "revision" : "36aa61d1b531f744f35229f010efba9c6d6cbbdd", + "version" : "0.9.0" } }, { diff --git a/Package.swift b/Package.swift index d575101..8cc2a91 100644 --- a/Package.swift +++ b/Package.swift @@ -15,17 +15,15 @@ let package = Package( .library(name: "Neon", targets: ["Neon"]), ], dependencies: [ - .package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", revision: "f01316eaf3aae07e30478f8afa76192ab4a96420"), + .package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.9.0"), .package(url: "https://github.com/ChimeHQ/Rearrange", from: "1.8.1"), ], targets: [ - .target(name: "ConcurrencyCompatibility"), - .target(name: "RangeState", dependencies: ["ConcurrencyCompatibility", "Rearrange"]), + .target(name: "RangeState", dependencies: ["Rearrange"]), .testTarget(name: "RangeStateTests", dependencies: ["RangeState"]), .target( name: "Neon", dependencies: [ - "ConcurrencyCompatibility", "RangeState", "Rearrange", "TreeSitterClient", @@ -35,7 +33,6 @@ let package = Package( .target( name: "TreeSitterClient", dependencies: [ - "ConcurrencyCompatibility", "RangeState", "Rearrange", "SwiftTreeSitter", diff --git a/Sources/ConcurrencyCompatibility/Compatibility.swift b/Sources/ConcurrencyCompatibility/Compatibility.swift deleted file mode 100644 index 3f6722c..0000000 --- a/Sources/ConcurrencyCompatibility/Compatibility.swift +++ /dev/null @@ -1,46 +0,0 @@ -import Foundation - -public struct MainActorBackport { - /// Execute the given body closure on the main actor without enforcing MainActor isolation. - /// - /// It will crash if run on any non-main thread. - @_unavailableFromAsync - public func assumeIsolated(_ body: @MainActor () throws -> T) rethrows -> T { -#if swift(>=5.9) - if #available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *) { - return try MainActor.assumeIsolated(body) - } -#endif - - dispatchPrecondition(condition: .onQueue(.main)) - return try withoutActuallyEscaping(body) { fn in - try unsafeBitCast(fn, to: (() throws -> T).self)() - } - } -} - -extension MainActor { - public static var backport: MainActorBackport { - MainActorBackport() - } -} - -public struct DispatchQueueBackport { - private let queue: DispatchQueue - - init(_ queue: DispatchQueue) { - self.queue = queue - } - - public func asyncUnsafe(group: DispatchGroup? = nil, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute unsafeWork: @escaping @convention(block) () -> Void) { - let work = unsafeBitCast(unsafeWork, to: (@Sendable @convention(block) () -> Void).self) - - queue.async(group: group, qos: qos, flags: flags, execute: work) - } -} - -extension DispatchQueue { - public var backport: DispatchQueueBackport { - DispatchQueueBackport(self) - } -} diff --git a/Sources/Neon/TextViewHighlighter.swift b/Sources/Neon/TextViewHighlighter.swift index 71d0365..94f7876 100644 --- a/Sources/Neon/TextViewHighlighter.swift +++ b/Sources/Neon/TextViewHighlighter.swift @@ -131,9 +131,7 @@ public final class TextViewHighlighter { try textView.getTextStorage().delegate = storageDelegate - if textView.enclosingScrollView != nil { - observeEnclosingScrollView() - } + observeEnclosingScrollView() invalidate(.all) } @@ -175,7 +173,7 @@ extension TextViewHighlighter { ) #elseif os(iOS) || os(visionOS) self.frameObservation = textView.observe(\.contentOffset) { [weak self] view, _ in - MainActor.backport.assumeIsolated { + MainActor.assumeIsolated { guard let self = self else { return } self.lastVisibleRange = self.textView.visibleTextRange diff --git a/Sources/RangeState/RangeProcessor.swift b/Sources/RangeState/RangeProcessor.swift index e05dd18..5aad898 100644 --- a/Sources/RangeState/RangeProcessor.swift +++ b/Sources/RangeState/RangeProcessor.swift @@ -1,6 +1,5 @@ import Foundation -import ConcurrencyCompatibility import Rearrange public enum RangeFillMode: Sendable, Hashable { diff --git a/Sources/RangeState/RangeValidator.swift b/Sources/RangeState/RangeValidator.swift index a3137d3..ee1d0d4 100644 --- a/Sources/RangeState/RangeValidator.swift +++ b/Sources/RangeState/RangeValidator.swift @@ -1,6 +1,5 @@ import Foundation -import ConcurrencyCompatibility import Rearrange public enum Validation: Sendable, Hashable { diff --git a/Sources/RangeState/SinglePhaseRangeValidator.swift b/Sources/RangeState/SinglePhaseRangeValidator.swift index 807eeff..2d98b37 100644 --- a/Sources/RangeState/SinglePhaseRangeValidator.swift +++ b/Sources/RangeState/SinglePhaseRangeValidator.swift @@ -1,6 +1,5 @@ import Foundation -import ConcurrencyCompatibility import Rearrange @MainActor diff --git a/Sources/RangeState/ThreePhaseRangeValidator.swift b/Sources/RangeState/ThreePhaseRangeValidator.swift index d0c966d..014de83 100644 --- a/Sources/RangeState/ThreePhaseRangeValidator.swift +++ b/Sources/RangeState/ThreePhaseRangeValidator.swift @@ -1,6 +1,5 @@ import Foundation -import ConcurrencyCompatibility import Rearrange @MainActor diff --git a/Sources/TreeSitterClient/BackgroundingLanguageLayerTree.swift b/Sources/TreeSitterClient/BackgroundingLanguageLayerTree.swift index c54fdd3..a48eac2 100644 --- a/Sources/TreeSitterClient/BackgroundingLanguageLayerTree.swift +++ b/Sources/TreeSitterClient/BackgroundingLanguageLayerTree.swift @@ -1,6 +1,5 @@ import Foundation -import ConcurrencyCompatibility import SwiftTreeSitter import SwiftTreeSitterLayer diff --git a/Sources/TreeSitterClient/DispatchQueueBackport.swift b/Sources/TreeSitterClient/DispatchQueueBackport.swift new file mode 100644 index 0000000..4d7d316 --- /dev/null +++ b/Sources/TreeSitterClient/DispatchQueueBackport.swift @@ -0,0 +1,21 @@ +import Foundation + +struct DispatchQueueBackport { + private let queue: DispatchQueue + + init(_ queue: DispatchQueue) { + self.queue = queue + } + + func asyncUnsafe(group: DispatchGroup? = nil, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute unsafeWork: @escaping @convention(block) () -> Void) { + let work = unsafeBitCast(unsafeWork, to: (@Sendable @convention(block) () -> Void).self) + + queue.async(group: group, qos: qos, flags: flags, execute: work) + } +} + +extension DispatchQueue { + var backport: DispatchQueueBackport { + DispatchQueueBackport(self) + } +}