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, parent)
| 172 | |
| 173 | |
| 174 | def make_local_variables(tree, parent): |
| 175 | """ |
| 176 | Given an ast of all the lines in a function, generate a list of |
| 177 | variables in that function. Variables are tokens and what they link to. |
| 178 | In this case, what it links to is just a string. However, that is resolved |
| 179 | later. |
| 180 | |
| 181 | Also return variables for the outer scope parent |
| 182 | |
| 183 | :param tree list|dict: |
| 184 | :param parent Group: |
| 185 | :rtype: list[Variable] |
| 186 | """ |
| 187 | if not tree: |
| 188 | return [] |
| 189 | |
| 190 | variables = [] |
| 191 | for element in walk(tree): |
| 192 | if element['type'] == 'VariableDeclaration': |
| 193 | variables += process_assign(element) |
| 194 | |
| 195 | # Make a 'this' variable for use anywhere we need it that points to the class |
| 196 | if isinstance(parent, Group) and parent.group_type == GROUP_TYPE.CLASS: |
| 197 | variables.append(Variable('this', parent, lineno(tree))) |
| 198 | |
| 199 | variables = list(filter(None, variables)) |
| 200 | return variables |
| 201 | |
| 202 | |
| 203 | def children(tree): |
no test coverage detected