mirror of
https://github.com/github/semantic.git
synced 2024-12-30 18:36:27 +03:00
Define a function to compute a JSONSummary from an Entry.
This commit is contained in:
parent
284f358d7a
commit
13d088e6b8
@ -10,6 +10,7 @@ module Renderer.TOC
|
||||
, declarationAlgebra
|
||||
, Entry(..)
|
||||
, tableOfContentsBy
|
||||
, entrySummary
|
||||
) where
|
||||
|
||||
import Category as C
|
||||
@ -106,6 +107,14 @@ tableOfContentsBy selector = fromMaybe [] . iter diffAlgebra . fmap (Just . fmap
|
||||
termAlgebra r | Just a <- selector r = [a]
|
||||
| otherwise = fold r
|
||||
|
||||
-- | Construct a 'JSONSummary' from an 'Entry'. Returns 'Nothing' for 'Unchanged' patches.
|
||||
entrySummary :: (HasField fields Category, HasField fields (Maybe Declaration), HasField fields SourceSpan) => Entry (Record fields) -> Maybe JSONSummary
|
||||
entrySummary entry = case entry of
|
||||
Unchanged _ -> Nothing
|
||||
Changed a -> Just (recordSummary a "modified")
|
||||
Patched p -> Just (recordSummary (afterOrBefore p) (patchType p))
|
||||
where recordSummary record = JSONSummary . Summarizable (category record) (maybe "" declarationIdentifier (getField record :: Maybe Declaration)) (sourceSpan record)
|
||||
|
||||
toc :: HasDefaultFields fields => Both SourceBlob -> Diff (Syntax Text) (Record fields) -> Summaries
|
||||
toc blobs diff = Summaries changes errors
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user