@@ -105,15 +105,13 @@ def get_class_list(node):
105
105
return res
106
106
107
107
@staticmethod
108
- def get_function_metadata (function_node , blob : str = None ) -> Dict [str , Any ]:
108
+ def get_function_metadata (function_node , blob : str = None ) -> Dict [str , Any ]:
109
109
"""
110
110
Function metadata contains:
111
111
- identifier (str): function name
112
112
- parameters (Dict[str, str]): parameter's name and their type (e.g: {'param_a': 'int'})
113
113
- type (str): type
114
114
"""
115
- if blob :
116
- logger .info ('From version `0.0.6` this function will update argument in the API' )
117
115
metadata = {
118
116
'identifier' : '' ,
119
117
'parameters' : {},
@@ -122,10 +120,13 @@ def get_function_metadata(function_node, blob: str=None) -> Dict[str, Any]:
122
120
assert type (function_node ) == tree_sitter .Node
123
121
124
122
for child in function_node .children :
125
- if child .type == 'predefined_type' :
123
+ if child .type in [ 'predefined_type' , 'generic_name' ] :
126
124
metadata ['return_type' ] = get_node_text (child )
127
125
elif child .type == 'identifier' :
128
- metadata ['identifier' ] = get_node_text (child )
126
+ if child .next_named_sibling .type != 'parameter_list' :
127
+ metadata ['return_type' ] = get_node_text (child )
128
+ else :
129
+ metadata ['identifier' ] = get_node_text (child )
129
130
elif child .type == 'parameter_list' :
130
131
for param_node in child .children :
131
132
param_nodes = get_node_by_kind (param_node , ['parameter' ])
0 commit comments