From ab7c0d172cf7c3db2eb3ee0e69474abf0f0a47fb Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 28 Oct 2015 14:41:13 -0400 Subject: [PATCH] Terms are annotated with `Info`. --- prototype/doubt-difftool/main.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prototype/doubt-difftool/main.swift b/prototype/doubt-difftool/main.swift index 14a18e748..70f59ccc2 100644 --- a/prototype/doubt-difftool/main.swift +++ b/prototype/doubt-difftool/main.swift @@ -7,7 +7,7 @@ func readFile(path: String) -> String? { return data as String? } -typealias Term = Cofree> +typealias Term = Cofree struct Info: Categorizable, CustomJSONConvertible, Equatable { let range: Range @@ -87,7 +87,7 @@ func termWithInput(string: String) -> Term? { } (root, Info.Category.Program) .map { node, category in let start = ts_node_pos(node).chars - return start..<(start + ts_node_size(node).chars) + return Info(range: start..<(start + ts_node_size(node).chars), category: category) } } } @@ -105,10 +105,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: Doubt.JSON.init, leaf: Doubt.JSON.String) } }, leaf: Doubt.JSON.String, annotation: { [ - "before": range($0), - "after": range($1), + "before": $0.JSON, + "after": $1.JSON, ] }), ]