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

Method make_class_group

code2flow/javascript.py:379–405  ·  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

377
378 @staticmethod
379 def make_class_group(tree, parent):
380 """
381 Given an AST for the subgroup (a class), generate that subgroup.
382 In this function, we will also need to generate all of the nodes internal
383 to the group.
384
385 :param tree ast:
386 :param parent Group:
387 :rtype: Group
388 """
389 assert tree['type'] == 'ClassDeclaration'
390 subgroup_trees, node_trees, body_trees = Javascript.separate_namespaces(tree)
391 assert not subgroup_trees
392
393 group_type = GROUP_TYPE.CLASS
394 token = tree['id']['name']
395 display_name = 'Class'
396 line_number = lineno(tree)
397 inherits = get_inherits(tree)
398 class_group = Group(token, group_type, display_name,
399 inherits=inherits, line_number=line_number, parent=parent)
400
401 for node_tree in node_trees:
402 for new_node in Javascript.make_nodes(node_tree, parent=class_group):
403 class_group.add_node(new_node)
404
405 return class_group
406
407 @staticmethod
408 def file_import_tokens(filename):

Callers

nothing calls this directly

Calls 6

add_nodeMethod · 0.95
GroupClass · 0.85
linenoFunction · 0.70
get_inheritsFunction · 0.70
separate_namespacesMethod · 0.45
make_nodesMethod · 0.45

Tested by

no test coverage detected