mirror of
https://github.com/github/semantic.git
synced 2025-01-05 05:58:34 +03:00
🔥 InSummarizable.
This commit is contained in:
parent
d38b76f554
commit
490820c79d
@ -22,9 +22,7 @@ data JSONSummary = JSONSummary { info :: Summarizable }
|
|||||||
deriving (Generic, Eq, Show)
|
deriving (Generic, Eq, Show)
|
||||||
|
|
||||||
instance ToJSON JSONSummary where
|
instance ToJSON JSONSummary where
|
||||||
toJSON JSONSummary{..} = object $ case info of
|
toJSON (JSONSummary Summarizable{..}) = object [ "changeType" .= summarizableChangeType, "category" .= toCategoryName summarizableCategory, "term" .= summarizableTermName, "span" .= summarizableSourceSpan ]
|
||||||
InSummarizable{..} -> [ "changeType" .= ("modified" :: Text), "category" .= toCategoryName parentCategory, "term" .= parentTermName, "span" .= parentSourceSpan ]
|
|
||||||
Summarizable{..} -> [ "changeType" .= summarizableChangeType, "category" .= toCategoryName summarizableCategory, "term" .= summarizableTermName, "span" .= summarizableSourceSpan ]
|
|
||||||
toJSON ErrorSummary{..} = object [ "error" .= error, "span" .= errorSpan ]
|
toJSON ErrorSummary{..} = object [ "error" .= error, "span" .= errorSpan ]
|
||||||
|
|
||||||
isErrorSummary :: JSONSummary -> Bool
|
isErrorSummary :: JSONSummary -> Bool
|
||||||
@ -51,11 +49,6 @@ data Summarizable
|
|||||||
, summarizableSourceSpan :: SourceSpan
|
, summarizableSourceSpan :: SourceSpan
|
||||||
, summarizableChangeType :: Text
|
, summarizableChangeType :: Text
|
||||||
}
|
}
|
||||||
| InSummarizable
|
|
||||||
{ parentCategory :: Category
|
|
||||||
, parentTermName :: Text
|
|
||||||
, parentSourceSpan :: SourceSpan
|
|
||||||
}
|
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
toc :: HasDefaultFields fields => Both SourceBlob -> Diff (Syntax Text) (Record fields) -> Summaries
|
toc :: HasDefaultFields fields => Both SourceBlob -> Diff (Syntax Text) (Record fields) -> Summaries
|
||||||
@ -93,7 +86,7 @@ diffTOC blobs diff = removeDupes (diffToTOCSummaries (source <$> blobs) diff) >>
|
|||||||
Free (Join (_, annotation) :< syntax)
|
Free (Join (_, annotation) :< syntax)
|
||||||
| isSummarizable syntax
|
| isSummarizable syntax
|
||||||
, Just termName <- toTermName (Both.snd sources) . cofree . (annotation :<) <$> traverse (afterTerm . fst) syntax
|
, Just termName <- toTermName (Both.snd sources) . cofree . (annotation :<) <$> traverse (afterTerm . fst) syntax
|
||||||
, parentInfo <- InSummarizable (category annotation) termName (sourceSpan annotation) ->
|
, parentInfo <- Summarizable (category annotation) termName (sourceSpan annotation) "modified" ->
|
||||||
foldMap (fmap (contextualize parentInfo) . snd) syntax
|
foldMap (fmap (contextualize parentInfo) . snd) syntax
|
||||||
| otherwise -> foldMap snd syntax
|
| otherwise -> foldMap snd syntax
|
||||||
Pure patch -> fmap summarize (sequenceA (runBothWith mapPatch (toInfo <$> sources) patch))
|
Pure patch -> fmap summarize (sequenceA (runBothWith mapPatch (toInfo <$> sources) patch))
|
||||||
|
Loading…
Reference in New Issue
Block a user