Given a tree element, recursively separate that AST into lists of ASTs for the subgroups, nodes, and body. This is an intermediate step to allow for cleaner processing downstream :param tree ast: :returns: tuple of group, node, and body trees. These are proc
(tree)
| 265 | |
| 266 | @staticmethod |
| 267 | def separate_namespaces(tree): |
| 268 | """ |
| 269 | Given a tree element, recursively separate that AST into lists of ASTs for the |
| 270 | subgroups, nodes, and body. This is an intermediate step to allow for |
| 271 | cleaner processing downstream |
| 272 | |
| 273 | :param tree ast: |
| 274 | :returns: tuple of group, node, and body trees. These are processed |
| 275 | downstream into real Groups and Nodes. |
| 276 | :rtype: (list[ast], list[ast], list[ast]) |
| 277 | """ |
| 278 | tree = tree or [] # if its abstract, it comes in with no body |
| 279 | |
| 280 | groups = [] |
| 281 | nodes = [] |
| 282 | body = [] |
| 283 | for el in tree: |
| 284 | if el['nodeType'] in ('Stmt_Function', 'Stmt_ClassMethod', 'Expr_Closure'): |
| 285 | nodes.append(el) |
| 286 | elif el['nodeType'] in ('Stmt_Class', 'Stmt_Namespace', 'Stmt_Trait'): |
| 287 | groups.append(el) |
| 288 | else: |
| 289 | tup = PHP.separate_namespaces(children(el)) |
| 290 | if tup[0] or tup[1]: |
| 291 | groups += tup[0] |
| 292 | nodes += tup[1] |
| 293 | body += tup[2] |
| 294 | else: |
| 295 | body.append(el) |
| 296 | return groups, nodes, body |
| 297 | |
| 298 | @staticmethod |
| 299 | def make_nodes(tree, parent): |
no test coverage detected