1
0
forked from VimPlug/jedi

fix the named param issue in the autocompletion

This commit is contained in:
Dave Halter
2014-04-19 22:57:41 +02:00
parent 34488d1bb6
commit 2b091076c1
4 changed files with 16 additions and 5 deletions

View File

@@ -163,6 +163,7 @@ class Script(object):
# Allow access on _definition here, because it's a
# public API and we don't want to make the internal
# Name object public.
if p._definition.stars == 0: # no *args/**kwargs
completions.append((p._definition.get_name(), p))
if not path and not isinstance(user_stmt, pr.Import):

View File

@@ -567,7 +567,9 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
if isinstance(d, pr.Param):
try:
return unicode(d.expression_list()[0].name)
except IndexError:
except (IndexError, AttributeError):
# IndexError for syntax error params
# AttributeError for *args/**kwargs
pass
return None
elif isinstance(d, iterable.Generator):

View File

@@ -1181,6 +1181,13 @@ class Param(Statement):
debug.warning("Multiple param names (%s).", n)
return n[0]
@property
def stars(self):
exp = self.expression_list()
if exp and isinstance(exp[0], Operator):
return exp[0].string.count('*')
return 0
class StatementElement(Simple):
__slots__ = ('parent', 'next', 'execution')

View File

@@ -1,7 +1,8 @@
""" named params:
"""
Named Params:
>>> def a(abc): pass
...
>>> a(abc=3) # <- this stuff
>>> a(abc=3) # <- this stuff (abc)
"""
def a(abc):
@@ -18,4 +19,4 @@ def a(*some_args, **some_kwargs):
a(some_args)
#? 13 []
a(some_kwargs
a(some_kwargs)