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)
| 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): |
nothing calls this directly
no test coverage detected