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:
parent
f95dd4215d
commit
a8fb1817d0
@ -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)
|
||||
|
@ -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'.
|
||||
|
Loading…
Reference in New Issue
Block a user