mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Change insertEdge to take 1 edge
This commit is contained in:
parent
e6460394e8
commit
b95a575ae2
@ -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
|
||||
|
@ -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') }
|
||||
|
Loading…
Reference in New Issue
Block a user