1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +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 (_, _) -> False
diffToTOCSummaries :: HasDefaultFields fields => Both Source -> Diff (Syntax Text) (Record fields) -> [TOCSummary DiffInfo] 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 -> Free (annotations :< syntax) -> toList diff >>= \ summaries ->
fmap (contextualize (Both.snd sources) (Both.snd annotations :< fmap fst syntax)) (snd summaries) fmap (contextualize (Both.snd sources) (Both.snd annotations :< fmap fst syntax)) (snd summaries)
Pure summaries -> summaries Pure patch -> toTOCSummaries $ runBothWith mapPatch (termToDiffInfo <$> sources) patch
where toInfo = termToDiffInfo <$> sources
contextualize source (annotation :< syntax) summary contextualize source (annotation :< syntax) summary
| Nothing <- parentInfo summary | Nothing <- parentInfo summary