From cf37d082d18d836ef27c32d40cdff4b539bf2a29 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 2 Oct 2019 13:18:02 -0400 Subject: [PATCH] Define sets of parsers for each diff output format. --- src/Semantic/Api/Diffs.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Semantic/Api/Diffs.hs b/src/Semantic/Api/Diffs.hs index 0643884ef..5d5de2c48 100644 --- a/src/Semantic/Api/Diffs.hs +++ b/src/Semantic/Api/Diffs.hs @@ -10,7 +10,9 @@ module Semantic.Api.Diffs , SomeTermPair(..) + , legacySummarizeDiffParsers , LegacySummarizeDiff(..) + , summarizeDiffParsers , SummarizeDiff(..) ) 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 +dotGraphDiffParsers :: [(Language, SomeParser DOTGraphDiff Loc)] +dotGraphDiffParsers = aLaCarteParsers + class HasDiffFor term => DOTGraphDiff term where 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 +jsonGraphDiffParsers :: [(Language, SomeParser JSONGraphDiff Loc)] +jsonGraphDiffParsers = aLaCarteParsers + class HasDiffFor term => JSONGraphDiff term where jsonGraphDiff :: BlobPair -> DiffFor term Loc Loc -> DiffTreeFileGraph @@ -104,6 +112,9 @@ instance (Foldable syntax, Functor syntax, ConstructorName syntax) => JSONGraphD lang = bridging # languageForBlobPair blobPair +jsonTreeDiffParsers :: [(Language, SomeParser JSONTreeDiff Loc)] +jsonTreeDiffParsers = aLaCarteParsers + class HasDiffFor term => JSONTreeDiff term where jsonTreeDiff :: BlobPair -> DiffFor term Loc Loc -> Rendering.JSON.JSON "diffs" SomeJSON @@ -111,6 +122,9 @@ instance ToJSONFields1 syntax => JSONTreeDiff (Term syntax) where jsonTreeDiff = renderJSONDiff +sexprDiffParsers :: [(Language, SomeParser SExprDiff Loc)] +sexprDiffParsers = aLaCarteParsers + class HasDiffFor term => SExprDiff term where 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) +showDiffParsers :: [(Language, SomeParser ShowDiff Loc)] +showDiffParsers = aLaCarteParsers + class HasDiffFor term => ShowDiff term where 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 +legacySummarizeDiffParsers :: [(Language, SomeParser LegacySummarizeDiff Loc)] +legacySummarizeDiffParsers = aLaCarteParsers + class HasDiffFor term => LegacySummarizeDiff term where legacyDecorateTerm :: Blob -> term Loc -> term (Maybe Declaration) legacySummarizeDiff :: BlobPair -> DiffFor term (Maybe Declaration) (Maybe Declaration) -> Summaries @@ -134,6 +154,9 @@ instance (Foldable syntax, Functor syntax, HasDeclaration syntax) => LegacySumma legacySummarizeDiff = renderToCDiff +summarizeDiffParsers :: [(Language, SomeParser SummarizeDiff Loc)] +summarizeDiffParsers = aLaCarteParsers + class HasDiffFor term => SummarizeDiff term where decorateTerm :: Blob -> term Loc -> term (Maybe Declaration) summarizeDiff :: BlobPair -> DiffFor term (Maybe Declaration) (Maybe Declaration) -> TOCSummaryFile