Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Nov 26, 2024
1 parent 853a51f commit 00334c4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Configurations/NonSwiftWorkaround.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/Internal.modulemap

// SwiftTreeSitter
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/tree-sitter.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitter.modulemap

// All the tree-sitter parsers
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterBash.modulemap
Expand Down
4 changes: 3 additions & 1 deletion Edit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@
C92931422B80CC6700C64DDE /* EditKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = EditKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C92931722B822BFF00C64DDE /* EditKit.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = EditKit.xcconfig; sourceTree = "<group>"; };
C93791A32AD5E02C00665F50 /* Project-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Debug.xcconfig"; sourceTree = "<group>"; };
C93A80492CC4052100B89FB4 /* Neon */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Neon; path = ../Neon; sourceTree = SOURCE_ROOT; };
C93F72482BF26BDC0021ACF3 /* EditIntents.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.extensionkit-extension"; includeInIndex = 0; path = EditIntents.appex; sourceTree = BUILT_PRODUCTS_DIR; };
C93F724A2BF26BDC0021ACF3 /* EditIntentsExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditIntentsExtension.swift; sourceTree = "<group>"; };
C93F724C2BF26BDC0021ACF3 /* HighlightIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HighlightIntent.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1863,6 +1864,7 @@
C9FE52902A7525D000CACA1A = {
isa = PBXGroup;
children = (
C93A80492CC4052100B89FB4 /* Neon */,
C9FE538E2A76674600CACA1A /* Configurations */,
C9439A742C3EC13A0020DDF5 /* Dependencies */,
C9FE529B2A7525D000CACA1A /* Edit */,
Expand Down Expand Up @@ -5336,7 +5338,7 @@
repositoryURL = "https://github.com/ChimeHQ/Neon.git";
requirement = {
kind = revision;
revision = 709683a2e2f3a2e502e8383f9aa5c725bf7d85e6;
revision = 9101469ff9ae2258e88099327969c350a953407d;
};
};
C93F72252BF0F9290021ACF3 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "93a0f563fbf3515fa097a1cc8e611c176c645da816d19e7f63eed073d79e680a",
"originHash" : "ff7de96f98e01194f786ca218f32286d1e04cc1961dd2ec8e8d690d02ed4a344",
"pins" : [
{
"identity" : "asyncxpcconnection",
Expand Down Expand Up @@ -122,14 +122,6 @@
"version" : "0.2.1"
}
},
{
"identity" : "neon",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/Neon.git",
"state" : {
"revision" : "709683a2e2f3a2e502e8383f9aa5c725bf7d85e6"
}
},
{
"identity" : "nsui",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -221,7 +213,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/SwiftTreeSitter",
"state" : {
"revision" : "b01904a3737649c1d8520106bbb285724fe5b0bb"
"revision" : "f01316eaf3aae07e30478f8afa76192ab4a96420"
}
},
{
Expand All @@ -240,6 +232,15 @@
"revision" : "2ccbf37a0c7e52c7b20aadabd8e8cbbb2b25b9a8"
}
},
{
"identity" : "tree-sitter",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tree-sitter/tree-sitter",
"state" : {
"revision" : "d97db6d63507eb62c536bcb2c4ac7d70c8ec665e",
"version" : "0.23.2"
}
},
{
"identity" : "tree-sitter-bash",
"kind" : "remoteSourceControl",
Expand All @@ -261,7 +262,7 @@
{
"identity" : "tree-sitter-clojure",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattmassicotte/tree-sitter-clojure.git",
"location" : "https://github.com/mattmassicotte/tree-sitter-clojure",
"state" : {
"branch" : "feature/spm",
"revision" : "0a3d6ce7b48bae5e5d96af6bda9f47ec28e055bd"
Expand All @@ -279,7 +280,7 @@
{
"identity" : "tree-sitter-go",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tree-sitter/tree-sitter-go.git",
"location" : "https://github.com/tree-sitter/tree-sitter-go",
"state" : {
"branch" : "master",
"revision" : "7ee8d928db5202f6831a78f8112fd693bf69f98b"
Expand Down Expand Up @@ -315,7 +316,7 @@
{
"identity" : "tree-sitter-markdown",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tree-sitter-grammars/tree-sitter-markdown.git",
"location" : "https://github.com/tree-sitter-grammars/tree-sitter-markdown",
"state" : {
"branch" : "split_parser",
"revision" : "f9820b2db958228f9be339b67d2de874d065866e"
Expand Down Expand Up @@ -360,7 +361,7 @@
{
"identity" : "tree-sitter-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/alex-pinkus/tree-sitter-swift/",
"location" : "https://github.com/alex-pinkus/tree-sitter-swift",
"state" : {
"branch" : "with-generated-files",
"revision" : "eda05af7ac41adb4eb19c346883c0fa32fe3bdd8"
Expand Down
2 changes: 1 addition & 1 deletion Edit/Modules/DocumentContent/TextMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension Line {

@MainActor
public final class TextMetrics {
public typealias ValueProvider = HybridValueProvider<Query, TextMetrics>
public typealias ValueProvider = HybridSyncAsyncValueProvider<Query, TextMetrics, Never>

public nonisolated static let invalidationSetKey = "set"
public nonisolated static let textMetricsDidChangeNotification = Notification.Name("textMetricsDidChangeNotification")
Expand Down
11 changes: 7 additions & 4 deletions Edit/Modules/Highlighting/TokenServiceWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension TokenServiceWrapper {

public func tokens(for range: NSRange) async -> TokenApplication {
guard let service else { return .init(tokens: []) }
let textMetrics = await textSystem.textMetrics.valueProvider.mainActorAsync(.location(range.max, fill: .optional))
let textMetrics = await textSystem.textMetrics.valueProvider.async(.location(range.max, fill: .optional))

let combinedRange = CombinedTextRange(range: range, metrics: textMetrics)

Expand All @@ -41,10 +41,13 @@ extension TokenServiceWrapper {
}

public var tokenProvider: TokenProvider {
.init(
mainActorAsyncValue: { [textSystem] range in
TokenProvider.init(
// this is needed to work around a compiler crash
// https://github.com/swiftlang/swift/issues/77123
syncValue: { _ in nil },
mainActorAsyncValue: { @MainActor [textSystem] range in
guard let service = self.service else { return .init(tokens: []) }
let textMetrics = await textSystem.textMetrics.valueProvider.mainActorAsync(.location(range.max, fill: .optional))
let textMetrics = await textSystem.textMetrics.valueProvider.async(.location(range.max, fill: .optional))

let combinedRange = CombinedTextRange(range: range, metrics: textMetrics)

Expand Down
2 changes: 1 addition & 1 deletion Edit/Modules/SyntaxService/SyntaxService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ extension SyntaxService {

do {
let queryParams = try self.highlightsQueryParams(for: range)
let namedRanges = try await client.highlightsProvider.mainActorAsync(queryParams)
let namedRanges = try await client.highlightsProvider.async(queryParams)

return TokenApplication(namedRanges: namedRanges, nameMap: [:], range: range)
} catch {
Expand Down

0 comments on commit 00334c4

Please sign in to comment.