1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00
semantic/prototype/doubt-difftool/Info.swift

47 lines
1.1 KiB
Swift
Raw Normal View History

2015-10-29 20:52:21 +03:00
struct Info: Categorizable, CustomJSONConvertible, Equatable {
init(range: Range<Int>, lines: Range<Line>, columns: Range<Column>, categories: Set<String>) {
self.range = range
self.lines = lines
self.columns = columns
self.categories = categories
}
init(range: Range<String.CharacterView.Index>, lines: Range<Line>, columns: Range<Column>, categories: Set<String>) {
// FIXME: this is terrible. see also https://github.com/github/semantic-diff/issues/136
self.range = Int(String(range.startIndex))!..<Int(String(range.endIndex))!
self.lines = lines
self.columns = columns
2015-10-30 21:55:02 +03:00
self.categories = categories
}
2015-10-29 20:52:21 +03:00
let range: Range<Int>
let lines: Range<Line>
2015-11-04 23:11:01 +03:00
let columns: Range<Column>
2015-11-04 23:11:01 +03:00
2015-10-29 20:52:21 +03:00
// MARK: Categorizable
let categories: Set<String>
// MARK: CustomJSONConvertible
var JSON: Doubt.JSON {
return [
"range": range.JSON,
"lines": lines.JSON,
"columns": columns.JSON,
2015-10-29 20:52:21 +03:00
"categories": Array(categories).JSON
]
}
}
func == (left: Info, right: Info) -> Bool {
return left.range == right.range && left.categories == right.categories && left.lines == left.lines && left.columns == right.columns
2015-10-29 20:52:21 +03:00
}
2015-11-04 23:11:01 +03:00
import Madness
2015-10-29 20:52:21 +03:00
import Doubt