mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
added param names to completion items (see also #7)
This commit is contained in:
16
api.py
16
api.py
@@ -40,6 +40,8 @@ class Completion(object):
|
||||
|
||||
if settings.add_dot_after_module:
|
||||
if isinstance(self.base, parsing.Module): append += '.'
|
||||
if isinstance(self.base, parsing.Param):
|
||||
append += '='
|
||||
return dot + self.name.names[-1][self.like_name_length:] + append
|
||||
|
||||
@property
|
||||
@@ -141,6 +143,11 @@ class CallDef(object):
|
||||
def call_name(self):
|
||||
return str(self.executable.name)
|
||||
|
||||
@property
|
||||
def module(self):
|
||||
return self.executable.get_parent_until()
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: %s index %s>' % (self.__class__.__name__, self.executable,
|
||||
self.index)
|
||||
@@ -204,8 +211,17 @@ class Script(object):
|
||||
and c.names[-1].lower().startswith(like.lower())
|
||||
or c.names[-1].startswith(like)]
|
||||
|
||||
if not dot: # named_params have no dots
|
||||
call_def = self.get_in_function_call()
|
||||
if call_def:
|
||||
if not call_def.module.is_builtin():
|
||||
for p in call_def.params:
|
||||
completions.append((p.get_name(), p))
|
||||
completions += []
|
||||
|
||||
needs_dot = not dot and path
|
||||
completions = set(completions)
|
||||
|
||||
c = [Completion(c, needs_dot, len(like), s) for c, s in completions]
|
||||
|
||||
return c
|
||||
|
||||
10
test/completion/named_param.py
Normal file
10
test/completion/named_param.py
Normal file
@@ -0,0 +1,10 @@
|
||||
""" named params:
|
||||
>>> def a(abc): pass
|
||||
>>> a(abc=3) # <- this stuff
|
||||
"""
|
||||
|
||||
def a(abc):
|
||||
pass
|
||||
|
||||
#? 5 ['abc']
|
||||
a(abc)
|
||||
Reference in New Issue
Block a user