mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Add documentation comments to all public declarations (#3027)
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
import Foundation
|
||||
import SourceKittenFramework
|
||||
|
||||
/// Represents a Swift file's syntax information.
|
||||
public struct SwiftLintSyntaxMap {
|
||||
/// The raw `SyntaxMap` obtained by SourceKitten.
|
||||
public let value: SyntaxMap
|
||||
|
||||
/// The SwiftLint-specific syntax tokens for this syntax map.
|
||||
public let tokens: [SwiftLintSyntaxToken]
|
||||
|
||||
/// Creates a `SwiftLintSyntaxMap` from the raw `SyntaxMap` obtained by SourceKitten.
|
||||
///
|
||||
/// - arameter value: The raw `SyntaxMap` obtained by SourceKitten.
|
||||
public init(value: SyntaxMap) {
|
||||
self.value = value
|
||||
self.tokens = value.tokens.map(SwiftLintSyntaxToken.init)
|
||||
}
|
||||
|
||||
/// Returns array of SyntaxTokens intersecting with byte range
|
||||
/// Returns array of SyntaxTokens intersecting with byte range.
|
||||
///
|
||||
/// - Parameter byteRange: byte based NSRange
|
||||
/// - parameter byteRange: Byte-based NSRange.
|
||||
internal func tokens(inByteRange byteRange: NSRange) -> [SwiftLintSyntaxToken] {
|
||||
func intersect(_ token: SwiftLintSyntaxToken) -> Bool {
|
||||
return token.range.intersects(byteRange)
|
||||
@@ -35,6 +42,9 @@ public struct SwiftLintSyntaxMap {
|
||||
return Array(tokensAfterFirstIntersection)
|
||||
}
|
||||
|
||||
/// Returns the syntax kinds in the specified byte range.
|
||||
///
|
||||
/// - parameter byteRange: Byte-based NSRange.
|
||||
internal func kinds(inByteRange byteRange: NSRange) -> [SyntaxKind] {
|
||||
return tokens(inByteRange: byteRange).compactMap { $0.kind }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user