mirror of
https://github.com/github/semantic.git
synced 2024-12-18 04:11:48 +03:00
Define reference to initial scope outside of for_ loop
This commit is contained in:
parent
5339ee2e03
commit
02db8cfa8e
@ -231,16 +231,17 @@ instance ToScopeGraph Py.GlobalStatement where scopeGraph = todo
|
||||
instance ToScopeGraph Py.Integer where scopeGraph = mempty
|
||||
|
||||
instance ToScopeGraph Py.ImportStatement where
|
||||
scopeGraph (Py.ImportStatement _ ((R1 (Py.DottedName _ names)) :| [])) = do
|
||||
scopeGraph (Py.ImportStatement _ ((R1 (Py.DottedName _ names@((Py.Identifier ann name) :| _))) :| [])) = do
|
||||
let toName (Py.Identifier _ name) = Name.name name
|
||||
newEdge ScopeGraph.Import (toName <$> names)
|
||||
|
||||
let xs = zip (toList names) (tail $ toList names)
|
||||
for_ xs $ \pair -> do
|
||||
case pair of
|
||||
(scopeIdentifier@(Py.Identifier ann _), referenceIdentifier@(Py.Identifier ann2 _)) -> do
|
||||
let referenceProps = Props.Reference ScopeGraph.Identifier ScopeGraph.Default (ann^.span_ :: Span)
|
||||
newReference (toName scopeIdentifier) referenceProps
|
||||
newReference (Name.name name) referenceProps
|
||||
|
||||
let pairs = zip (toList names) (tail $ toList names)
|
||||
for_ pairs $ \pair -> do
|
||||
case pair of
|
||||
(scopeIdentifier, referenceIdentifier@(Py.Identifier ann2 _)) -> do
|
||||
withScope (toName scopeIdentifier) $ do
|
||||
let referenceProps = Props.Reference ScopeGraph.Identifier ScopeGraph.Default (ann2^.span_ :: Span)
|
||||
newReference (toName referenceIdentifier) referenceProps
|
||||
|
Loading…
Reference in New Issue
Block a user