Add documentation comments to all public declarations (#3027)

This commit is contained in:
JP Simard
2020-01-08 09:47:10 -08:00
committed by GitHub
parent df6cf175d8
commit 37167a8a35
57 changed files with 693 additions and 79 deletions
@@ -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 }
}