From 3dcc0de5b2ed58ee3c804944baa8ec510ab67ce8 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 18 Oct 2019 15:00:41 -0400 Subject: [PATCH] Facror the common part of runGraph out. --- src/Semantic/Graph.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Semantic/Graph.hs b/src/Semantic/Graph.hs index 64efad5cd..a51b66a2b 100644 --- a/src/Semantic/Graph.hs +++ b/src/Semantic/Graph.hs @@ -122,16 +122,14 @@ runGraph :: ( Member Distribute sig -> Project -> m (Graph ControlFlowVertex) runGraph type' includePackages project - | SomeAnalysisParser parser (lang :: Proxy lang) <- someAnalysisParser (Proxy @AnalyzeTerm) (projectLanguage project) = case type' of - ImportGraph -> do + | SomeAnalysisParser parser (lang :: Proxy lang) <- someAnalysisParser (Proxy @AnalyzeTerm) (projectLanguage project) = do let parse = if projectLanguage project == Language.Python then parsePythonPackage parser else fmap (fmap snd) . parsePackage parser package <- parse project - runImportGraphToModuleInfos lang package - CallGraph -> do - let parse = if projectLanguage project == Language.Python then parsePythonPackage parser else fmap (fmap snd) . parsePackage parser - package <- parse project - modules <- topologicalSort <$> runImportGraphToModules lang package - runCallGraph lang includePackages modules package + case type' of + ImportGraph -> runImportGraphToModuleInfos lang package + CallGraph -> do + modules <- topologicalSort <$> runImportGraphToModules lang package + runCallGraph lang includePackages modules package runCallGraph :: ( AnalyzeTerm term , HasPrelude lang