mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-12 23:21:41 +08:00
Don't use UserContextParser.user_stmt anymore, since we can access it directly.
This commit is contained in:
@@ -172,7 +172,7 @@ class Completion:
|
||||
if not names:
|
||||
continue
|
||||
completion_names += filter_definition_names(
|
||||
names, self._parser.user_stmt(), pos
|
||||
names, self._module.get_statement_for_position(self._position), pos
|
||||
)
|
||||
return completion_names
|
||||
|
||||
@@ -186,7 +186,7 @@ class Completion:
|
||||
names += chain.from_iterable(names_dict.values())
|
||||
|
||||
completion_names += filter_definition_names(
|
||||
names, self._parser.user_stmt()
|
||||
names, self._module.get_statement_for_position(self._position)
|
||||
)
|
||||
return completion_names
|
||||
|
||||
|
||||
@@ -12,16 +12,6 @@ from jedi.parser import tokenize, token
|
||||
CompletionParts = namedtuple('CompletionParts', ['path', 'has_dot', 'name'])
|
||||
|
||||
|
||||
def get_completion_parts(path_until_cursor):
|
||||
"""
|
||||
Returns the parts for the completion
|
||||
:return: tuple - (path, dot, like)
|
||||
"""
|
||||
match = re.match(r'^(.*?)(\.|)(\w?[\w\d]*)$', path_until_cursor, flags=re.S)
|
||||
path, dot, name = match.groups()
|
||||
return CompletionParts(path, bool(dot), name)
|
||||
|
||||
|
||||
def sorted_definitions(defs):
|
||||
# Note: `or ''` below is required because `module_path` could be
|
||||
return sorted(defs, key=lambda x: (x.module_path or '', x.line or 0, x.column or 0))
|
||||
|
||||
Reference in New Issue
Block a user