MCPcopy Index your code
hub / github.com/andialbrecht/sqlparse / get_token_at_offset

Method get_token_at_offset

sqlparse/sql.py:198–205  ·  view source on GitHub ↗

Returns the token that is on position offset.

(self, offset)

Source from the content-addressed store, hash-verified

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.

Callers 1

test_get_token_at_offsetFunction · 0.80

Calls 1

flattenMethod · 0.95

Tested by 1

test_get_token_at_offsetFunction · 0.64