1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Serialize diffs to Builders.

This commit is contained in:
Rob Rix 2018-05-11 14:25:37 -04:00
parent a47251cef6
commit 0f218f5274
2 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ data DiffRenderer output where
-- | Render to a 'ByteString' formatted as nested s-expressions with patches indicated.
SExpressionDiffRenderer :: DiffRenderer ByteString
-- | Render to a 'ByteString' formatted as a DOT description of the diff.
DOTDiffRenderer :: DiffRenderer ByteString
DOTDiffRenderer :: DiffRenderer Builder
deriving instance Eq (DiffRenderer output)
deriving instance Show (DiffRenderer output)

View File

@ -1,7 +1,6 @@
{-# LANGUAGE GADTs #-}
module Semantic.Diff where
import Algebra.Graph.Export.Dot
import Analysis.ConstructorName (ConstructorName, constructorLabel)
import Analysis.IdentifierName (IdentifierName, identifierLabel)
import Analysis.Declaration (HasDeclaration, declarationAlgebra)
@ -20,6 +19,7 @@ import Rendering.Renderer
import Semantic.IO (NoLanguageForBlob(..))
import Semantic.Stat as Stat
import Semantic.Task as Task
import Serializing.Format
diffBlobPairs :: (Members '[Distribute WrappedTask, Task, Telemetry, Exc SomeException, IO] effs, Output output) => DiffRenderer output -> [BlobPair] -> Eff effs ByteString
diffBlobPairs renderer blobs = toOutput' <$> distributeFoldMap (WrapTask . diffBlobPair renderer) blobs
@ -35,7 +35,7 @@ diffBlobPair renderer blobs
ToCDiffRenderer -> run (WrapTask . (\ blob -> parse parser blob >>= decorate (declarationAlgebra blob))) diffTerms renderToCDiff
JSONDiffRenderer -> run (WrapTask . ( parse parser >=> decorate constructorLabel >=> decorate identifierLabel)) diffTerms renderJSONDiff
SExpressionDiffRenderer -> run (WrapTask . ( parse parser >=> decorate constructorLabel . (Nil <$))) diffTerms (const renderSExpressionDiff)
DOTDiffRenderer -> run (WrapTask . parse parser) diffTerms (const (export (diffStyle (pathKeyForBlobPair blobs)) . renderTreeGraph))
DOTDiffRenderer -> run (WrapTask . parse parser) diffTerms (const renderTreeGraph) >>= serialize (DOT (diffStyle (pathKeyForBlobPair blobs)))
| otherwise = throwError (SomeException (NoLanguageForBlob effectivePath))
where effectivePath = pathForBlobPair blobs
effectiveLanguage = languageForBlobPair blobs