mirror of
https://github.com/github/semantic.git
synced 2025-01-02 12:23:08 +03:00
Serializing requires only the config.
This commit is contained in:
parent
e4587c6cb5
commit
199372d0f3
@ -18,6 +18,7 @@ import Data.AST
|
||||
import Data.Blob
|
||||
import Parsing.Parser
|
||||
import Rendering.JSON (renderJSONAST)
|
||||
import Semantic.Config
|
||||
import Semantic.Task
|
||||
import qualified Serializing.Format as F
|
||||
|
||||
@ -36,7 +37,7 @@ astParseBlob blob@Blob{..}
|
||||
data ASTFormat = SExpression | JSON | Show | Quiet
|
||||
deriving (Show)
|
||||
|
||||
runASTParse :: (Member Distribute sig, Member (Error SomeException) sig, Member Parse sig, Member (Reader TaskSession) sig, Carrier sig m, MonadIO m) => ASTFormat -> [Blob] -> m F.Builder
|
||||
runASTParse :: (Member Distribute sig, Member (Error SomeException) sig, Member Parse sig, Member (Reader Config) sig, Carrier sig m, MonadIO m) => ASTFormat -> [Blob] -> m F.Builder
|
||||
runASTParse SExpression = distributeFoldMap (astParseBlob >=> withSomeAST (serialize (F.SExpression F.ByShow)))
|
||||
runASTParse Show = distributeFoldMap (astParseBlob >=> withSomeAST (serialize F.Show . fmap nodeSymbol))
|
||||
runASTParse JSON = distributeFoldMap (\ blob -> withSomeAST (renderJSONAST blob) <$> astParseBlob blob) >=> serialize F.JSON
|
||||
|
@ -35,6 +35,7 @@ import Rendering.Graph
|
||||
import Rendering.JSON hiding (JSON)
|
||||
import qualified Rendering.JSON
|
||||
import Semantic.Api.Bridge
|
||||
import Semantic.Config
|
||||
import Semantic.Proto.SemanticPB hiding (Blob, BlobPair)
|
||||
import Semantic.Task as Task
|
||||
import Semantic.Telemetry as Stat
|
||||
@ -96,7 +97,7 @@ dotGraphDiff :: (DiffEffects sig m) => BlobPair -> m Builder
|
||||
dotGraphDiff blobPair = doDiff blobPair (const id) render
|
||||
where render _ = serialize (DOT (diffStyle "diffs")) . renderTreeGraph
|
||||
|
||||
type DiffEffects sig m = (Member (Error SomeException) sig, Member (Reader TaskSession) sig, Member Telemetry sig, Member Distribute sig, Member Parse sig, Carrier sig m, MonadIO m)
|
||||
type DiffEffects sig m = (Member (Error SomeException) sig, Member (Reader Config) sig, Member (Reader TaskSession) sig, Member Telemetry sig, Member Distribute sig, Member Parse sig, Carrier sig m, MonadIO m)
|
||||
|
||||
type CanDiff syntax = (ConstructorName syntax, Diffable syntax, Eq1 syntax, HasDeclaration syntax, Hashable1 syntax, Show1 syntax, ToJSONFields1 syntax, Traversable syntax)
|
||||
type Decorate a b = forall syntax . CanDiff syntax => Blob -> Term syntax a -> Term syntax b
|
||||
|
@ -37,6 +37,7 @@ import Rendering.Graph
|
||||
import Rendering.JSON hiding (JSON)
|
||||
import qualified Rendering.JSON
|
||||
import Semantic.Api.Bridge
|
||||
import Semantic.Config
|
||||
import Semantic.Proto.SemanticPB hiding (Blob)
|
||||
import Semantic.Task
|
||||
import Serializing.Format hiding (JSON)
|
||||
@ -102,7 +103,7 @@ quietTerm blob = showTiming blob <$> time' ( (doParse blob >>= withSomeTerm (fma
|
||||
in stringUtf8 (status <> "\t" <> show (blobLanguage blob) <> "\t" <> blobPath blob <> "\t" <> show duration <> " ms\n")
|
||||
|
||||
|
||||
type ParseEffects sig m = (Member (Error SomeException) sig, Member (Reader PerLanguageModes) sig, Member Parse sig, Member (Reader TaskSession) sig, Carrier sig m)
|
||||
type ParseEffects sig m = (Member (Error SomeException) sig, Member (Reader PerLanguageModes) sig, Member Parse sig, Member (Reader Config) sig, Member (Reader TaskSession) sig, Carrier sig m)
|
||||
|
||||
type TermConstraints =
|
||||
'[ Taggable
|
||||
|
@ -108,12 +108,12 @@ parse :: (Member Parse sig, Carrier sig m)
|
||||
-> m term
|
||||
parse parser blob = send (Parse parser blob pure)
|
||||
|
||||
serialize :: (Member (Reader TaskSession) sig, Carrier sig m)
|
||||
serialize :: (Member (Reader Config) sig, Carrier sig m)
|
||||
=> Format input
|
||||
-> input
|
||||
-> m Builder
|
||||
serialize format input = do
|
||||
formatStyle <- asks (Flag.choose IsTerminal Plain Colourful . configIsTerminal . config)
|
||||
formatStyle <- asks (Flag.choose IsTerminal Plain Colourful . configIsTerminal)
|
||||
pure (runSerialize formatStyle format input)
|
||||
|
||||
data TaskSession
|
||||
|
Loading…
Reference in New Issue
Block a user