Files
SwiftLint/Source/SwiftLintCore/Extensions/SyntaxKind+SwiftLint.swift
T
Danny Mösch 3f039f26d5 Connect configs with their referencing rules to have some context in error logging (#5017)
With the binding of configurations to their associated rule types
"unknown configuration" errors can be made more specific mentioning
also the rule's identifier in the printed message.
2023-05-19 20:58:24 +02:00

40 lines
1.5 KiB
Swift

import SourceKittenFramework
public extension SyntaxKind {
init?(shortName: Swift.String) {
guard let kind = SyntaxKind(rawValue: "source.lang.swift.syntaxtype.\(shortName.lowercased())") else {
return nil
}
self = kind
}
static let commentAndStringKinds: Set<SyntaxKind> = commentKinds.union([.string])
static let commentKinds: Set<SyntaxKind> = [.comment, .commentMark, .commentURL,
.docComment, .docCommentField]
static let allKinds: Set<SyntaxKind> = [.argument, .attributeBuiltin, .attributeID, .buildconfigID,
.buildconfigKeyword, .comment, .commentMark, .commentURL,
.docComment, .docCommentField, .identifier, .keyword, .number,
.objectLiteral, .parameter, .placeholder, .string,
.stringInterpolationAnchor, .typeidentifier]
/// Syntax kinds that don't have associated module info when getting their cursor info.
static var kindsWithoutModuleInfo: Set<SyntaxKind> {
return [
.attributeBuiltin,
.keyword,
.number,
.docComment,
.string,
.stringInterpolationAnchor,
.attributeID,
.buildconfigKeyword,
.buildconfigID,
.commentURL,
.comment,
.docCommentField
]
}
}