1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00

Insert vertices rather than names.

This commit is contained in:
Rob Rix 2018-04-02 18:19:56 -04:00
parent 1d375d8d61
commit 92b4cb9168

View File

@ -60,7 +60,7 @@ instance ( Effectful m
analyzeTerm eval term@(In _ syntax) = do
case prj syntax of
Just (Syntax.Identifier name) -> do
insertVertexName name
insertVertex (Variable name)
o <- lookupEnv name
case o >>= withSomeOrigin originModule . origin . unAddress of
Just ModuleInfo{..} -> modifyImportGraph (vertex (Variable name) >< vertex (Module moduleName) <>)
@ -70,13 +70,13 @@ instance ( Effectful m
resumeException
@(LoadError term value)
(liftAnalyze analyzeTerm eval term)
(\yield (LoadError name) -> insertVertexName name >> yield [])
(\yield (LoadError name) -> insertVertex (Module name) >> yield [])
analyzeModule recur m = do
let name = moduleName (moduleInfo m)
o <- raise ask
modifyImportGraph (packageGraph @term o >< vertex (Module name) <>)
insertVertexName name
insertVertex (Module name)
liftAnalyze analyzeModule recur m
parentGraph :: SomeOrigin term -> ImportGraph
@ -88,17 +88,17 @@ packageGraph = maybe empty (vertex . Package . packageName) . withSomeOrigin ori
moduleGraph :: SomeOrigin term -> ImportGraph
moduleGraph = maybe empty (vertex . Module . moduleName) . withSomeOrigin originModule
insertVertexName :: forall m location term value effects
insertVertex :: forall m location term value effects
. ( Effectful m
, Member (Reader (SomeOrigin term)) effects
, Member (State ImportGraph) effects
, MonadEvaluator location term value (m effects)
)
=> NonEmpty ByteString
=> Vertex
-> ImportGraphing m effects ()
insertVertexName name = do
insertVertex v = do
o <- raise ask
modifyImportGraph (parentGraph @term o >< vertex (Module name) <>)
modifyImportGraph (parentGraph @term o >< vertex v <>)
(><) :: Graph a => a -> a -> a
(><) = connect