1
1
mirror of https://github.com/github/semantic.git synced 2025-01-09 00:56:32 +03:00

Extract alignSyntax to the top level.

This commit is contained in:
Rob Rix 2016-04-04 15:49:22 -04:00
parent 5ffd45ebe5
commit 013bf6e1c0

View File

@ -124,9 +124,10 @@ alignPatch _ _ = []
-- alignTerm sources infos syntax = (\ (source, info) -> Free . Annotated info <$> alignSyntax source (characterRange info) syntax) <$> Join (pairWithThese sources (runJoin infos)) -- alignTerm sources infos syntax = (\ (source, info) -> Free . Annotated info <$> alignSyntax source (characterRange info) syntax) <$> Join (pairWithThese sources (runJoin infos))
alignDiff :: Both (Source Char) -> Diff leaf Info -> AlignedDiff leaf alignDiff :: Both (Source Char) -> Diff leaf Info -> AlignedDiff leaf
alignDiff sources diff = iter alignSyntax (alignPatch sources <$> diff) alignDiff sources diff = iter (alignSyntax sources) (alignPatch sources <$> diff)
where alignSyntax :: Annotated leaf (Both Info) (AlignedDiff leaf) -> AlignedDiff leaf
alignSyntax (Annotated infos syntax) = case syntax of alignSyntax :: Both (Source Char) -> Annotated leaf (Both Info) (AlignedDiff leaf) -> AlignedDiff leaf
alignSyntax sources (Annotated infos syntax) = case syntax of
Leaf s -> modifyJoin (runBothWith bimap (((Free . (`Annotated` Leaf s)) .) . setCharacterRange <$> infos)) <$> sequenceL lineRanges Leaf s -> modifyJoin (runBothWith bimap (((Free . (`Annotated` Leaf s)) .) . setCharacterRange <$> infos)) <$> sequenceL lineRanges
Indexed children -> wrapInBranch Indexed <$> groupChildrenByLine lineRanges children Indexed children -> wrapInBranch Indexed <$> groupChildrenByLine lineRanges children
Fixed children -> wrapInBranch Fixed <$> groupChildrenByLine lineRanges children Fixed children -> wrapInBranch Fixed <$> groupChildrenByLine lineRanges children