Skip to content

Commit

Permalink
Compatibility with new SwiftTreeSitter
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jan 13, 2024
1 parent 1e427cd commit 405d202
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/SwiftTreeSitter",
"state" : {
"revision" : "df25a52f72ebc5b50ae20d26d1363793408bb28b",
"version" : "0.7.1"
"revision" : "a9b1335d5151b62b11f07599bd07d07dc5965de3",
"version" : "0.7.2"
}
}
],
Expand Down
8 changes: 4 additions & 4 deletions Sources/TreeSitterClient/TreeSitterClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public enum TreeSitterClientError: Error {
}

public final class TreeSitterClient {
public typealias TextProvider = ResolvingQueryCursor.TextProvider
public typealias TextProvider = SwiftTreeSitter.Predicate.TextProvider

public enum ExecutionMode: Hashable {
case synchronous
case synchronousPreferred
Expand Down Expand Up @@ -389,15 +389,15 @@ extension TreeSitterClient {
let startedVersion = version
queue.async {
self.semaphore.wait()
let state = self.parseState.copy()
let tree = self.parseState.tree?.copy()
self.semaphore.signal()

OperationQueue.main.addOperation {
guard startedVersion == self.version else {
completionHandler(.failure(.staleContent))
return
}
if let tree = state.tree {
if let tree {
completionHandler(.success(tree))
} else {
completionHandler(.failure(.stateInvalid))
Expand Down
6 changes: 3 additions & 3 deletions Sources/TreeSitterClient/TreeSitterParseState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Foundation
import SwiftTreeSitter

struct TreeSitterParseState {
var tree: Tree?
var tree: MutableTree?

init(tree: Tree? = nil) {
init(tree: MutableTree? = nil) {
self.tree = tree
}

Expand Down Expand Up @@ -36,7 +36,7 @@ struct TreeSitterParseState {
}

func copy() -> TreeSitterParseState {
return TreeSitterParseState(tree: tree?.copy())
return TreeSitterParseState(tree: tree?.mutableCopy())
}
}

Expand Down

0 comments on commit 405d202

Please sign in to comment.