1
1
mirror of https://github.com/github/semantic.git synced 2025-01-06 06:46:07 +03:00

Define an identity renderer for terms, for the tests.

This commit is contained in:
Rob Rix 2017-05-30 10:32:25 -04:00
parent f95dd4215d
commit a8fb1817d0
2 changed files with 5 additions and 0 deletions

View File

@ -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)

View File

@ -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'.