1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Add alignSyntax to split a leaf by its lines.

Doesn’t yet operate on branches. Invalidates some other assumptions.
This commit is contained in:
Rob Rix 2016-03-18 14:56:32 -04:00
parent d318b6565c
commit 21356e0144

View File

@ -122,3 +122,7 @@ alignPatch sources (Replace term1 term2) = let Join (This info1) :< AlignThis a
alignTermBy :: Both (Source Char) -> (forall r. [Syntax leaf r] -> Aligned (Syntax leaf) r) -> Join These Info -> Syntax leaf (AlignedDiff leaf) -> AlignedDiff leaf
alignTermBy sources constructor infos syntax = infos :< constructor [syntax]
alignSyntax :: Both (Source Char) -> Join These Range -> Syntax leaf (AlignedDiff leaf) -> Join These [Syntax leaf (AlignedDiff leaf)]
alignSyntax sources ranges (Leaf s) = (Leaf s <$) <$> lineRanges
where lineRanges = uncurry actualLineRanges <$> Join (runBothWith bimap (flip (,) <$> sources) (runJoin ranges))