mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
* Make some SwiftLintFramework declarations public If built-in rules depend on them. This will allow separating the rules from the core infrastructure in separate modules in an upcoming PR. It also helps formalize the API contract for what should be accessible to rule implementations. * Exclude extensions from jazzy
41 lines
1.1 KiB
Swift
41 lines
1.1 KiB
Swift
import SourceKittenFramework
|
|
|
|
/// A SwiftLint-aware Swift syntax token.
|
|
public struct SwiftLintSyntaxToken {
|
|
/// The raw `SyntaxToken` obtained by SourceKitten.
|
|
public let value: SyntaxToken
|
|
|
|
/// The syntax kind associated with is token.
|
|
public let kind: SyntaxKind?
|
|
|
|
/// Creates a `SwiftLintSyntaxToken` from the raw `SyntaxToken` obtained by SourceKitten.
|
|
///
|
|
/// - parameter value: The raw `SyntaxToken` obtained by SourceKitten.
|
|
public init(value: SyntaxToken) {
|
|
self.value = value
|
|
kind = SyntaxKind(rawValue: value.type)
|
|
}
|
|
|
|
/// The byte range in a source file for this token.
|
|
public var range: ByteRange {
|
|
return value.range
|
|
}
|
|
|
|
/// The starting byte offset in a source file for this token.
|
|
public var offset: ByteCount {
|
|
return value.offset
|
|
}
|
|
|
|
/// The length in bytes for this token.
|
|
public var length: ByteCount {
|
|
return value.length
|
|
}
|
|
}
|
|
|
|
public extension Array where Element == SwiftLintSyntaxToken {
|
|
/// The kinds for these tokens.
|
|
var kinds: [SyntaxKind] {
|
|
return compactMap { $0.kind }
|
|
}
|
|
}
|