-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Huge internal changes to improve thread-safety and performance - Some async APIs - Remove OperationPlus dependency
- Loading branch information
1 parent
3e44fb6
commit ba3a497
Showing
8 changed files
with
239 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
|
||
public struct Token { | ||
public let name: String | ||
public let range: NSRange | ||
|
||
public init(name: String, range: NSRange) { | ||
self.name = name | ||
self.range = range | ||
} | ||
} | ||
|
||
extension Token: Hashable { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Foundation | ||
import SwiftTreeSitter | ||
|
||
extension Point { | ||
public typealias LocationTransformer = (Int) -> Point? | ||
} | ||
|
||
extension InputEdit { | ||
init?(range: NSRange, delta: Int, oldEndPoint: Point, transformer: Point.LocationTransformer) { | ||
let startLocation = range.location | ||
let newEndLocation = range.max + delta | ||
|
||
if newEndLocation < 0 { | ||
assertionFailure("invalid range/delta") | ||
return nil | ||
} | ||
|
||
guard | ||
let startPoint = transformer(startLocation), | ||
let newEndPoint = transformer(newEndLocation) | ||
else { | ||
return nil | ||
} | ||
|
||
self.init(startByte: UInt32(range.location * 2), | ||
oldEndByte: UInt32(range.max * 2), | ||
newEndByte: UInt32(newEndLocation * 2), | ||
startPoint: startPoint, | ||
oldEndPoint: oldEndPoint, | ||
newEndPoint: newEndPoint) | ||
} | ||
} |
Oops, something went wrong.