forked from VimPlug/jedi
Refactor the completion module.
This commit is contained in:
@@ -21,8 +21,7 @@ class Completion:
|
|||||||
self._pos = position
|
self._pos = position
|
||||||
self._call_signatures_method = call_signatures_method
|
self._call_signatures_method = call_signatures_method
|
||||||
|
|
||||||
def completions(self):
|
def get_completions(self, user_stmt, path, dot, like):
|
||||||
def get_completions(user_stmt, bs):
|
|
||||||
# TODO this closure is ugly. it also doesn't work with
|
# TODO this closure is ugly. it also doesn't work with
|
||||||
# simple_complete (used for Interpreter), somehow redo.
|
# simple_complete (used for Interpreter), somehow redo.
|
||||||
module = self._evaluator.wrap(self._parser.module())
|
module = self._evaluator.wrap(self._parser.module())
|
||||||
@@ -63,6 +62,7 @@ class Completion:
|
|||||||
completion_names += self._simple_complete(path, dot, like)
|
completion_names += self._simple_complete(path, dot, like)
|
||||||
return completion_names
|
return completion_names
|
||||||
|
|
||||||
|
def completions(self):
|
||||||
debug.speed('completions start')
|
debug.speed('completions start')
|
||||||
path = self._user_context.get_path_until_cursor()
|
path = self._user_context.get_path_until_cursor()
|
||||||
# Dots following an int are not the start of a completion but a float
|
# Dots following an int are not the start of a completion but a float
|
||||||
@@ -73,7 +73,7 @@ class Completion:
|
|||||||
|
|
||||||
user_stmt = self._parser.user_stmt_with_whitespace()
|
user_stmt = self._parser.user_stmt_with_whitespace()
|
||||||
|
|
||||||
completion_names = get_completions(user_stmt, self._evaluator.BUILTINS)
|
completion_names = self.get_completions(user_stmt, path, dot, like)
|
||||||
|
|
||||||
if not dot:
|
if not dot:
|
||||||
# add named params
|
# add named params
|
||||||
@@ -131,7 +131,9 @@ class Completion:
|
|||||||
names = list(chain.from_iterable(names_dict.values()))
|
names = list(chain.from_iterable(names_dict.values()))
|
||||||
if not names:
|
if not names:
|
||||||
continue
|
continue
|
||||||
completion_names += filter_definition_names(names, self._parser.user_stmt(), pos)
|
completion_names += filter_definition_names(
|
||||||
|
names, self._parser.user_stmt(), pos
|
||||||
|
)
|
||||||
elif inference.get_under_cursor_stmt(self._evaluator, self._parser,
|
elif inference.get_under_cursor_stmt(self._evaluator, self._parser,
|
||||||
path, self._pos) is None:
|
path, self._pos) is None:
|
||||||
return []
|
return []
|
||||||
@@ -147,5 +149,7 @@ class Completion:
|
|||||||
for names_dict in s.names_dicts(search_global=False):
|
for names_dict in s.names_dicts(search_global=False):
|
||||||
names += chain.from_iterable(names_dict.values())
|
names += chain.from_iterable(names_dict.values())
|
||||||
|
|
||||||
completion_names += filter_definition_names(names, self._parser.user_stmt())
|
completion_names += filter_definition_names(
|
||||||
|
names, self._parser.user_stmt()
|
||||||
|
)
|
||||||
return completion_names
|
return completion_names
|
||||||
|
|||||||
Reference in New Issue
Block a user