(
self, document: Document, complete_event: CompleteEvent
)
| 399 | return None # Many exception, like NameError can be thrown here. |
| 400 | |
| 401 | def get_completions( |
| 402 | self, document: Document, complete_event: CompleteEvent |
| 403 | ) -> Iterable[Completion]: |
| 404 | # First, find all for-loops, and assign the first item of the |
| 405 | # collections they're iterating to the iterator variable, so that we |
| 406 | # can provide code completion on the iterators. |
| 407 | temp_locals = self.get_locals().copy() |
| 408 | |
| 409 | for match in self.for_loop_pattern.finditer(document.text_before_cursor): |
| 410 | varname, expression = match.groups() |
| 411 | expression_val = self._lookup(expression, temp_locals) |
| 412 | |
| 413 | # We do this only for lists and tuples. Calling `next()` on any |
| 414 | # collection would create undesired side effects. |
| 415 | if isinstance(expression_val, (list, tuple)) and expression_val: |
| 416 | temp_locals[varname] = expression_val[0] |
| 417 | |
| 418 | # Get all completions. |
| 419 | yield from self._get_expression_completions( |
| 420 | document, complete_event, temp_locals |
| 421 | ) |
| 422 | yield from self._get_item_lookup_completions( |
| 423 | document, complete_event, temp_locals |
| 424 | ) |
| 425 | yield from self._get_attribute_completions( |
| 426 | document, complete_event, temp_locals |
| 427 | ) |
| 428 | |
| 429 | def _do_repr(self, obj: object) -> str: |
| 430 | try: |
nothing calls this directly
no test coverage detected