From b95a575ae22241077a5ed3607604b2e288f2bae3 Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 5 Feb 2020 18:03:53 -0500 Subject: [PATCH] Change insertEdge to take 1 edge --- semantic-python/test-graphing/GraphTest.hs | 7 +++++-- semantic-scope-graph/src/Data/ScopeGraph.hs | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/semantic-python/test-graphing/GraphTest.hs b/semantic-python/test-graphing/GraphTest.hs index ebfb5cc67..e915438fc 100644 --- a/semantic-python/test-graphing/GraphTest.hs +++ b/semantic-python/test-graphing/GraphTest.hs @@ -103,7 +103,10 @@ expectedFunctionArg = do pure Complete expectedImportHole :: (Has Sketch sig m) => m Result -expectedImportHole = undefined +expectedImportHole = do + addImportEdge Import ["cheese", "ints"] + + assertLexicalScope :: HUnit.Assertion assertLexicalScope = do @@ -123,7 +126,7 @@ assertFunctionArg = do assertImportHole :: HUnit.Assertion assertImportHole = do - let path = "semantic-python/test/fixtures/cheese/6-01-import-holes.py" + let path = "semantic-python/test/fixtures/cheese/6-01-imports.py" (graph, _) <- graphFile path case run (runSketch Nothing expectedImportHole) of (expecto, Complete) -> HUnit.assertEqual "Should work for simple case" expecto graph diff --git a/semantic-scope-graph/src/Data/ScopeGraph.hs b/semantic-scope-graph/src/Data/ScopeGraph.hs index fee0b2bf5..f8992c24c 100644 --- a/semantic-scope-graph/src/Data/ScopeGraph.hs +++ b/semantic-scope-graph/src/Data/ScopeGraph.hs @@ -346,8 +346,8 @@ putDeclarationScopeAtPosition scope position assocScope g@(ScopeGraph graph) = f lookupReference :: Ord scopeAddress => Name -> scopeAddress -> ScopeGraph scopeAddress -> Maybe (Path scopeAddress) lookupReference name scope g = fmap snd . Map.lookup (Reference name) =<< pathsOfScope scope g -insertEdge :: Ord scopeAddress => EdgeLabel -> NonEmpty scopeAddress -> scopeAddress -> ScopeGraph scopeAddress -> ScopeGraph scopeAddress -insertEdge label targets currentAddress g@(ScopeGraph graph) = fromMaybe g $ do +insertEdge :: Ord scopeAddress => EdgeLabel -> scopeAddress -> scopeAddress -> ScopeGraph scopeAddress -> ScopeGraph scopeAddress +insertEdge label hole currentAddress g@(ScopeGraph graph) = fromMaybe g $ do currentScope' <- lookupScope currentAddress g scopes <- maybe (Just mempty) pure (Map.lookup label (edges currentScope')) let newScope = currentScope' { edges = Map.insert label (toList targets <> scopes) (edges currentScope') }