mirror of
https://github.com/github/semantic.git
synced 2024-12-31 19:20:19 +03:00
Serialize graphs to JSON.
This commit is contained in:
parent
599f10f76b
commit
0f9279b5f7
@ -28,7 +28,6 @@ module Rendering.Renderer
|
||||
import Data.Aeson (Value)
|
||||
import Data.ByteString.Builder
|
||||
import Data.Output
|
||||
import Prologue
|
||||
import Rendering.Graph as R
|
||||
import Rendering.Imports as R
|
||||
import Rendering.JSON as R
|
||||
@ -70,7 +69,7 @@ deriving instance Show (TermRenderer output)
|
||||
|
||||
-- | Specification of renderers for graph analysis, producing output in the parameter type.
|
||||
data GraphRenderer output where
|
||||
JSONGraphRenderer :: GraphRenderer ByteString
|
||||
JSONGraphRenderer :: GraphRenderer Builder
|
||||
DOTGraphRenderer :: GraphRenderer Builder
|
||||
|
||||
deriving instance Eq (GraphRenderer output)
|
||||
|
@ -13,7 +13,6 @@ import Data.Abstract.Package as Package
|
||||
import Data.Abstract.Value (Value, ValueError(..), runValueErrorWith)
|
||||
import Data.ByteString.Char8 (pack)
|
||||
import Data.File
|
||||
import Data.Output
|
||||
import Data.Record
|
||||
import Data.Semilattice.Lower
|
||||
import Data.Term
|
||||
@ -39,7 +38,7 @@ graph graphType renderer project
|
||||
ImportGraph -> id
|
||||
CallGraph -> graphingTerms
|
||||
analyze runGraphAnalysis (evaluatePackageWith graphingModules (withTermSpans . graphingLoadErrors . analyzeTerm) package) >>= extractGraph >>= case renderer of
|
||||
JSONGraphRenderer -> pure . toOutput
|
||||
JSONGraphRenderer -> serialize JSON
|
||||
DOTGraphRenderer -> serialize (DOT style)
|
||||
where extractGraph result = case result of
|
||||
(Right ((_, graph), _), _) -> pure graph
|
||||
|
Loading…
Reference in New Issue
Block a user