MCPcopy Index your code
hub / github.com/ipython/ipython / _complete

Method _complete

IPython/core/completer.py:3573–3735  ·  view source on GitHub ↗

Like complete but can also returns raw jedi completions as well as the origin of the completion text. This could (and should) be made much cleaner but that will be simpler once we drop the old (and stateful) :any:`complete` API. With current provisional API,

(self, *, cursor_line, cursor_pos, line_buffer=None, text=None,
                  full_text=None)

Source from the content-addressed store, hash-verified

3571 ]
3572
3573 def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None,
3574 full_text=None) -> _CompleteResult:
3575 """
3576 Like complete but can also returns raw jedi completions as well as the
3577 origin of the completion text. This could (and should) be made much
3578 cleaner but that will be simpler once we drop the old (and stateful)
3579 :any:`complete` API.
3580
3581 With current provisional API, cursor_pos act both (depending on the
3582 caller) as the offset in the ``text`` or ``line_buffer``, or as the
3583 ``column`` when passing multiline strings this could/should be renamed
3584 but would add extra noise.
3585
3586 Parameters
3587 ----------
3588 cursor_line
3589 Index of the line the cursor is on. 0 indexed.
3590 cursor_pos
3591 Position of the cursor in the current line/line_buffer/text. 0
3592 indexed.
3593 line_buffer : optional, str
3594 The current line the cursor is in, this is mostly due to legacy
3595 reason that readline could only give a us the single current line.
3596 Prefer `full_text`.
3597 text : str
3598 The current "token" the cursor is in, mostly also for historical
3599 reasons. as the completer would trigger only after the current line
3600 was parsed.
3601 full_text : str
3602 Full text of the current cell.
3603
3604 Returns
3605 -------
3606 An ordered dictionary where keys are identifiers of completion
3607 matchers and values are ``MatcherResult``s.
3608 """
3609
3610 # if the cursor position isn't given, the only sane assumption we can
3611 # make is that it's at the end of the line (the common case)
3612 if cursor_pos is None:
3613 cursor_pos = len(line_buffer) if text is None else len(text)
3614
3615 if self.use_main_ns:
3616 self.namespace = __main__.__dict__
3617
3618 # if text is either None or an empty string, rely on the line buffer
3619 if (not line_buffer) and full_text:
3620 line_buffer = full_text.split('\n')[cursor_line]
3621 if not text: # issue #11508: check line_buffer before calling split_line
3622 text = (
3623 self.splitter.split_line(line_buffer, cursor_pos) if line_buffer else ""
3624 )
3625
3626 # If no line buffer is given, assume the input text is all there was
3627 if line_buffer is None:
3628 line_buffer = text
3629
3630 # deprecated - do not use `line_buffer` in new code.

Callers 3

_completionsMethod · 0.95
completeMethod · 0.95
_Method · 0.80

Calls 13

_extract_codeMethod · 0.95
_arrange_and_extractMethod · 0.95
CompletionContextClass · 0.85
_get_matcher_idFunction · 0.85
_is_matcher_v1Function · 0.85
_is_matcher_v2Function · 0.85
_get_matcher_api_versionFunction · 0.85
has_any_completionsFunction · 0.85
split_lineMethod · 0.80
warnMethod · 0.80
getMethod · 0.80

Tested by 1

_Method · 0.64