mirror of
https://github.com/github/semantic.git
synced 2024-12-26 16:33:03 +03:00
Add a toPrettyDiff function to abstract the construction of pretty diffs away.
This commit is contained in:
parent
24a732322c
commit
e0e7f0fa4a
@ -218,6 +218,11 @@ toAlignedChildren = join . (`evalState` both 0 0) . mapM go
|
|||||||
put $ (+) <$> prev <*> modifyJoin (fromThese 0 0) (length <$> contents)
|
put $ (+) <$> prev <*> modifyJoin (fromThese 0 0) (length <$> contents)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
toPrettyDiff :: [BranchElement] -> PrettyDiff [(String, Range)]
|
||||||
|
toPrettyDiff elements = PrettyDiff sources (alignBranch id children ranges)
|
||||||
|
where (sources, ranges) = toSourcesAndRanges elements
|
||||||
|
children = toAlignedChildren elements
|
||||||
|
|
||||||
instance Arbitrary BranchElement where
|
instance Arbitrary BranchElement where
|
||||||
arbitrary = oneof [ key >>= \ key -> Child key <$> joinTheseOf (contents key)
|
arbitrary = oneof [ key >>= \ key -> Child key <$> joinTheseOf (contents key)
|
||||||
, Margin <$> joinTheseOf margin ]
|
, Margin <$> joinTheseOf margin ]
|
||||||
|
Loading…
Reference in New Issue
Block a user