Refactor the completion module.
This commit is contained in:
1 parent
cfa65a22fa
commit
323581e253
1 file changed
+9
-5
@@ -21,8 +21,7 @@ class Completion:
|
||||
self._pos = position
|
||||
self._call_signatures_method = call_signatures_method
|
||||
|
||||
def completions(self):
|
||||
def get_completions(user_stmt, bs):
|
||||
def get_completions(self, user_stmt, path, dot, like):
|
||||
# TODO this closure is ugly. it also doesn't work with
|
||||
# simple_complete (used for Interpreter), somehow redo.
|
||||
module = self._evaluator.wrap(self._parser.module())
|
||||
@@ -63,6 +62,7 @@ class Completion:
|
||||
completion_names += self._simple_complete(path, dot, like)
|
||||
return completion_names
|
||||
|
||||
def completions(self):
|
||||
debug.speed('completions start')
|
||||
path = self._user_context.get_path_until_cursor()
|
||||
# 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()
|
||||
|
||||
completion_names = get_completions(user_stmt, self._evaluator.BUILTINS)
|
||||
completion_names = self.get_completions(user_stmt, path, dot, like)
|
||||
|
||||
if not dot:
|
||||
# add named params
|
||||
@@ -131,7 +131,9 @@ class Completion:
|
||||
names = list(chain.from_iterable(names_dict.values()))
|
||||
if not names:
|
||||
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,
|
||||
path, self._pos) is None:
|
||||
return []
|
||||
@@ -147,5 +149,7 @@ class Completion:
|
||||
for names_dict in s.names_dicts(search_global=False):
|
||||
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
|
||||
Reference in new issue
Block a user