##// END OF EJS Templates
Switch `CompletionContext` to `dataclass`, use `cached_property`...
krassowski -
Show More
@@ -191,7 +191,8 b' import unicodedata'
191 191 import uuid
192 192 import warnings
193 193 from contextlib import contextmanager
194 from functools import lru_cache, partial
194 from dataclasses import dataclass
195 from functools import cached_property, partial
195 196 from importlib import import_module
196 197 from types import SimpleNamespace
197 198 from typing import (
@@ -597,7 +598,8 b' class _JediMatcherResult(_MatcherResultBase):'
597 598 completions: Iterable[_JediCompletionLike]
598 599
599 600
600 class CompletionContext(NamedTuple):
601 @dataclass
602 class CompletionContext:
601 603 """Completion context provided as an argument to matchers in the Matcher API v2."""
602 604
603 605 # rationale: many legacy matchers relied on completer state (`self.text_until_cursor`)
@@ -626,13 +628,11 b' class CompletionContext(NamedTuple):'
626 628 # If not given, return all possible completions.
627 629 limit: Optional[int]
628 630
629 @property
630 @lru_cache(maxsize=None) # TODO change to @cache after dropping Python 3.7
631 @cached_property
631 632 def text_until_cursor(self) -> str:
632 633 return self.line_with_cursor[: self.cursor_position]
633 634
634 @property
635 @lru_cache(maxsize=None) # TODO change to @cache after dropping Python 3.7
635 @cached_property
636 636 def line_with_cursor(self) -> str:
637 637 return self.full_text.split("\n")[self.cursor_line]
638 638
General Comments 0
You need to be logged in to leave comments. Login now