1
0
forked from VimPlug/jedi

deprecated api_classes.Completion.word in favor of name

This commit is contained in:
David Halter
2013-05-03 20:38:37 +04:30
parent beae920177
commit 49e51f5a1a
5 changed files with 33 additions and 22 deletions

View File

@@ -27,7 +27,7 @@ example for the autocompletion feature:
[<Completion: date>, <Completion: datetime>, ...]
>>> print(completions[0].complete)
te
>>> print(completions[0].word)
>>> print(completions[0].name)
date
As you see Jedi is pretty simple and allows you to concentrate on writing a

View File

@@ -154,7 +154,7 @@ class Script(object):
self._parser.user_stmt, n):
new = api_classes.Completion(c, needs_dot,
len(like), s)
k = (new.word, new.complete) # key
k = (new.name, new.complete) # key
if k in comp_dct and settings.no_completion_duplicates:
comp_dct[k]._same_name_completions.append(new)
else:
@@ -163,9 +163,9 @@ class Script(object):
debug.speed('completions end')
return sorted(comps, key=lambda x: (x.word.startswith('__'),
x.word.startswith('_'),
x.word.lower()))
return sorted(comps, key=lambda x: (x.name.startswith('__'),
x.name.startswith('_'),
x.name.lower()))
def _prepare_goto(self, goto_path, is_like_search=False):
""" Base for completions, goto and definition. Basically it returns

View File

@@ -310,7 +310,7 @@ class Completion(BaseDefinition):
def __init__(self, name, needs_dot, like_name_length, base):
super(Completion, self).__init__(name.parent, name.start_pos)
self.name = name
self._name = name
self.needs_dot = needs_dot
self.like_name_length = like_name_length
self.base = base
@@ -342,10 +342,10 @@ class Completion(BaseDefinition):
append += '.'
if isinstance(self.base, pr.Param):
append += '='
return dot + self.name.names[-1][self.like_name_length:] + append
return dot + self._name.names[-1][self.like_name_length:] + append
@property
def word(self):
def name(self):
"""
Similar to :meth:`Completion.complete`, but return the whole word, for
example::
@@ -354,7 +354,18 @@ class Completion(BaseDefinition):
would return 'isinstance'.
"""
return unicode(self.name.names[-1])
return unicode(self._name.names[-1])
@property
def word(self):
"""
.. deprecated:: 0.6.0
Use :attr:`.name` instead.
.. todo:: Remove!
"""
warnings.warn("Use name instead.", DeprecationWarning)
return self.name
@property
def description(self):
@@ -363,7 +374,7 @@ class Completion(BaseDefinition):
.. todo:: return value is just __repr__ of some objects, improve!
"""
parent = self.name.parent
parent = self._name.parent
if parent is None:
return ''
t = self.type
@@ -399,7 +410,7 @@ class Completion(BaseDefinition):
return self._followed_definitions
def __repr__(self):
return '<%s: %s>' % (type(self).__name__, self.name)
return '<%s: %s>' % (type(self).__name__, self._name)
class Definition(BaseDefinition):