From a8fb1817d0c3091555e8cd8fcafc15bcda1b7f32 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 30 May 2017 10:32:25 -0400 Subject: [PATCH] Define an identity renderer for terms, for the tests. --- src/Renderer.hs | 2 ++ src/Semantic.hs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/Renderer.hs b/src/Renderer.hs index 5ec07a670..e4c295f26 100644 --- a/src/Renderer.hs +++ b/src/Renderer.hs @@ -23,6 +23,7 @@ import Renderer.Patch as R import Renderer.SExpression as R import Renderer.TOC as R import Syntax as S +import Term (SyntaxTerm) data DiffRenderer output where PatchDiffRenderer :: DiffRenderer File @@ -37,6 +38,7 @@ deriving instance Show (DiffRenderer output) data TermRenderer output where JSONTermRenderer :: TermRenderer [Value] SExpressionTermRenderer :: TermRenderer ByteString + IdentityTermRenderer :: TermRenderer (Maybe (SyntaxTerm Text DefaultFields)) deriving instance Eq (TermRenderer output) deriving instance Show (TermRenderer output) diff --git a/src/Semantic.hs b/src/Semantic.hs index 8eac37dd2..f0417202e 100644 --- a/src/Semantic.hs +++ b/src/Semantic.hs @@ -37,6 +37,9 @@ parseAndRenderBlob renderer blob@SourceBlob{..} = case renderer of SExpressionTermRenderer -> case blobLanguage of Just Language.Python -> parse pythonParser source >>= render renderSExpressionTerm . fmap (Info.Other "Term" :.) language -> parse (parserForLanguage language) source >>= render renderSExpressionTerm + IdentityTermRenderer -> case blobLanguage of + Just Language.Python -> pure Nothing + language -> Just <$> parse (parserForLanguage language) source -- | A task to parse a pair of 'SourceBlob's, diff them, and render the 'Diff'.