mirror of
https://github.com/github/semantic.git
synced 2024-12-22 22:31:36 +03:00
Align patches.
This commit is contained in:
parent
0132f180ed
commit
06dd79dc76
@ -114,11 +114,11 @@ type Row a = Both (Line a)
|
||||
type AlignedDiff leaf = [Join These (SplitDiff leaf Info)]
|
||||
|
||||
alignPatch :: Both (Source Char) -> Patch (Term leaf Info) -> AlignedDiff leaf
|
||||
alignPatch sources (Delete term) = hylo (alignSyntax (Join . This . runIdentity) (Identity $ fst sources)) unCofree (Identity <$> term)
|
||||
alignPatch sources (Insert term) = hylo (alignSyntax (Join . That . runIdentity) (Identity $ snd sources)) unCofree (Identity <$> term)
|
||||
alignPatch _ _ = []
|
||||
-- alignPatch sources (Replace term1 term2) = alignWith Join (hylo (alignTerm sources) unCofree term1)
|
||||
-- (hylo (alignTerm sources) unCofree term2)
|
||||
alignPatch sources (Delete term) = hylo (alignSyntax (Join . This . runIdentity) (Identity (fst sources))) unCofree (Identity <$> term)
|
||||
alignPatch sources (Insert term) = hylo (alignSyntax (Join . That . runIdentity) (Identity (snd sources))) unCofree (Identity <$> term)
|
||||
alignPatch sources (Replace term1 term2) = alignWith (fmap (these id id const . runJoin) . Join)
|
||||
(hylo (alignSyntax (Join . This . runIdentity) (Identity (fst sources))) unCofree (Identity <$> term1))
|
||||
(hylo (alignSyntax (Join . That . runIdentity) (Identity (snd sources))) unCofree (Identity <$> term2))
|
||||
|
||||
alignDiff :: Both (Source Char) -> Diff leaf Info -> AlignedDiff leaf
|
||||
alignDiff sources diff = iter (uncurry (alignSyntax (runBothWith ((Join .) . These)) sources) . (annotation &&& syntax)) (alignPatch sources <$> diff)
|
||||
|
Loading…
Reference in New Issue
Block a user