forked from VimPlug/jedi
Adding prev_sibling, getting self attributes.
This commit is contained in:
@@ -295,11 +295,16 @@ class FakeArray(pr.Array):
|
||||
|
||||
class FakeStatement(pr.ExprStmt):
|
||||
def __init__(self, values, start_pos=(0, 0), parent=None):
|
||||
p = start_pos
|
||||
self._start_pos = start_pos
|
||||
super(FakeStatement, self).__init__([])
|
||||
self.values = values
|
||||
self.parent = parent
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
"""Overwriting the original start_pos property."""
|
||||
return self._start_pos
|
||||
|
||||
|
||||
class FakeImport(pr.Import):
|
||||
def __init__(self, name, parent, level=0):
|
||||
|
||||
@@ -394,6 +394,7 @@ def _gen_param_name_copy(func, var_args, param, keys=(), values=(), array_type=N
|
||||
"""
|
||||
Create a param with the original scope (of varargs) as parent.
|
||||
"""
|
||||
print(func, var_args, param, keys, values, array_type)
|
||||
if isinstance(var_args, pr.Array):
|
||||
parent = var_args.parent
|
||||
start_pos = var_args.start_pos
|
||||
|
||||
@@ -155,13 +155,14 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
|
||||
# because to follow them and their self variables is too
|
||||
# complicated.
|
||||
sub = self._get_method_execution(sub)
|
||||
print(sub.names_dict.values())
|
||||
for name_list in sub.names_dict.values():
|
||||
for name in name_list:
|
||||
if name.value == self_name:
|
||||
next = name.next_sibling()
|
||||
if isinstance(next, pr.Name) and next.is_definition():
|
||||
names.append(get_instance_el(self._evaluator, self, next))
|
||||
if name.value == self_name and name.prev_sibling() is None:
|
||||
trailer = name.next_sibling()
|
||||
if pr.is_node(trailer, 'trailer') \
|
||||
and len(trailer.children) == 2:
|
||||
name = trailer.children[1] # After dot.
|
||||
names.append(get_instance_el(self._evaluator, self, name))
|
||||
|
||||
for s in self.base.py__bases__(self._evaluator):
|
||||
if not isinstance(s, compiled.CompiledObject):
|
||||
|
||||
@@ -208,6 +208,18 @@ class _Leaf(Base):
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def prev_sibling(self):
|
||||
"""
|
||||
The node immediately preceding the invocant in their parent's children
|
||||
list. If the invocant does not have a previous 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:
|
||||
if i == 0:
|
||||
return None
|
||||
return self.parent.children[i - 1]
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s: %s>" % (type(self).__name__, repr(self.value))
|
||||
|
||||
@@ -1249,6 +1261,10 @@ class Param(object):
|
||||
annotation_stmt.parent = self.use_as_parent
|
||||
self.annotation_stmt = annotation_stmt
|
||||
|
||||
def __repr__(self):
|
||||
default = '' if self.default is None else '=%s' % self.default
|
||||
return '<%s: %s>' % (type(self).__name__, str(self.tfpdef) + default)
|
||||
|
||||
|
||||
class StatementElement(Simple):
|
||||
__slots__ = ('next', 'previous')
|
||||
|
||||
Reference in New Issue
Block a user