Given an ast of all the lines in a function, generate a list of variables in that function. Variables are tokens and what they link to. In this case, what it links to is just a string. However, that is resolved later. Also return variables for the outer scope parent :param
(tree_el, parent)
| 106 | |
| 107 | |
| 108 | def make_local_variables(tree_el, parent): |
| 109 | """ |
| 110 | Given an ast of all the lines in a function, generate a list of |
| 111 | variables in that function. Variables are tokens and what they link to. |
| 112 | In this case, what it links to is just a string. However, that is resolved |
| 113 | later. |
| 114 | |
| 115 | Also return variables for the outer scope parent |
| 116 | |
| 117 | :param tree_el ast: |
| 118 | :param parent Group: |
| 119 | :rtype: list[Variable] |
| 120 | """ |
| 121 | variables = [] |
| 122 | for el in tree_el: |
| 123 | if el[0] == 'lvasgn': |
| 124 | variables.append(process_assign(el)) |
| 125 | |
| 126 | # Make a 'self' variable for use anywhere we need it that points to the class |
| 127 | if isinstance(parent, Group) and parent.group_type == GROUP_TYPE.CLASS: |
| 128 | variables.append(Variable('self', parent)) |
| 129 | |
| 130 | variables = list(filter(None, variables)) |
| 131 | return variables |
| 132 | |
| 133 | |
| 134 | def as_lines(tree_el): |
no test coverage detected