Files
SwiftLint/Source/SwiftLintFramework/Models/Region.swift
T
2015-11-17 11:41:02 -08:00

35 lines
886 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(violation: StyleViolation) -> Bool {
return start <= violation.location && end >= violation.location
}
public func isRuleEnabled(rule: Rule) -> Bool {
return !isRuleDisabled(rule)
}
public func isRuleDisabled(rule: Rule) -> Bool {
return disabledRuleIdentifiers.contains(rule.dynamicType.description.identifier)
}
}