1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +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 (Child key contents) = Child key <$> crosswalk lines contents
alignBranchElement (Margin contents) = Margin <$> 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 :: [BranchElement] -> (Both (Source.Source Char), Both [Range])
toSourcesAndRanges elements = (sources, Source.actualLineRanges <$> totalRanges <*> sources) toSourcesAndRanges elements = (sources, Source.actualLineRanges <$> totalRanges <*> sources)
where sources = foldMap Source.fromList <$> bothContents elements where sources = foldMap Source.fromList <$> bothContents elements
totalRanges = totalRange <$> sources totalRanges = totalRange <$> sources
bothContents = foldMap (modifyJoin (fromThese [] []) . fmap (:[]) . branchElementContents)
toAlignedChildren :: [BranchElement] -> [(String, [Join These Range])] toAlignedChildren :: [BranchElement] -> [(String, [Join These Range])]
toAlignedChildren = join . (`evalState` both 0 0) . mapM go toAlignedChildren = join . (`evalState` both 0 0) . mapM go