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