mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
39 lines
1.2 KiB
Swift
39 lines
1.2 KiB
Swift
//
|
|
// SyntaxKind+SwiftLint.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by JP Simard on 2015-11-17.
|
|
// Copyright © 2015 Realm. All rights reserved.
|
|
//
|
|
|
|
import SourceKittenFramework
|
|
|
|
extension SyntaxKind {
|
|
init(shortName: Swift.String) throws {
|
|
let prefix = "source.lang.swift.syntaxtype."
|
|
guard let kind = SyntaxKind(rawValue: prefix + shortName.lowercased()) else {
|
|
throw ConfigurationError.unknownConfiguration
|
|
}
|
|
self = kind
|
|
}
|
|
|
|
static func commentKeywordStringAndTypeidentifierKinds() -> [SyntaxKind] {
|
|
return commentAndStringKinds() + [.keyword, .typeidentifier]
|
|
}
|
|
|
|
static func commentAndStringKinds() -> [SyntaxKind] {
|
|
return commentKinds() + [.string]
|
|
}
|
|
|
|
static func commentKinds() -> [SyntaxKind] {
|
|
return [.comment, .commentMark, .commentURL, .docComment, .docCommentField]
|
|
}
|
|
|
|
static func allKinds() -> [SyntaxKind] {
|
|
return [.argument, .attributeBuiltin, .attributeID, .buildconfigID, .buildconfigKeyword,
|
|
.comment, .commentMark, .commentURL, .docComment, .docCommentField, .identifier,
|
|
.keyword, .number, .objectLiteral, .parameter, .placeholder, .string,
|
|
.stringInterpolationAnchor, .typeidentifier]
|
|
}
|
|
}
|