forked from VimPlug/jedi
python keyword completion, fixes #21
This commit is contained in:
16
jedi/api.py
16
jedi/api.py
@@ -12,6 +12,7 @@ import debug
|
|||||||
import settings
|
import settings
|
||||||
import keywords
|
import keywords
|
||||||
import helpers
|
import helpers
|
||||||
|
import builtin
|
||||||
|
|
||||||
from _compatibility import next
|
from _compatibility import next
|
||||||
|
|
||||||
@@ -206,18 +207,21 @@ class Script(object):
|
|||||||
for c in names:
|
for c in names:
|
||||||
completions.append((c, s))
|
completions.append((c, s))
|
||||||
|
|
||||||
completions = [(c, s) for c, s in completions
|
|
||||||
if settings.case_insensitive_completion
|
|
||||||
and c.names[-1].lower().startswith(like.lower())
|
|
||||||
or c.names[-1].startswith(like)]
|
|
||||||
|
|
||||||
if not dot: # named_params have no dots
|
if not dot: # named_params have no dots
|
||||||
call_def = self.get_in_function_call()
|
call_def = self.get_in_function_call()
|
||||||
if call_def:
|
if call_def:
|
||||||
if not call_def.module.is_builtin():
|
if not call_def.module.is_builtin():
|
||||||
for p in call_def.params:
|
for p in call_def.params:
|
||||||
completions.append((p.get_name(), p))
|
completions.append((p.get_name(), p))
|
||||||
completions += []
|
|
||||||
|
# add keywords
|
||||||
|
s = builtin.builtin_scope
|
||||||
|
completions += ((k, s) for k in keywords.get_keywords(all=True))
|
||||||
|
|
||||||
|
completions = [(c, s) for c, s in completions
|
||||||
|
if settings.case_insensitive_completion
|
||||||
|
and c.names[-1].lower().startswith(like.lower())
|
||||||
|
or c.names[-1].startswith(like)]
|
||||||
|
|
||||||
needs_dot = not dot and path
|
needs_dot = not dot and path
|
||||||
completions = set(completions)
|
completions = set(completions)
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ def _check_array_additions(compare_array, module, is_list):
|
|||||||
continue
|
continue
|
||||||
backtrack_path = iter(call_path[:separate_index])
|
backtrack_path = iter(call_path[:separate_index])
|
||||||
|
|
||||||
position = c.parent_stmt().start_pos
|
position = c.start_pos
|
||||||
scope = c.parent_stmt().parent()
|
scope = c.parent_stmt().parent()
|
||||||
|
|
||||||
found = evaluate.follow_call_path(backtrack_path, scope, position)
|
found = evaluate.follow_call_path(backtrack_path, scope, position)
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ class Keyword(object):
|
|||||||
def get_parent_until(self):
|
def get_parent_until(self):
|
||||||
return builtin.builtin_scope
|
return builtin.builtin_scope
|
||||||
|
|
||||||
|
@property
|
||||||
|
def names(self):
|
||||||
|
""" For a `parsing.Name` like comparision """
|
||||||
|
return [self.name]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def docstr(self):
|
def docstr(self):
|
||||||
return imitate_pydoc(self.name)
|
return imitate_pydoc(self.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user