1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

🔥 flattenPatch.

traverse has different semantics, but I’m pretty sure the zipWith was problematic.
This commit is contained in:
Rob Rix 2017-05-08 15:50:13 -04:00
parent 967ded76a8
commit 51d548cb0a

View File

@ -105,7 +105,7 @@ diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>
toTOCSummaries patch = case afterOrBefore patch of
ErrorInfo{..} -> pure $ TOCSummary patch Nothing
BranchInfo{..} -> flattenPatch (toLeafInfos <$> patch) >>= toTOCSummaries
BranchInfo{..} -> traverse toLeafInfos patch >>= toTOCSummaries
LeafInfo{..} -> pure . TOCSummary patch $ case leafCategory of
C.Function -> Just $ Summarizable leafCategory termName leafSourceSpan (patchType patch)
C.Method -> Just $ Summarizable leafCategory termName leafSourceSpan (patchType patch)
@ -122,12 +122,6 @@ diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>
isSummarizable S.Function{} = True
isSummarizable _ = False
flattenPatch :: Patch [a] -> [Patch a]
flattenPatch patch = case patch of
Replace i1 i2 -> zipWith Replace i1 i2
Insert info -> Insert <$> info
Delete info -> Delete <$> info
toLeafInfos :: DiffInfo -> [DiffInfo]
toLeafInfos BranchInfo{..} = branches >>= toLeafInfos
toLeafInfos leaf = [leaf]