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

Map patches to ToC summaries without a second pass.

This commit is contained in:
Rob Rix 2017-05-08 15:20:22 -04:00
parent 03fc463c5c
commit 9750fa35ec

View File

@ -90,11 +90,10 @@ diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>
(_, _) -> False
diffToTOCSummaries :: HasDefaultFields fields => Both Source -> Diff (Syntax Text) (Record fields) -> [TOCSummary DiffInfo]
diffToTOCSummaries sources = para $ \diff -> case first (toTOCSummaries . runBothWith mapPatch toInfo) diff of
diffToTOCSummaries sources = para $ \diff -> case diff of
Free (annotations :< syntax) -> toList diff >>= \ summaries ->
fmap (contextualize (Both.snd sources) (Both.snd annotations :< fmap fst syntax)) (snd summaries)
Pure summaries -> summaries
where toInfo = termToDiffInfo <$> sources
Pure patch -> toTOCSummaries $ runBothWith mapPatch (termToDiffInfo <$> sources) patch
contextualize source (annotation :< syntax) summary
| Nothing <- parentInfo summary