1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 13:34:31 +03:00

Line JSON contains the range of all the diffs on the line.

This commit is contained in:
Rob Rix 2016-03-02 08:16:27 -05:00
parent 5eaa843abc
commit d5f9b170d4

View File

@ -60,7 +60,9 @@ instance ToJSON (Term leaf Info) where
toEncoding (info :< syntax) = pairs $ mconcat (termFields info syntax)
lineFields :: KeyValue kv => Int -> Line (SplitDiff leaf Info) -> [kv]
lineFields n line = [ "number" .= n, "terms" .= unLine line, "hasChanges" .= hasChanges line ]
lineFields n line = [ "number" .= n, "terms" .= unLine line, "range" .= unionRanges (getRange <$> line), "hasChanges" .= hasChanges line ]
where getRange (Free (Annotated (Info range _) _)) = range
getRange (Pure patch) = case getSplitTerm patch of Info range _ :< _ -> range
termFields :: (ToJSON recur, KeyValue kv) => Info -> Syntax leaf recur -> [kv]
termFields (Info range categories) syntax = "range" .= range : "categories" .= categories : case syntax of