1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Don’t produce valid JSON summaries in the presence of errors.

This commit is contained in:
Rob Rix 2017-05-10 15:57:41 -04:00
parent 72faa30494
commit bb634a5e51

View File

@ -16,7 +16,6 @@ module Renderer.TOC
import Category as C
import Data.Aeson
import Data.Align (crosswalk)
import Data.Functor.Both hiding (fst, snd)
import qualified Data.Functor.Both as Both
import Data.Text (toLower)
@ -102,7 +101,7 @@ tableOfContentsBy :: Traversable f
=> (forall b. TermF f annotation b -> Maybe a) -- ^ A function mapping relevant nodes onto values in Maybe.
-> Diff f annotation -- ^ The diff to compute the table of contents for.
-> [Entry a] -- ^ A list of entries for relevant changed and unchanged nodes in the diff.
tableOfContentsBy selector = fromMaybe [] . iter diffAlgebra . fmap (Just . fmap Patched . crosswalk (cata termAlgebra))
tableOfContentsBy selector = fromMaybe [] . iter diffAlgebra . fmap (Just . fmap Patched . traverse (cata termAlgebra))
where diffAlgebra r = case (selector (first Both.snd r), fold r) of
(Just a, Nothing) -> Just [Unchanged a]
(Just a, Just []) -> Just [Changed a]