Given an ast tree walk it to get every node. For PHP, the exception is that we return Expr_BinaryOp_Concat which has internal nodes but is important to process as a whole. :param tree_el ast: :rtype: list[ast]
(tree)
| 79 | |
| 80 | |
| 81 | def walk(tree): |
| 82 | """ |
| 83 | Given an ast tree walk it to get every node. For PHP, the exception |
| 84 | is that we return Expr_BinaryOp_Concat which has internal nodes but |
| 85 | is important to process as a whole. |
| 86 | |
| 87 | :param tree_el ast: |
| 88 | :rtype: list[ast] |
| 89 | """ |
| 90 | |
| 91 | if isinstance(tree, list): |
| 92 | ret = [] |
| 93 | for el in tree: |
| 94 | if isinstance(el, dict) and el.get('nodeType'): |
| 95 | ret += walk(el) |
| 96 | return ret |
| 97 | |
| 98 | assert isinstance(tree, dict) |
| 99 | assert tree['nodeType'] |
| 100 | ret = [tree] |
| 101 | |
| 102 | if tree['nodeType'] == 'Expr_BinaryOp_Concat': |
| 103 | return ret |
| 104 | |
| 105 | for v in tree.values(): |
| 106 | if isinstance(v, list) or (isinstance(v, dict) and v.get('nodeType')): |
| 107 | ret += walk(v) |
| 108 | return ret |
| 109 | |
| 110 | |
| 111 | def children(tree): |
no outgoing calls
no test coverage detected