Return a list of :any:`jedi.api.Completion`\\s object from a ``text`` and cursor position. Parameters ---------- cursor_column : int column position of the cursor in ``text``, 0-indexed. cursor_line : int line position of the
(
self, cursor_column: int, cursor_line: int, text: str
)
| 2497 | } |
| 2498 | |
| 2499 | def _jedi_matches( |
| 2500 | self, cursor_column: int, cursor_line: int, text: str |
| 2501 | ) -> Iterator[_JediCompletionLike]: |
| 2502 | """ |
| 2503 | Return a list of :any:`jedi.api.Completion`\\s object from a ``text`` and |
| 2504 | cursor position. |
| 2505 | |
| 2506 | Parameters |
| 2507 | ---------- |
| 2508 | cursor_column : int |
| 2509 | column position of the cursor in ``text``, 0-indexed. |
| 2510 | cursor_line : int |
| 2511 | line position of the cursor in ``text``, 0-indexed |
| 2512 | text : str |
| 2513 | text to complete |
| 2514 | |
| 2515 | Notes |
| 2516 | ----- |
| 2517 | If ``IPCompleter.debug`` is ``True`` may return a :any:`_FakeJediCompletion` |
| 2518 | object containing a string with the Jedi debug information attached. |
| 2519 | |
| 2520 | .. deprecated:: 8.6 |
| 2521 | You can use :meth:`_jedi_matcher` instead. |
| 2522 | """ |
| 2523 | namespaces = [self.namespace] |
| 2524 | if self.global_namespace is not None: |
| 2525 | namespaces.append(self.global_namespace) |
| 2526 | |
| 2527 | completion_filter = lambda x:x |
| 2528 | offset = cursor_to_position(text, cursor_line, cursor_column) |
| 2529 | # filter output if we are completing for object members |
| 2530 | if offset: |
| 2531 | pre = text[offset-1] |
| 2532 | if pre == '.': |
| 2533 | if self.omit__names == 2: |
| 2534 | completion_filter = lambda c:not c.name.startswith('_') |
| 2535 | elif self.omit__names == 1: |
| 2536 | completion_filter = lambda c:not (c.name.startswith('__') and c.name.endswith('__')) |
| 2537 | elif self.omit__names == 0: |
| 2538 | completion_filter = lambda x:x |
| 2539 | else: |
| 2540 | raise ValueError("Don't understand self.omit__names == {}".format(self.omit__names)) |
| 2541 | |
| 2542 | interpreter = jedi.Interpreter(text[:offset], namespaces) |
| 2543 | try_jedi = True |
| 2544 | |
| 2545 | try: |
| 2546 | # find the first token in the current tree -- if it is a ' or " then we are in a string |
| 2547 | completing_string = False |
| 2548 | try: |
| 2549 | first_child = next(c for c in interpreter._get_module().tree_node.children if hasattr(c, 'value')) |
| 2550 | except StopIteration: |
| 2551 | pass |
| 2552 | else: |
| 2553 | # note the value may be ', ", or it may also be ''' or """, or |
| 2554 | # in some cases, """what/you/typed..., but all of these are |
| 2555 | # strings. |
| 2556 | completing_string = len(first_child.value) > 0 and first_child.value[0] in {"'", '"'} |
no test coverage detected