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

Method make_class_group

code2flow/ruby.py:301–335  ·  view source on GitHub ↗

Given an AST for the subgroup (a class), generate that subgroup. In this function, we will also need to generate all of the nodes internal to the group. :param tree ast: :param parent Group: :rtype: Group

(tree, parent)

Source from the content-addressed store, hash-verified

299
300 @staticmethod
301 def make_class_group(tree, parent):
302 """
303 Given an AST for the subgroup (a class), generate that subgroup.
304 In this function, we will also need to generate all of the nodes internal
305 to the group.
306
307 :param tree ast:
308 :param parent Group:
309 :rtype: Group
310 """
311 assert tree[0] in ('class', 'module')
312 tree_body = get_tree_body(tree)
313 subgroup_trees, node_trees, body_trees = Ruby.separate_namespaces(tree_body)
314
315 group_type = GROUP_TYPE.CLASS
316 if tree[0] == 'module':
317 group_type = GROUP_TYPE.NAMESPACE
318 display_type = tree[0].capitalize()
319 assert tree[1][0] == 'const'
320 token = tree[1][2]
321
322 inherits = get_inherits(tree, body_trees)
323 class_group = Group(token, group_type, display_type,
324 inherits=inherits, parent=parent)
325
326 for subgroup_tree in subgroup_trees:
327 class_group.add_subgroup(Ruby.make_class_group(subgroup_tree, class_group))
328
329 for node_tree in node_trees:
330 for new_node in Ruby.make_nodes(node_tree, parent=class_group):
331 class_group.add_node(new_node)
332 for node in class_group.nodes:
333 node.variables += [Variable(n.token, n) for n in class_group.nodes]
334
335 return class_group
336
337 @staticmethod
338 def file_import_tokens(filename):

Callers

nothing calls this directly

Calls 8

add_subgroupMethod · 0.95
add_nodeMethod · 0.95
get_tree_bodyFunction · 0.85
GroupClass · 0.85
VariableClass · 0.85
get_inheritsFunction · 0.70
separate_namespacesMethod · 0.45
make_nodesMethod · 0.45

Tested by

no test coverage detected