mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
704e7bde1d
That returns array of SyntaxTokens intersecting with byte range.
23 lines
627 B
Swift
23 lines
627 B
Swift
//
|
|
// SyntaxMap+SwiftLint.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by Norio Nomura on 2/19/16.
|
|
// Copyright © 2016 Realm. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SourceKittenFramework
|
|
|
|
extension SyntaxMap {
|
|
/// Returns array of SyntaxTokens intersecting with byte range
|
|
///
|
|
/// - Parameter byteRange: byte based NSRange
|
|
internal func tokensIn(byteRange: NSRange) -> [SyntaxToken] {
|
|
return tokens.filter { token in
|
|
let tokenByteRange = NSRange(location: token.offset, length: token.length)
|
|
return NSIntersectionRange(byteRange, tokenByteRange).length > 0
|
|
}
|
|
}
|
|
}
|