1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Flatten toTOCSummaries.

This commit is contained in:
Rob Rix 2017-05-05 15:33:16 -04:00
parent 948869066c
commit 0ab53b002a

View File

@ -103,16 +103,14 @@ diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>
-- Mark which leaves are summarizable.
toTOCSummaries :: Patch DiffInfo -> [TOCSummary DiffInfo]
toTOCSummaries patch = toTOCSummaries' patch (afterOrBefore patch)
where
toTOCSummaries' patch' diffInfo = case diffInfo of
ErrorInfo{..} -> pure $ TOCSummary patch' NotSummarizable
BranchInfo{..} -> join $ zipWith toTOCSummaries' (flattenPatch patch') branches
LeafInfo{..} -> pure . TOCSummary patch' $ case leafCategory of
C.Function -> Summarizable leafCategory termName leafSourceSpan (patchType patch')
C.Method -> Summarizable leafCategory termName leafSourceSpan (patchType patch')
C.SingletonMethod -> Summarizable leafCategory termName leafSourceSpan (patchType patch')
_ -> NotSummarizable
toTOCSummaries patch = case afterOrBefore patch of
ErrorInfo{..} -> pure $ TOCSummary patch NotSummarizable
BranchInfo{..} -> flattenPatch patch >>= toTOCSummaries
LeafInfo{..} -> pure . TOCSummary patch $ case leafCategory of
C.Function -> Summarizable leafCategory termName leafSourceSpan (patchType patch)
C.Method -> Summarizable leafCategory termName leafSourceSpan (patchType patch)
C.SingletonMethod -> Summarizable leafCategory termName leafSourceSpan (patchType patch)
_ -> NotSummarizable
flattenPatch :: Patch DiffInfo -> [Patch DiffInfo]
flattenPatch patch = case patch of