forked from VimPlug/jedi
Create a next_sibling method on _Leaf, which is then used to check for self attributes.
This commit is contained in:
@@ -136,16 +136,6 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
|||||||
|
|
||||||
@memoize_default([])
|
@memoize_default([])
|
||||||
def get_self_attributes(self):
|
def get_self_attributes(self):
|
||||||
def add_self_dot_name(name):
|
|
||||||
"""
|
|
||||||
Need to copy and rewrite the name, because names are now
|
|
||||||
``instance_usage.variable`` instead of ``self.variable``.
|
|
||||||
"""
|
|
||||||
n = copy.copy(name)
|
|
||||||
n.names = n.names[1:]
|
|
||||||
n._get_code = unicode(n.names[-1])
|
|
||||||
names.append(get_instance_el(self._evaluator, self, n))
|
|
||||||
|
|
||||||
names = []
|
names = []
|
||||||
# This loop adds the names of the self object, copies them and removes
|
# This loop adds the names of the self object, copies them and removes
|
||||||
# the self.
|
# the self.
|
||||||
@@ -166,14 +156,12 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
|||||||
# complicated.
|
# complicated.
|
||||||
sub = self._get_method_execution(sub)
|
sub = self._get_method_execution(sub)
|
||||||
print(sub.names_dict.values())
|
print(sub.names_dict.values())
|
||||||
for per_name_list in sub.names_dict.values():
|
for name_list in sub.names_dict.values():
|
||||||
for call in per_name_list:
|
for name in name_list:
|
||||||
if name.value == self_name \
|
if name.value == self_name:
|
||||||
and isinstance(call.next, pr.Call) \
|
next = name.next_sibling()
|
||||||
and call.next.next is None:
|
if isinstance(next, pr.Name) and next.is_definition():
|
||||||
names.append(get_instance_el(self._evaluator, self, call.next.name))
|
names.append(get_instance_el(self._evaluator, self, next))
|
||||||
#if unicode(n.names[0]) == self_name and len(n.names) == 2:
|
|
||||||
# add_self_dot_name(n)
|
|
||||||
|
|
||||||
for s in self.base.py__bases__(self._evaluator):
|
for s in self.base.py__bases__(self._evaluator):
|
||||||
if not isinstance(s, compiled.CompiledObject):
|
if not isinstance(s, compiled.CompiledObject):
|
||||||
|
|||||||
@@ -195,6 +195,19 @@ class _Leaf(Base):
|
|||||||
def get_code(self):
|
def get_code(self):
|
||||||
return self.prefix + self.value
|
return self.prefix + self.value
|
||||||
|
|
||||||
|
def next_sibling(self):
|
||||||
|
"""
|
||||||
|
The node immediately following the invocant in their parent's children
|
||||||
|
list. If the invocant does not have a next sibling, it is None
|
||||||
|
"""
|
||||||
|
# Can't use index(); we need to test by identity
|
||||||
|
for i, child in enumerate(self.parent.children):
|
||||||
|
if child is self:
|
||||||
|
try:
|
||||||
|
return self.parent.children[i + 1]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s: %s>" % (type(self).__name__, repr(self.value))
|
return "<%s: %s>" % (type(self).__name__, repr(self.value))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user