From c3c707cd6abaf8a9881322183bb2f2d47387e4d4 Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 5 Feb 2020 19:49:32 -0500 Subject: [PATCH] Lookup scopes while adding import edges otherwise create intermediate scopes --- semantic-scope-graph/src/Data/ScopeGraph.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/semantic-scope-graph/src/Data/ScopeGraph.hs b/semantic-scope-graph/src/Data/ScopeGraph.hs index 49e60a249..0fcfdfe83 100644 --- a/semantic-scope-graph/src/Data/ScopeGraph.hs +++ b/semantic-scope-graph/src/Data/ScopeGraph.hs @@ -360,8 +360,13 @@ addImportEdge edge names currentAddress g = do case names of (x :| []) -> addImportHole x currentAddress g (x :| xs) -> do - let scopeGraph' = newScope x mempty g - addImportEdge edge (NonEmpty.fromList xs) x scopeGraph' + case lookupScope x g of + Just _ -> addImportEdge edge (NonEmpty.fromList xs) x g + Nothing -> + let + scopeGraph' = insertEdge edge x currentAddress (newScope x mempty g) + in + addImportEdge edge (NonEmpty.fromList xs) x scopeGraph' addImportHole :: Ord scopeAddress => scopeAddress -> scopeAddress -> ScopeGraph scopeAddress -> ScopeGraph scopeAddress