mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
keyword completion shouldn't occur all the times; thanks to Tobias Halter for his brilliant Kantischueler logic.
This commit is contained in:
13
jedi/api.py
13
jedi/api.py
@@ -185,8 +185,9 @@ class Script(object):
|
|||||||
path, dot, like = self._get_completion_parts(path)
|
path, dot, like = self._get_completion_parts(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
scopes = self._prepare_goto(path, True)
|
scopes = list(self._prepare_goto(path, True))
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
|
scopes = []
|
||||||
scope_generator = evaluate.get_names_for_scope(
|
scope_generator = evaluate.get_names_for_scope(
|
||||||
self.parser.user_scope, self.pos)
|
self.parser.user_scope, self.pos)
|
||||||
completions = []
|
completions = []
|
||||||
@@ -214,9 +215,13 @@ class Script(object):
|
|||||||
for p in call_def.params:
|
for p in call_def.params:
|
||||||
completions.append((p.get_name(), p))
|
completions.append((p.get_name(), p))
|
||||||
|
|
||||||
# add keywords
|
# Do the completion if there is no path before and no import stmt.
|
||||||
s = builtin.builtin_scope
|
if (not scopes or not isinstance(scopes[0], imports.ImportPath)) \
|
||||||
completions += ((k, s) for k in keywords.get_keywords(all=True))
|
and not path:
|
||||||
|
# add keywords
|
||||||
|
bs = builtin.builtin_scope
|
||||||
|
completions += ((k, bs) for k in keywords.get_keywords(
|
||||||
|
all=True))
|
||||||
|
|
||||||
completions = [(c, s) for c, s in completions
|
completions = [(c, s) for c, s in completions
|
||||||
if settings.case_insensitive_completion
|
if settings.case_insensitive_completion
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class TestClass(object):
|
|||||||
# should not know any class functions!
|
# should not know any class functions!
|
||||||
#? []
|
#? []
|
||||||
values
|
values
|
||||||
#? []
|
#? ['return']
|
||||||
ret
|
ret
|
||||||
return a1
|
return a1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user