mirror of
https://github.com/github/semantic.git
synced 2024-12-20 13:21:59 +03:00
Split the LoadError handling out into a separate function.
This commit is contained in:
parent
0dedd68188
commit
136a9661d2
@ -3,6 +3,7 @@ module Analysis.Abstract.ImportGraph
|
||||
( ImportGraph(..)
|
||||
, renderImportGraph
|
||||
, graphingTerms
|
||||
, graphingLoadErrors
|
||||
, graphingModules
|
||||
, importGraphing
|
||||
) where
|
||||
@ -54,12 +55,10 @@ style = (defaultStyle vertexName)
|
||||
edgeAttributes Variable{} Module{} = [ "color" := "blue" ]
|
||||
edgeAttributes _ _ = []
|
||||
|
||||
graphingTerms :: forall location term value effects syntax ann a
|
||||
. ( Element Syntax.Identifier syntax
|
||||
graphingTerms :: ( Element Syntax.Identifier syntax
|
||||
, Members '[ Reader (Environment (Located location) value)
|
||||
, Reader ModuleInfo
|
||||
, Reader PackageInfo
|
||||
, Resumable (LoadError term)
|
||||
, State (Environment (Located location) value)
|
||||
, State (ImportGraph term)
|
||||
] effects
|
||||
@ -73,8 +72,16 @@ graphingTerms recur term@(In _ syntax) = do
|
||||
moduleInclusion (Variable (unName name))
|
||||
variableDefinition name
|
||||
_ -> pure ()
|
||||
resume
|
||||
@(LoadError term)
|
||||
(recur term)
|
||||
|
||||
graphingLoadErrors :: forall location term value effects a
|
||||
. Members '[ Reader ModuleInfo
|
||||
, Resumable (LoadError term)
|
||||
, State (ImportGraph term)
|
||||
] effects
|
||||
=> SubtermAlgebra (Base term) term (Evaluator location term value effects a)
|
||||
-> SubtermAlgebra (Base term) term (Evaluator location term value effects a)
|
||||
graphingLoadErrors recur term = resume @(LoadError term)
|
||||
(recur term)
|
||||
(\ (LoadError name) -> moduleInclusion (Module (BC.pack name)) *> pure [])
|
||||
|
||||
|
@ -108,7 +108,7 @@ graphImports :: ( Show ann
|
||||
)
|
||||
=> Package (Term (Sum syntax) ann)
|
||||
-> Eff effs (ImportGraph (Term (Sum syntax) ann))
|
||||
graphImports package = analyze importGraphAnalysis (evaluatePackageWith graphingModules graphingTerms package) >>= extractGraph
|
||||
graphImports package = analyze importGraphAnalysis (evaluatePackageWith graphingModules (graphingLoadErrors . graphingTerms) package) >>= extractGraph
|
||||
where
|
||||
extractGraph result = case result of
|
||||
(Right (Right ((_, graph), _)), _) -> pure graph
|
||||
|
Loading…
Reference in New Issue
Block a user