1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Use modifyJoin to map leaf lines.

This commit is contained in:
Rob Rix 2016-03-24 14:04:43 -04:00
parent 4c132d0c2d
commit 6d4e3761c6

View File

@ -126,7 +126,7 @@ alignDiff :: Both (Source Char) -> Diff leaf Info -> AlignedDiff leaf
alignDiff sources diff = iter alignSyntax (alignPatch sources <$> diff)
where alignSyntax :: Annotated leaf (Both Info) (AlignedDiff leaf) -> AlignedDiff leaf
alignSyntax (Annotated infos syntax) = case syntax of
Leaf s -> (Join . bimap (Free . (`Annotated` Leaf s) . setCharacterRange (fst infos)) (Free . (`Annotated` Leaf s) . setCharacterRange (snd infos)) . runJoin) <$> sequenceL lineRanges
Leaf s -> (modifyJoin $ bimap (Free . (`Annotated` Leaf s) . setCharacterRange (fst infos)) (Free . (`Annotated` Leaf s) . setCharacterRange (snd infos))) <$> sequenceL lineRanges
Indexed children -> (Join . bimap (\ (range, children) -> Free (Annotated (setCharacterRange (fst infos) range) (Indexed children))) (\ (range, children) -> Free (Annotated (setCharacterRange (snd infos) range) (Indexed children))) . runJoin) <$> groupChildrenByLine lineRanges children
_ -> []
where lineRanges = runBothWith ((Join .) . These) (actualLineRanges <$> (characterRange <$> infos) <*> sources)