Returns the token that is on position offset.
(self, offset)
| 196 | token._pprint_tree(max_depth, depth + 1, f, _pre + parent_pre) |
| 197 | |
| 198 | def get_token_at_offset(self, offset): |
| 199 | """Returns the token that is on position offset.""" |
| 200 | idx = 0 |
| 201 | for token in self.flatten(): |
| 202 | end = idx + len(token.value) |
| 203 | if idx <= offset < end: |
| 204 | return token |
| 205 | idx = end |
| 206 | |
| 207 | def flatten(self): |
| 208 | """Generator yielding ungrouped tokens. |