mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Terms are annotated with Info
.
This commit is contained in:
parent
9d0805c228
commit
ab7c0d172c
@ -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>
|
||||
@ -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,
|
||||
]
|
||||
}),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user