@@ -208,6 +208,8 @@ instance ToScopeGraph Py.ClassDefinition where
208
208
for_ bindings $ \ (node, statement) -> do
209
209
if isInstanceMember statement then
210
210
modify (Stack. addEdge (Stack. InstanceMembers " IM" ) node)
211
+ else if isClassMember statement then
212
+ modify (Stack. addEdge (Stack. ClassMembers " CM" ) node)
211
213
else pure ()
212
214
undefined
213
215
res -> pure res
@@ -218,11 +220,28 @@ instance ToScopeGraph Py.ClassDefinition where
218
220
219
221
isInstanceMember :: (Py. SimpleStatement :+: Py. CompoundStatement ) a -> Bool
220
222
isInstanceMember statement = case statement of
221
- L1 _ -> False
223
+ L1 ( Py. SimpleStatement _) -> False
222
224
R1 (Py. CompoundStatement compoundStatement) -> case compoundStatement of
223
225
Prj (Py. FunctionDefinition {}) -> True
224
226
_ -> False
225
227
228
+ isClassMember :: (Py. SimpleStatement :+: Py. CompoundStatement ) a -> Bool
229
+ isClassMember statement = case statement of
230
+ L1 (Py. SimpleStatement simpleStatement) -> case simpleStatement of
231
+ Prj (Py. ExpressionStatement _ expressions) -> all isAssignment expressions
232
+ _ -> False
233
+ R1 (Py. CompoundStatement compoundStatement) -> case compoundStatement of
234
+ _ -> False
235
+
236
+ isAssignment :: (:+: )
237
+ (Py. Expression :+: Py. Assignment )
238
+ (Py. AugmentedAssignment :+: Py. Yield )
239
+ a -> Bool
240
+ isAssignment expressionStatement = case expressionStatement of
241
+ Prj (Py. Assignment {}) -> True
242
+ Prj (Py. AugmentedAssignment {}) -> True
243
+ _ -> False
244
+
226
245
instance ToScopeGraph Py. ConcatenatedString where
227
246
type FocalPoint Py. ConcatenatedString _ = Stack. Node
228
247
scopeGraph = todo
0 commit comments