mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Migrate to use SourceKitten's new ByteCount/ByteRange types (#3037)
New APIs were introduced in SourceKitten to allow for a more typesafe distinction between integers meaning NSString-based distances and byte-based distances. * https://github.com/jpsim/SourceKitten/pull/639 * https://github.com/jpsim/SourceKitten/pull/642 This PR migrates SwiftLint's use of those APIs.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import Foundation
|
||||
import SourceKittenFramework
|
||||
|
||||
/// Represents a Swift file's syntax information.
|
||||
@@ -22,7 +21,7 @@ public struct SwiftLintSyntaxMap {
|
||||
/// - parameter byteRange: Byte-based NSRange.
|
||||
///
|
||||
/// - returns: The array of syntax tokens intersecting with byte range.
|
||||
internal func tokens(inByteRange byteRange: NSRange) -> [SwiftLintSyntaxToken] {
|
||||
internal func tokens(inByteRange byteRange: ByteRange) -> [SwiftLintSyntaxToken] {
|
||||
func intersect(_ token: SwiftLintSyntaxToken) -> Bool {
|
||||
return token.range.intersects(byteRange)
|
||||
}
|
||||
@@ -46,10 +45,10 @@ public struct SwiftLintSyntaxMap {
|
||||
|
||||
/// Returns the syntax kinds in the specified byte range.
|
||||
///
|
||||
/// - parameter byteRange: Byte-based NSRange.
|
||||
/// - parameter byteRange: Byte range.
|
||||
///
|
||||
/// - returns: The syntax kinds in the specified byte range.
|
||||
internal func kinds(inByteRange byteRange: NSRange) -> [SyntaxKind] {
|
||||
internal func kinds(inByteRange byteRange: ByteRange) -> [SyntaxKind] {
|
||||
return tokens(inByteRange: byteRange).compactMap { $0.kind }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user