mirror of
https://github.com/github/semantic.git
synced 2025-01-03 13:02:37 +03:00
alignSyntax takes the infos and syntax unpacked.
This commit is contained in:
parent
013bf6e1c0
commit
df4247d0c9
@ -11,6 +11,7 @@ module Alignment
|
|||||||
, groupChildrenByLine
|
, groupChildrenByLine
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Control.Arrow ((&&&))
|
||||||
import Control.Comonad.Cofree
|
import Control.Comonad.Cofree
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.Free
|
import Control.Monad.Free
|
||||||
@ -124,10 +125,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 sources) (alignPatch sources <$> diff)
|
alignDiff sources diff = iter (uncurry (alignSyntax sources) . (annotation &&& syntax)) (alignPatch sources <$> diff)
|
||||||
|
|
||||||
alignSyntax :: Both (Source Char) -> Annotated leaf (Both Info) (AlignedDiff leaf) -> AlignedDiff leaf
|
alignSyntax :: Both (Source Char) -> Both Info -> Syntax leaf (AlignedDiff leaf) -> AlignedDiff leaf
|
||||||
alignSyntax sources (Annotated infos syntax) = case syntax of
|
alignSyntax sources 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
|
||||||
|
Loading…
Reference in New Issue
Block a user