@@ -20,14 +20,18 @@ def process_node(
2020 result = self ._create_base_result (node )
2121
2222 if node .type == "type_declaration" :
23- return self ._handle_type_declaration (node , source_code , result , process_children_callback )
23+ return self ._handle_type_declaration (
24+ node , source_code , result , process_children_callback
25+ )
2426
2527 elif node .type in ["function_declaration" , "method_declaration" ]:
2628 for child in node .children :
2729 if child .type in ["identifier" , "field_identifier" ]:
2830 result ["name" ] = self .extract_node_text (child , source_code )
2931 result ["first_line" ] = (
30- self .extract_node_text (node , source_code ).split ("\n " )[0 ].strip ("{" )
32+ self .extract_node_text (node , source_code )
33+ .split ("\n " )[0 ]
34+ .strip ("{" )
3135 )
3236 return result
3337 return result
@@ -57,7 +61,11 @@ def process_node(
5761 return result
5862
5963 def _handle_type_declaration (
60- self , node , source_code : bytes , result : Dict [str , Any ], process_children_callback
64+ self ,
65+ node ,
66+ source_code : bytes ,
67+ result : Dict [str , Any ],
68+ process_children_callback ,
6169 ) -> Dict [str , Any ]:
6270 for child in node .children :
6371 if child .type == "type_spec" :
@@ -72,7 +80,9 @@ def _handle_type_declaration(
7280 children = []
7381 for field in struct_child .children :
7482 field_result = process_children_callback (field )
75- if field_result and self ._is_significant_node (field_result ):
83+ if field_result and self ._is_significant_node (
84+ field_result
85+ ):
7686 children .append (field_result )
7787 if children :
7888 result ["children" ] = children
@@ -92,7 +102,15 @@ def _handle_var_declaration(
92102 for subchild in child .children :
93103 if subchild .type == "identifier" and var_name is None :
94104 var_name = self .extract_node_text (subchild , source_code )
95- elif subchild .type in ["type_identifier" , "pointer_type" , "array_type" , "slice_type" , "map_type" , "channel_type" , "qualified_type" ]:
105+ elif subchild .type in [
106+ "type_identifier" ,
107+ "pointer_type" ,
108+ "array_type" ,
109+ "slice_type" ,
110+ "map_type" ,
111+ "channel_type" ,
112+ "qualified_type" ,
113+ ]:
96114 var_type = self .extract_node_text (subchild , source_code )
97115
98116 if var_name :
@@ -113,7 +131,17 @@ def _handle_field_declaration(
113131 for child in node .children :
114132 if child .type == "field_identifier" :
115133 field_name = self .extract_node_text (child , source_code )
116- elif child .type in ["type_identifier" , "pointer_type" , "array_type" , "slice_type" , "map_type" , "channel_type" , "qualified_type" , "struct_type" , "interface_type" ]:
134+ elif child .type in [
135+ "type_identifier" ,
136+ "pointer_type" ,
137+ "array_type" ,
138+ "slice_type" ,
139+ "map_type" ,
140+ "channel_type" ,
141+ "qualified_type" ,
142+ "struct_type" ,
143+ "interface_type" ,
144+ ]:
117145 field_type = self .extract_node_text (child , source_code )
118146
119147 if field_name :
0 commit comments