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)
|
|
}
|
|
}
|
|
}
|