mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
added a method 'api_classes.Completion.name_with_signs', because this is important for #280
This commit is contained in:
@@ -321,16 +321,7 @@ class Completion(BaseDefinition):
|
|||||||
|
|
||||||
self._followed_definitions = None
|
self._followed_definitions = None
|
||||||
|
|
||||||
@property
|
def _complete(self, like_name):
|
||||||
def complete(self):
|
|
||||||
"""
|
|
||||||
Return the rest of the word, e.g. completing ``isinstance``::
|
|
||||||
|
|
||||||
isinstan# <-- Cursor is here
|
|
||||||
|
|
||||||
would return the string 'ce'. It also adds additional stuff, depending
|
|
||||||
on your `settings.py`.
|
|
||||||
"""
|
|
||||||
dot = '.' if self._needs_dot else ''
|
dot = '.' if self._needs_dot else ''
|
||||||
append = ''
|
append = ''
|
||||||
if settings.add_bracket_after_function \
|
if settings.add_bracket_after_function \
|
||||||
@@ -342,7 +333,23 @@ class Completion(BaseDefinition):
|
|||||||
append += '.'
|
append += '.'
|
||||||
if isinstance(self._base, pr.Param):
|
if isinstance(self._base, pr.Param):
|
||||||
append += '='
|
append += '='
|
||||||
return dot + self._name.names[-1][self._like_name_length:] + append
|
|
||||||
|
name = self._name.names[-1]
|
||||||
|
if like_name:
|
||||||
|
name = name[self._like_name_length:]
|
||||||
|
return dot + name + append
|
||||||
|
|
||||||
|
@property
|
||||||
|
def complete(self):
|
||||||
|
"""
|
||||||
|
Return the rest of the word, e.g. completing ``isinstance``::
|
||||||
|
|
||||||
|
isinstan# <-- Cursor is here
|
||||||
|
|
||||||
|
would return the string 'ce'. It also adds additional stuff, depending
|
||||||
|
on your `settings.py`.
|
||||||
|
"""
|
||||||
|
return self._complete(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@@ -352,10 +359,22 @@ class Completion(BaseDefinition):
|
|||||||
|
|
||||||
isinstan
|
isinstan
|
||||||
|
|
||||||
would return 'isinstance'.
|
would return `isinstance`.
|
||||||
"""
|
"""
|
||||||
return unicode(self._name.names[-1])
|
return unicode(self._name.names[-1])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name_with_signs(self):
|
||||||
|
"""
|
||||||
|
Similar to :meth:`Completion.name`, but like :meth:`Completion.name`
|
||||||
|
returns also the signs, for example::
|
||||||
|
|
||||||
|
list()
|
||||||
|
|
||||||
|
would return ``.append`` and others.
|
||||||
|
"""
|
||||||
|
return self._complete(False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def word(self):
|
def word(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ def setup_readline(namespace=__main__.__dict__):
|
|||||||
self.matches.append(path + dot + name)
|
self.matches.append(path + dot + name)
|
||||||
else:
|
else:
|
||||||
completions = interpreter.completions()
|
completions = interpreter.completions()
|
||||||
self.matches = [text + c.complete for c in completions]
|
self.matches = [path + dot + c.name_with_signs
|
||||||
|
for c in completions]
|
||||||
try:
|
try:
|
||||||
return self.matches[state]
|
return self.matches[state]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|||||||
Reference in New Issue
Block a user