mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
aea1fd3538
Fixes #1019
27 lines
592 B
Swift
27 lines
592 B
Swift
//
|
|
// SwiftVersion.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by Marcelo Fabri on 12/29/16.
|
|
// Copyright © 2016 Realm. All rights reserved.
|
|
//
|
|
|
|
import SourceKittenFramework
|
|
|
|
enum SwiftVersion {
|
|
case two
|
|
case three
|
|
|
|
static let current: SwiftVersion = {
|
|
let file = File(contents: "#sourceLocation()")
|
|
let kinds = file.syntaxMap.tokens.flatMap { SyntaxKind(rawValue: $0.type) }
|
|
if kinds == [.identifier] {
|
|
return .two
|
|
} else if kinds == [.keyword] {
|
|
return .three
|
|
}
|
|
|
|
fatalError("Unexpected Swift version")
|
|
}()
|
|
}
|