Files
SwiftLint/Source/SwiftLintFramework/Models/Region.swift
T
2016-10-09 01:09:50 +09:00

35 lines
863 B
Swift

//
// Region.swift
// SwiftLint
//
// Created by JP Simard on 8/29/15.
// Copyright © 2015 Realm. All rights reserved.
//
import Foundation
import SourceKittenFramework
public struct Region {
let start: Location
let end: Location
let disabledRuleIdentifiers: Set<String>
public init(start: Location, end: Location, disabledRuleIdentifiers: Set<String>) {
self.start = start
self.end = end
self.disabledRuleIdentifiers = disabledRuleIdentifiers
}
public func contains(_ location: Location) -> Bool {
return start <= location && end >= location
}
public func isRuleEnabled(_ rule: Rule) -> Bool {
return !isRuleDisabled(rule)
}
public func isRuleDisabled(_ rule: Rule) -> Bool {
return disabledRuleIdentifiers.contains(type(of: rule).description.identifier)
}
}