From 4dedb928b219acd4f7827830b44e5210601a7441 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 11 Sep 2018 15:20:19 -0700 Subject: [PATCH] New command line flag json-graph --- src/Rendering/Renderer.hs | 4 ++-- src/Semantic/CLI.hs | 4 ++-- src/Semantic/Diff.hs | 2 +- src/Semantic/Parse.hs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Rendering/Renderer.hs b/src/Rendering/Renderer.hs index d675f676e..c564a302a 100644 --- a/src/Rendering/Renderer.hs +++ b/src/Rendering/Renderer.hs @@ -36,7 +36,7 @@ data DiffRenderer output where -- | Render to JSON with the format documented in docs/json-format.md JSONDiffRenderer :: DiffRenderer (JSON "diffs" SomeJSON) -- | Render to JSON as an adjacency list. - JSONAdjDiffRenderer :: DiffRenderer (JSON "diffs" SomeJSON) + JSONGraphDiffRenderer :: DiffRenderer (JSON "diffs" SomeJSON) -- | Render to a 'ByteString' formatted as nested s-expressions with patches indicated. SExpressionDiffRenderer :: DiffRenderer Builder -- | Render to a 'ByteString' formatted as a DOT description of the diff. @@ -52,7 +52,7 @@ data TermRenderer output where -- | Render to JSON with the format documented in docs/json-format.md under “Term.” JSONTermRenderer :: TermRenderer (JSON "trees" SomeJSON) -- | Render to JSON as an adjacency list represenation. - JSONAdjTermRenderer :: TermRenderer (JSON "trees" SomeJSON) + JSONGraphTermRenderer :: TermRenderer (JSON "trees" SomeJSON) -- | Render to a 'ByteString' formatted as nested s-expressions. SExpressionTermRenderer :: TermRenderer Builder -- | Render to a list of symbols. diff --git a/src/Semantic/CLI.hs b/src/Semantic/CLI.hs index 909d7f176..bd7f57107 100644 --- a/src/Semantic/CLI.hs +++ b/src/Semantic/CLI.hs @@ -60,7 +60,7 @@ diffCommand = command "diff" (info diffArgumentsParser (progDesc "Compute change diffArgumentsParser = do renderer <- flag (Diff.runDiff SExpressionDiffRenderer) (Diff.runDiff SExpressionDiffRenderer) (long "sexpression" <> help "Output s-expression diff tree (default)") <|> flag' (Diff.runDiff JSONDiffRenderer) (long "json" <> help "Output JSON diff trees") - <|> flag' (Diff.runDiff JSONAdjDiffRenderer) (long "json-adj" <> help "Output JSON diff trees") + <|> flag' (Diff.runDiff JSONGraphDiffRenderer) (long "json-graph" <> help "Output JSON diff trees") <|> flag' (Diff.runDiff ToCDiffRenderer) (long "toc" <> help "Output JSON table of contents diff summary") <|> flag' (Diff.runDiff DOTDiffRenderer) (long "dot" <> help "Output the diff as a DOT graph") <|> flag' (Diff.runDiff ShowDiffRenderer) (long "show" <> help "Output using the Show instance (debug only, format subject to change without notice)") @@ -73,7 +73,7 @@ parseCommand = command "parse" (info parseArgumentsParser (progDesc "Generate pa parseArgumentsParser = do renderer <- flag (Parse.runParse SExpressionTermRenderer) (Parse.runParse SExpressionTermRenderer) (long "sexpression" <> help "Output s-expression parse trees (default)") <|> flag' (Parse.runParse JSONTermRenderer) (long "json" <> help "Output JSON parse trees") - <|> flag' (Parse.runParse JSONAdjTermRenderer) (long "json-adj" <> help "Output JSON adjacency list") + <|> flag' (Parse.runParse JSONGraphTermRenderer) (long "json-graph" <> help "Output JSON adjacency list") <|> flag' (Parse.runParse . SymbolsTermRenderer) (long "symbols" <> help "Output JSON symbol list") <*> (option symbolFieldsReader ( long "fields" <> help "Comma delimited list of specific fields to return (symbols output only)." diff --git a/src/Semantic/Diff.hs b/src/Semantic/Diff.hs index efe756ec7..77100bc6c 100644 --- a/src/Semantic/Diff.hs +++ b/src/Semantic/Diff.hs @@ -28,7 +28,7 @@ import qualified Rendering.JSON as JSON runDiff :: (Member Distribute effs, Member (Exc SomeException) effs, Member (Lift IO) effs, Member Task effs, Member Telemetry effs) => DiffRenderer output -> [BlobPair] -> Eff effs Builder runDiff ToCDiffRenderer = withParsedBlobPairs (decorate . declarationAlgebra) (render . renderToCDiff) >=> serialize JSON runDiff JSONDiffRenderer = withParsedBlobPairs (const pure) (render . renderJSONDiff) >=> serialize JSON -runDiff JSONAdjDiffRenderer = withParsedBlobPairs (const pure) (render . renderAdjGraph) >=> serialize JSON +runDiff JSONGraphDiffRenderer = withParsedBlobPairs (const pure) (render . renderAdjGraph) >=> serialize JSON where renderAdjGraph :: (Recursive t, ToTreeGraph DiffVertex (Base t)) => BlobPair -> t -> JSON.JSON "diffs" SomeJSON renderAdjGraph blob diff = renderJSONAdjDiff blob (renderTreeGraph diff) runDiff SExpressionDiffRenderer = withParsedBlobPairs (const pure) (const (serialize (SExpression ByConstructorName))) diff --git a/src/Semantic/Parse.hs b/src/Semantic/Parse.hs index 73bceed3a..b009653d0 100644 --- a/src/Semantic/Parse.hs +++ b/src/Semantic/Parse.hs @@ -24,7 +24,7 @@ import Serializing.Format runParse :: (Member Distribute effs, Member (Exc SomeException) effs, Member Task effs) => TermRenderer output -> [Blob] -> Eff effs Builder runParse JSONTermRenderer = withParsedBlobs renderJSONError (render . renderJSONTerm) >=> serialize JSON -runParse JSONAdjTermRenderer = withParsedBlobs renderJSONError (render . renderAdjGraph) >=> serialize JSON +runParse JSONGraphTermRenderer = withParsedBlobs renderJSONError (render . renderAdjGraph) >=> serialize JSON where renderAdjGraph :: (Recursive t, ToTreeGraph TermVertex (Base t)) => Blob -> t -> JSON.JSON "trees" SomeJSON renderAdjGraph blob term = renderJSONAdjTerm blob (renderTreeGraph term) runParse SExpressionTermRenderer = withParsedBlobs (\_ _ -> mempty) (const (serialize (SExpression ByConstructorName)))