Find completions for the given text and line context. Note that both the text and the line_buffer are optional, but at least one of them must be given. Parameters ---------- text : string, optional Text to perform the completion on. If not given
(
self, text=None, line_buffer=None, cursor_pos=None
)
| 3480 | ] |
| 3481 | |
| 3482 | def complete( |
| 3483 | self, text=None, line_buffer=None, cursor_pos=None |
| 3484 | ) -> tuple[str, Sequence[str]]: |
| 3485 | """Find completions for the given text and line context. |
| 3486 | |
| 3487 | Note that both the text and the line_buffer are optional, but at least |
| 3488 | one of them must be given. |
| 3489 | |
| 3490 | Parameters |
| 3491 | ---------- |
| 3492 | text : string, optional |
| 3493 | Text to perform the completion on. If not given, the line buffer |
| 3494 | is split using the instance's CompletionSplitter object. |
| 3495 | line_buffer : string, optional |
| 3496 | If not given, the completer attempts to obtain the current line |
| 3497 | buffer via readline. This keyword allows clients which are |
| 3498 | requesting for text completions in non-readline contexts to inform |
| 3499 | the completer of the entire text. |
| 3500 | cursor_pos : int, optional |
| 3501 | Index of the cursor in the full line buffer. Should be provided by |
| 3502 | remote frontends where kernel has no access to frontend state. |
| 3503 | |
| 3504 | Returns |
| 3505 | ------- |
| 3506 | Tuple of two items: |
| 3507 | text : str |
| 3508 | Text that was actually used in the completion. |
| 3509 | matches : list |
| 3510 | A list of completion matches. |
| 3511 | |
| 3512 | Notes |
| 3513 | ----- |
| 3514 | This API is likely to be deprecated and replaced by |
| 3515 | :any:`IPCompleter.completions` in the future. |
| 3516 | |
| 3517 | """ |
| 3518 | warnings.warn('`Completer.complete` is pending deprecation since ' |
| 3519 | 'IPython 6.0 and will be replaced by `Completer.completions`.', |
| 3520 | PendingDeprecationWarning) |
| 3521 | # potential todo, FOLD the 3rd throw away argument of _complete |
| 3522 | # into the first 2 one. |
| 3523 | # TODO: Q: does the above refer to jedi completions (i.e. 0-indexed?) |
| 3524 | # TODO: should we deprecate now, or does it stay? |
| 3525 | |
| 3526 | results = self._complete( |
| 3527 | line_buffer=line_buffer, cursor_pos=cursor_pos, text=text, cursor_line=0 |
| 3528 | ) |
| 3529 | |
| 3530 | jedi_matcher_id = _get_matcher_id(self._jedi_matcher) |
| 3531 | |
| 3532 | return self._arrange_and_extract( |
| 3533 | results, |
| 3534 | # TODO: can we confirm that excluding Jedi here was a deliberate choice in previous version? |
| 3535 | skip_matchers={jedi_matcher_id}, |
| 3536 | # this API does not support different start/end positions (fragments of token). |
| 3537 | abort_if_offset_changes=True, |
| 3538 | ) |
| 3539 |
no test coverage detected