mirror of
https://github.com/github/semantic.git
synced 2024-12-11 08:45:48 +03:00
Module inclusion uses the State effect.
This commit is contained in:
parent
93c315402d
commit
4226bab371
@ -55,10 +55,10 @@ style = (defaultStyle (byteString . vertexName))
|
||||
-- | Add vertices to the graph for evaluated identifiers.
|
||||
graphingTerms :: ( Element Syntax.Identifier syntax
|
||||
, Members '[ Reader (Environment (Located location) value)
|
||||
, Reader ModuleInfo
|
||||
, Reader PackageInfo
|
||||
, State (Environment (Located location) value)
|
||||
, State (Graph Vertex)
|
||||
, State (Maybe ModuleInfo)
|
||||
] effects
|
||||
, term ~ Term (Sum syntax) ann
|
||||
)
|
||||
@ -73,17 +73,16 @@ graphingTerms recur term@(In _ syntax) = do
|
||||
recur term
|
||||
|
||||
-- | Add vertices to the graph for 'LoadError's.
|
||||
graphingLoadErrors :: Members '[ Reader ModuleInfo
|
||||
, Resumable (LoadError location value)
|
||||
graphingLoadErrors :: Members '[ Resumable (LoadError location value)
|
||||
, State (Graph Vertex)
|
||||
, State (Maybe ModuleInfo)
|
||||
] effects
|
||||
=> SubtermAlgebra (Base term) term (TermEvaluator term location value effects a)
|
||||
-> SubtermAlgebra (Base term) term (TermEvaluator term location value effects a)
|
||||
graphingLoadErrors recur term = TermEvaluator (runTermEvaluator (recur term) `resumeLoadError` (\ (ModuleNotFound name) -> moduleInclusion (Module (BC.pack name)) *> moduleNotFound name))
|
||||
|
||||
-- | Add vertices to the graph for evaluated modules and the packages containing them.
|
||||
graphingModules :: Members '[ Reader ModuleInfo
|
||||
, Reader PackageInfo
|
||||
graphingModules :: Members '[ Reader PackageInfo
|
||||
, State (Graph Vertex)
|
||||
, State (Maybe ModuleInfo)
|
||||
] effects
|
||||
@ -117,16 +116,16 @@ packageInclusion v = do
|
||||
|
||||
-- | Add an edge from the current module to the passed vertex.
|
||||
moduleInclusion :: ( Effectful m
|
||||
, Members '[ Reader ModuleInfo
|
||||
, State (Graph Vertex)
|
||||
, Members '[ State (Graph Vertex)
|
||||
, State (Maybe ModuleInfo)
|
||||
] effects
|
||||
, Monad (m effects)
|
||||
)
|
||||
=> Vertex
|
||||
-> m effects ()
|
||||
moduleInclusion v = do
|
||||
m <- currentModule
|
||||
appendGraph (moduleGraph m `connect` vertex v)
|
||||
m <- get
|
||||
appendGraph (maybe mempty moduleGraph m `connect` (vertex v))
|
||||
|
||||
-- | Add an edge from the passed variable name to the module it originated within.
|
||||
variableDefinition :: ( Member (Reader (Environment (Located location) value)) effects
|
||||
|
Loading…
Reference in New Issue
Block a user