1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

🔥 the top-level bothContents binding.

This commit is contained in:
Rob Rix 2016-05-25 13:32:33 -04:00
parent eb15740170
commit b4d0749d52

View File

@ -207,13 +207,11 @@ alignBranchElement :: BranchElement -> [BranchElement]
alignBranchElement (Child key contents) = Child key <$> crosswalk lines contents
alignBranchElement (Margin contents) = Margin <$> crosswalk lines contents
bothContents :: [BranchElement] -> Both [String]
bothContents = foldMap (modifyJoin (fromThese [] []) . fmap (:[]) . branchElementContents)
toSourcesAndRanges :: [BranchElement] -> (Both (Source.Source Char), Both [Range])
toSourcesAndRanges elements = (sources, Source.actualLineRanges <$> totalRanges <*> sources)
where sources = foldMap Source.fromList <$> bothContents elements
totalRanges = totalRange <$> sources
bothContents = foldMap (modifyJoin (fromThese [] []) . fmap (:[]) . branchElementContents)
toAlignedChildren :: [BranchElement] -> [(String, [Join These Range])]
toAlignedChildren = join . (`evalState` both 0 0) . mapM go