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

Drop the SourceBlob parameters from s-expression rendering.

This commit is contained in:
Rob Rix 2017-05-26 10:07:22 -04:00
parent 3b3b19bd1e
commit 4748cac0ac
2 changed files with 6 additions and 8 deletions

View File

@ -38,9 +38,9 @@ runRenderer :: (Monoid output, StringConv output ByteString) => Renderer input o
runRenderer renderer = case renderer of
PatchRenderer -> File . uncurry R.patch
JSONRenderer -> uncurry R.json
SExpressionDiffRenderer format -> uncurry (R.sExpression format)
SExpressionDiffRenderer format -> R.sExpression format . snd
ToCRenderer -> uncurry R.toc
SExpressionParseTreeRenderer format -> uncurry (R.sExpressionParseTree format) . first runIdentity
SExpressionParseTreeRenderer format -> R.sExpressionParseTree format . snd
declarationDecorator :: Source -> Term (Syntax Text) (Record DefaultFields) -> Term (Syntax Text) (Record (Maybe Declaration ': DefaultFields))

View File

@ -7,26 +7,24 @@ module Renderer.SExpression
import Data.Bifunctor.Join
import Data.ByteString hiding (foldr, spanEnd)
import Data.Functor.Both
import Data.Record
import Prologue hiding (replicate, encodeUtf8)
import Category as C
import Diff
import Patch
import Info
import Source
import Term
data SExpressionFormat = TreeOnly | TreeAndRanges
deriving (Show)
-- | Returns a ByteString SExpression formatted diff.
sExpression :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => SExpressionFormat -> Both SourceBlob -> Diff f (Record fields) -> ByteString
sExpression format _ diff = printDiff diff 0 format <> "\n"
sExpression :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => SExpressionFormat -> Diff f (Record fields) -> ByteString
sExpression format diff = printDiff diff 0 format <> "\n"
-- | Returns a ByteString SExpression formatted term.
sExpressionParseTree :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => SExpressionFormat -> SourceBlob -> Term f (Record fields) -> ByteString
sExpressionParseTree format _ term = printTerm term 0 format <> "\n"
sExpressionParseTree :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => SExpressionFormat -> Term f (Record fields) -> ByteString
sExpressionParseTree format term = printTerm term 0 format <> "\n"
printDiff :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => Diff f (Record fields) -> Int -> SExpressionFormat -> ByteString
printDiff diff level format = case runFree diff of