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)
| 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): |
no test coverage detected