MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / make_nodes

Method make_nodes

code2flow/python.py:194–216  ·  view source on GitHub ↗

Given an ast of all the lines in a function, create the node along with the calls and variables internal to it. :param tree ast: :param parent Group: :rtype: list[Node]

(tree, parent)

Source from the content-addressed store, hash-verified

192
193 @staticmethod
194 def make_nodes(tree, parent):
195 """
196 Given an ast of all the lines in a function, create the node along with the
197 calls and variables internal to it.
198
199 :param tree ast:
200 :param parent Group:
201 :rtype: list[Node]
202 """
203 token = tree.name
204 line_number = tree.lineno
205 calls = make_calls(tree.body)
206 variables = make_local_variables(tree.body, parent)
207 is_constructor = False
208 if parent.group_type == GROUP_TYPE.CLASS and token in ['__init__', '__new__']:
209 is_constructor = True
210
211 import_tokens = []
212 if parent.group_type == GROUP_TYPE.FILE:
213 import_tokens = [djoin(parent.token, token)]
214
215 return [Node(token, calls, variables, parent, import_tokens=import_tokens,
216 line_number=line_number, is_constructor=is_constructor)]
217
218 @staticmethod
219 def make_root_node(lines, parent):

Callers 1

make_class_groupMethod · 0.45

Calls 4

djoinFunction · 0.85
NodeClass · 0.85
make_callsFunction · 0.70
make_local_variablesFunction · 0.70

Tested by

no test coverage detected