1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 17:59:10 +03:00

Patches of terms annotated with ranges can produce JSON over source strings.

This commit is contained in:
Rob Rix 2015-10-16 11:09:30 -04:00
parent 8c341fc129
commit 01d65a4245

View File

@ -140,3 +140,13 @@ extension Patch: PatchType {
self = .Insert(after)
}
}
extension PatchType where Element: CofreeType, Element.Annotation == Range<String.Index> {
public func JSON(a a: String, b: String) -> Doubt.JSON {
return [
"before": state.before.map { $0.JSON(a) } ?? nil,
"after": state.after.map { $0.JSON(b) } ?? nil,
]
}
}