This repository was archived by the owner on Sep 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +51
-8
lines changed
languages/tree-sitter-stack-graphs-python Expand file tree Collapse file tree 4 files changed +51
-8
lines changed Original file line number Diff line number Diff line change @@ -798,15 +798,21 @@ inherit .parent_module
798798 let @body.class_member_attr_scope = #null
799799}
800800
801- (function_definition
802- parameters: (parameters
803- . (identifier) @param)
804- body: (block) @body)
801+ ; method definition
802+ (class_definition
803+ body: (block
804+ (function_definition
805+ parameters:
806+ (parameters . (identifier) @first_param)
807+ body: (block) @method_body
808+ )
809+ )
810+ )
805811{
806- edge @param .def -> @param .class_self_scope
807- edge @param .class_member_attr_scope -> @param .output
808- edge @param .output -> @body .after_scope
809- attr (@param .output) push_node = @param
812+ edge @first_param .def -> @first_param .class_self_scope
813+ edge @first_param .class_member_attr_scope -> @first_param .output
814+ edge @first_param .output -> @method_body .after_scope
815+ attr (@first_param .output) push_node = @first_param
810816}
811817
812818[
Original file line number Diff line number Diff line change 1+ def outer (a ):
2+ def inner (b ):
3+ pass
4+
5+ inner (1 )
6+ # ^ defined: 2
Original file line number Diff line number Diff line change 1+ class Foo :
2+ a = 1
3+
4+ def first_method (self ):
5+ self .a
6+ # ^ defined: 2
7+
8+ def second_method (self ):
9+ self .a
10+ # ^ defined: 2
11+
12+ # First argument here is not self
13+ def not_a_method (not_self ):
14+ return not_self .a
15+ # ^ defined:
16+
17+
18+ def function (self ):
19+ self .a
20+ # ^ defined:
Original file line number Diff line number Diff line change 1+ class Foo :
2+ a = 1
3+
4+ def mathod_1 (self ):
5+ return self .a
6+ # ^ defined: 2
7+
8+ # Self can be named anything
9+ def method_2 (actually_self ):
10+ return actually_self .a
11+ # ^ defined: 2
You can’t perform that action at this time.
0 commit comments