mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-20 07:19:40 +08:00
Moved keyword completion around to get it working in all cases.
This commit is contained in:
+10
-10
@@ -131,6 +131,8 @@ class Script(object):
|
|||||||
:rtype: list of :class:`classes.Completion`
|
:rtype: list of :class:`classes.Completion`
|
||||||
"""
|
"""
|
||||||
def get_completions(user_stmt, bs):
|
def get_completions(user_stmt, bs):
|
||||||
|
# TODO this closure is ugly. it also doesn't work with
|
||||||
|
# simple_complete (used for Interpreter), somehow redo.
|
||||||
module = self._parser.module()
|
module = self._parser.module()
|
||||||
names, level, only_modules = helpers.check_error_statements(module, self._pos)
|
names, level, only_modules = helpers.check_error_statements(module, self._pos)
|
||||||
completions = []
|
completions = []
|
||||||
@@ -154,10 +156,14 @@ class Script(object):
|
|||||||
imp = imports.ImportWrapper(self._evaluator, name)
|
imp = imports.ImportWrapper(self._evaluator, name)
|
||||||
completions += [(n, module) for n in imp.completion_names()]
|
completions += [(n, module) for n in imp.completion_names()]
|
||||||
|
|
||||||
if names or isinstance(user_stmt, pr.Import):
|
if not names and not isinstance(user_stmt, pr.Import):
|
||||||
return completions
|
if not path and not dot:
|
||||||
return self._simple_complete(path, dot, like)
|
# add keywords
|
||||||
|
completions += ((k, b) for k in keywords.keyword_names(all=True))
|
||||||
|
# TODO delete? We should search for valid parser
|
||||||
|
# transformations.
|
||||||
|
completions += self._simple_complete(path, dot, like)
|
||||||
|
return completions
|
||||||
|
|
||||||
debug.speed('completions start')
|
debug.speed('completions start')
|
||||||
path = self._user_context.get_path_until_cursor()
|
path = self._user_context.get_path_until_cursor()
|
||||||
@@ -186,12 +192,6 @@ class Script(object):
|
|||||||
if p._definition.stars == 0: # no *args/**kwargs
|
if p._definition.stars == 0: # no *args/**kwargs
|
||||||
completions.append((p._name, p._name))
|
completions.append((p._name, p._name))
|
||||||
|
|
||||||
if not path and not isinstance(user_stmt, pr.Import):
|
|
||||||
# add keywords
|
|
||||||
completions += ((k, b) for k in keywords.keyword_names(all=True))
|
|
||||||
# TODO delete? We should search for valid parser
|
|
||||||
# transformations.
|
|
||||||
|
|
||||||
needs_dot = not dot and path
|
needs_dot = not dot and path
|
||||||
|
|
||||||
comps = []
|
comps = []
|
||||||
|
|||||||
Reference in New Issue
Block a user