mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
0ded5859a1
Making it about 7x faster, finding some previously missed cases.
15 lines
457 B
Swift
15 lines
457 B
Swift
import SwiftSyntax
|
|
|
|
extension SourceFileSyntax {
|
|
func windowsOfThreeTokens() -> [(TokenSyntax, TokenSyntax, TokenSyntax)] {
|
|
Array(tokens)
|
|
.windows(ofCount: 3)
|
|
.map { tokens in
|
|
let previous = tokens[tokens.startIndex]
|
|
let current = tokens[tokens.startIndex + 1]
|
|
let next = tokens[tokens.startIndex + 2]
|
|
return (previous, current, next)
|
|
}
|
|
}
|
|
}
|