mirror of
https://github.com/github/semantic.git
synced 2025-01-03 21:16:12 +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.Aeson (Value)
|
||||||
import Data.ByteString.Builder
|
import Data.ByteString.Builder
|
||||||
import Data.Output
|
import Data.Output
|
||||||
import Prologue
|
|
||||||
import Rendering.Graph as R
|
import Rendering.Graph as R
|
||||||
import Rendering.Imports as R
|
import Rendering.Imports as R
|
||||||
import Rendering.JSON 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.
|
-- | Specification of renderers for graph analysis, producing output in the parameter type.
|
||||||
data GraphRenderer output where
|
data GraphRenderer output where
|
||||||
JSONGraphRenderer :: GraphRenderer ByteString
|
JSONGraphRenderer :: GraphRenderer Builder
|
||||||
DOTGraphRenderer :: GraphRenderer Builder
|
DOTGraphRenderer :: GraphRenderer Builder
|
||||||
|
|
||||||
deriving instance Eq (GraphRenderer output)
|
deriving instance Eq (GraphRenderer output)
|
||||||
|
@ -13,7 +13,6 @@ import Data.Abstract.Package as Package
|
|||||||
import Data.Abstract.Value (Value, ValueError(..), runValueErrorWith)
|
import Data.Abstract.Value (Value, ValueError(..), runValueErrorWith)
|
||||||
import Data.ByteString.Char8 (pack)
|
import Data.ByteString.Char8 (pack)
|
||||||
import Data.File
|
import Data.File
|
||||||
import Data.Output
|
|
||||||
import Data.Record
|
import Data.Record
|
||||||
import Data.Semilattice.Lower
|
import Data.Semilattice.Lower
|
||||||
import Data.Term
|
import Data.Term
|
||||||
@ -39,7 +38,7 @@ graph graphType renderer project
|
|||||||
ImportGraph -> id
|
ImportGraph -> id
|
||||||
CallGraph -> graphingTerms
|
CallGraph -> graphingTerms
|
||||||
analyze runGraphAnalysis (evaluatePackageWith graphingModules (withTermSpans . graphingLoadErrors . analyzeTerm) package) >>= extractGraph >>= case renderer of
|
analyze runGraphAnalysis (evaluatePackageWith graphingModules (withTermSpans . graphingLoadErrors . analyzeTerm) package) >>= extractGraph >>= case renderer of
|
||||||
JSONGraphRenderer -> pure . toOutput
|
JSONGraphRenderer -> serialize JSON
|
||||||
DOTGraphRenderer -> serialize (DOT style)
|
DOTGraphRenderer -> serialize (DOT style)
|
||||||
where extractGraph result = case result of
|
where extractGraph result = case result of
|
||||||
(Right ((_, graph), _), _) -> pure graph
|
(Right ((_, graph), _), _) -> pure graph
|
||||||
|
Loading…
Reference in New Issue
Block a user