8000 Replace onChildren with todo · github/semantic@711618c · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 711618c

Browse files
Replace onChildren with todo
Co-Authored-By: Josh Vera <vera@github.com>
1 parent 7e2f80e commit 711618c

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

semantic-python/src/Language/Python/ScopeGraph.hs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,13 @@ onField =
8383
scopeGraph @syn
8484
. getField @field
8585

86-
onChildren ::
87-
( Traversable t,
88-
ToScopeGraph syn,
89-
ScopeGraphEff sig m,
90-
HasField "extraChildren" (r Loc) (t (syn Loc))
91-
) =>
92-
r Loc ->
93-
m (Result (FocalPoint syn))
94-
onChildren =
95-
fmap fold
96-
. traverse scopeGraph
97-
. getField @"extraChildren"
98-
9986
scopeGraphModule :: ScopeGraphEff sig m => Py.Module Loc -> m (Result ())
10087
scopeGraphModule = getAp . scopeGraph
10188

10289
instance ToScopeGraph Py.AssertStatement where
10390
type FocalPoint Py.AssertStatement = [Stack.Node]
10491
scopeGraph assertStmt =
105-
fmap (\x -> [x]) <$> onChildren assertStmt
92+
fmap (\x -> [x]) <$> todo assertStmt
10693

10794
instance ToScopeGraph Py.Assignment where
10895
type FocalPoint Py.Assignment = Stack.Node
@@ -143,7 +130,7 @@ instance ToScopeGraph Py.Attribute where
143130
instance ToScopeGraph Py.Block where
144131
type FocalPoint Py.Block = [Stack.Node]
145132
scopeGraph block =
146-
fmap (either (fromEither . fromEither . fromEither) id) <$> onChildren block
133+
fmap (either (fromEither . fromEither . fromEither) id) <$> todo block
147134

148135
instance ToScopeGraph Py.BreakStatement where
149136
type FocalPoint Py.BreakStatement = [Stack.Node]
@@ -176,7 +163,7 @@ deriving instance ToScopeGraph Py.CompoundStatement
176163

177164
instance ToScopeGraph Py.ConditionalExpression where
178165
type FocalPoint Py.ConditionalExpression = Stack.Node
179-
scopeGraph = onChildren
166+
scopeGraph = todo
180167

181168
instance ToScopeGraph Py.ContinueStatement where
182169
type FocalPoint Py.ContinueStatement = [Stack.Node]
@@ -188,7 +175,7 @@ instance ToScopeGraph Py.DecoratedDefinition where
188175

189176
instance ToScopeGraph Py.ComparisonOperator where
190177
type FocalPoint Py.ComparisonOperator = Stack.Node
191-
scopeGraph = onChildren
178+
scopeGraph = todo
192179

193180
instance ToScopeGraph Py.DeleteStatement where
194181
type FocalPoint Py.DeleteStatement = [Stack.Node]
@@ -226,18 +213,18 @@ instance ToScopeGraph Py.Ellipsis where
226213

227214
instance ToScopeGraph Py.ExceptClause where
228215
type FocalPoint Py.ExceptClause = [Stack.Node]
229-
scopeGraph x = fmap (either (const []) id) <$> onChildren x
216+
scopeGraph x = fmap (either (const []) id) <$> todo x
230217

231218
instance ToScopeGraph Py.ExecStatement where
232219
type FocalPoint Py.ExecStatement = [Stack.Node]
233220
scopeGraph x = do
234-
onChildren x
221+
todo x
235222
pure (Complete [])
236223

237224
instance ToScopeGraph Py.ExpressionStatement where
238225
type FocalPoint Py.ExpressionStatement = [Stack.Node]
239226
scopeGraph x = do
240-
onChildren x
227+
todo x
241228
pure (Complete [])
242229

243230
instance ToScopeGraph Py.ExpressionList where
@@ -441,14 +428,14 @@ instance ToScopeGraph Py.NonlocalStatement where
441428

442429
instance ToScopeGraph Py.Module where
443430
type FocalPoint Py.Module = ()
444-
scopeGraph term@(Py.Module ann _) = do
431+
scopeGraph term@(Py.Module ann stmts) = do
445432
rootScope' <- rootScope
446433

447434
putCurrentScope "__main__"
448435

449436
modify (Stack.addEdge rootScope' (Stack.Declaration "__main__" Identifier ann))
450437

451-
_ <- onChildren term
438+
_ <- mapM scopeGraph stmts
452439

453440
newGraph <- get @(Stack.Graph Stack.Node)
454441

0 commit comments

Comments
 (0)
0