1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 17:59:10 +03:00

Define sets of parsers for each diff output format.

This commit is contained in:
Rob Rix 2019-10-02 13:18:02 -04:00
parent 589a567e60
commit cf37d082d1
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -10,7 +10,9 @@ module Semantic.Api.Diffs
, SomeTermPair(..) , SomeTermPair(..)
, legacySummarizeDiffParsers
, LegacySummarizeDiff(..) , LegacySummarizeDiff(..)
, summarizeDiffParsers
, SummarizeDiff(..) , SummarizeDiff(..)
) where ) where
@ -85,6 +87,9 @@ type DiffEffects sig m = (Member (Error SomeException) sig, Member (Reader Confi
type Decorate a b = forall term . DiffActions term => Blob -> term a -> term b type Decorate a b = forall term . DiffActions term => Blob -> term a -> term b
dotGraphDiffParsers :: [(Language, SomeParser DOTGraphDiff Loc)]
dotGraphDiffParsers = aLaCarteParsers
class HasDiffFor term => DOTGraphDiff term where class HasDiffFor term => DOTGraphDiff term where
dotGraphDiff :: (Carrier sig m, Member (Reader Config) sig) => DiffFor term Loc Loc -> m Builder dotGraphDiff :: (Carrier sig m, Member (Reader Config) sig) => DiffFor term Loc Loc -> m Builder
@ -92,6 +97,9 @@ instance (ConstructorName syntax, Foldable syntax, Functor syntax) => DOTGraphDi
dotGraphDiff = serialize (DOT (diffStyle "diffs")) . renderTreeGraph dotGraphDiff = serialize (DOT (diffStyle "diffs")) . renderTreeGraph
jsonGraphDiffParsers :: [(Language, SomeParser JSONGraphDiff Loc)]
jsonGraphDiffParsers = aLaCarteParsers
class HasDiffFor term => JSONGraphDiff term where class HasDiffFor term => JSONGraphDiff term where
jsonGraphDiff :: BlobPair -> DiffFor term Loc Loc -> DiffTreeFileGraph jsonGraphDiff :: BlobPair -> DiffFor term Loc Loc -> DiffTreeFileGraph
@ -104,6 +112,9 @@ instance (Foldable syntax, Functor syntax, ConstructorName syntax) => JSONGraphD
lang = bridging # languageForBlobPair blobPair lang = bridging # languageForBlobPair blobPair
jsonTreeDiffParsers :: [(Language, SomeParser JSONTreeDiff Loc)]
jsonTreeDiffParsers = aLaCarteParsers
class HasDiffFor term => JSONTreeDiff term where class HasDiffFor term => JSONTreeDiff term where
jsonTreeDiff :: BlobPair -> DiffFor term Loc Loc -> Rendering.JSON.JSON "diffs" SomeJSON jsonTreeDiff :: BlobPair -> DiffFor term Loc Loc -> Rendering.JSON.JSON "diffs" SomeJSON
@ -111,6 +122,9 @@ instance ToJSONFields1 syntax => JSONTreeDiff (Term syntax) where
jsonTreeDiff = renderJSONDiff jsonTreeDiff = renderJSONDiff
sexprDiffParsers :: [(Language, SomeParser SExprDiff Loc)]
sexprDiffParsers = aLaCarteParsers
class HasDiffFor term => SExprDiff term where class HasDiffFor term => SExprDiff term where
sexprDiff :: (Carrier sig m, Member (Reader Config) sig) => DiffFor term Loc Loc -> m Builder sexprDiff :: (Carrier sig m, Member (Reader Config) sig) => DiffFor term Loc Loc -> m Builder
@ -118,6 +132,9 @@ instance (ConstructorName syntax, Foldable syntax, Functor syntax) => SExprDiff
sexprDiff = serialize (SExpression ByConstructorName) sexprDiff = serialize (SExpression ByConstructorName)
showDiffParsers :: [(Language, SomeParser ShowDiff Loc)]
showDiffParsers = aLaCarteParsers
class HasDiffFor term => ShowDiff term where class HasDiffFor term => ShowDiff term where
showDiff :: (Carrier sig m, Member (Reader Config) sig) => DiffFor term Loc Loc -> m Builder showDiff :: (Carrier sig m, Member (Reader Config) sig) => DiffFor term Loc Loc -> m Builder
@ -125,6 +142,9 @@ instance Show1 syntax => ShowDiff (Term syntax) where
showDiff = serialize Show showDiff = serialize Show
legacySummarizeDiffParsers :: [(Language, SomeParser LegacySummarizeDiff Loc)]
legacySummarizeDiffParsers = aLaCarteParsers
class HasDiffFor term => LegacySummarizeDiff term where class HasDiffFor term => LegacySummarizeDiff term where
legacyDecorateTerm :: Blob -> term Loc -> term (Maybe Declaration) legacyDecorateTerm :: Blob -> term Loc -> term (Maybe Declaration)
legacySummarizeDiff :: BlobPair -> DiffFor term (Maybe Declaration) (Maybe Declaration) -> Summaries legacySummarizeDiff :: BlobPair -> DiffFor term (Maybe Declaration) (Maybe Declaration) -> Summaries
@ -134,6 +154,9 @@ instance (Foldable syntax, Functor syntax, HasDeclaration syntax) => LegacySumma
legacySummarizeDiff = renderToCDiff legacySummarizeDiff = renderToCDiff
summarizeDiffParsers :: [(Language, SomeParser SummarizeDiff Loc)]
summarizeDiffParsers = aLaCarteParsers
class HasDiffFor term => SummarizeDiff term where class HasDiffFor term => SummarizeDiff term where
decorateTerm :: Blob -> term Loc -> term (Maybe Declaration) decorateTerm :: Blob -> term Loc -> term (Maybe Declaration)
summarizeDiff :: BlobPair -> DiffFor term (Maybe Declaration) (Maybe Declaration) -> TOCSummaryFile summarizeDiff :: BlobPair -> DiffFor term (Maybe Declaration) (Maybe Declaration) -> TOCSummaryFile