1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Terms’ annotations are Infos.

This commit is contained in:
Rob Rix 2015-10-28 18:12:16 -04:00
parent 08120cb79f
commit b004a800b9

View File

@ -7,7 +7,7 @@ func readFile(path: String) -> String? {
return data as String?
}
typealias Term = Cofree<String, Range<Int>>
typealias Term = Cofree<String, Info>
struct Info: Categorizable, CustomJSONConvertible, Equatable {
let range: Range<Int>
@ -64,7 +64,7 @@ func termWithInput(string: String) -> Term? {
}
} (root, "program")
.map { node, category in
node.range
Info(range: node.range, categories: [ category ])
}
}
}
@ -82,10 +82,10 @@ if let aString = arguments[1].flatMap(readFile), bString = arguments[2].flatMap(
let JSON: Doubt.JSON = [
"before": .String(aString),
"after": .String(bString),
"diff": diff.JSON(pure: { $0.JSON { $0.JSON(annotation: range, leaf: Doubt.JSON.String) } }, leaf: Doubt.JSON.String, annotation: {
"diff": diff.JSON(pure: { $0.JSON { $0.JSON(annotation: { $0.range.JSON }, leaf: Doubt.JSON.String) } }, leaf: Doubt.JSON.String, annotation: {
[
"before": range($0),
"after": range($1),
"before": $0.range.JSON,
"after": $1.range.JSON,
]
}),
]