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

Method make_nodes

code2flow/ruby.py:254–282  ·  view source on GitHub ↗

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

(tree, parent)

Source from the content-addressed store, hash-verified

252
253 @staticmethod
254 def make_nodes(tree, parent):
255 """
256 Given a tree element of all the lines in a function, create the node along
257 with the calls and variables internal to it.
258 Also make the nested subnodes
259
260 :param tree ast:
261 :param parent Group:
262 :rtype: list[Node]
263 """
264 if tree[0] == 'defs':
265 token = tree[2] # def self.func
266 else:
267 token = tree[1] # def func
268
269 is_constructor = token == 'initialize' and parent.group_type == GROUP_TYPE.CLASS
270
271 tree_body = get_tree_body(tree)
272 subgroup_trees, subnode_trees, this_scope_body = Ruby.separate_namespaces(tree_body)
273 assert not subgroup_trees
274 calls = make_calls(this_scope_body)
275 variables = make_local_variables(this_scope_body, parent)
276 node = Node(token, calls, variables,
277 parent=parent, is_constructor=is_constructor)
278
279 # This is a little different from the other languages in that
280 # the node is now on the parent
281 subnodes = flatten([Ruby.make_nodes(t, parent) for t in subnode_trees])
282 return [node] + subnodes
283
284 @staticmethod
285 def make_root_node(lines, parent):

Callers 1

make_class_groupMethod · 0.45

Calls 6

get_tree_bodyFunction · 0.85
NodeClass · 0.85
flattenFunction · 0.85
make_callsFunction · 0.70
make_local_variablesFunction · 0.70
separate_namespacesMethod · 0.45

Tested by

no test coverage detected