forked from VimPlug/jedi
Return None instead of raising an IndexError in get_next_leaf.
This commit is contained in:
@@ -255,7 +255,7 @@ class Base(object):
|
|||||||
if i == len(c) - 1:
|
if i == len(c) - 1:
|
||||||
node = node.parent
|
node = node.parent
|
||||||
if node.parent is None:
|
if node.parent is None:
|
||||||
raise IndexError('Cannot access the next element of the last one.')
|
return None
|
||||||
else:
|
else:
|
||||||
node = c[i + 1]
|
node = c[i + 1]
|
||||||
break
|
break
|
||||||
@@ -566,18 +566,6 @@ class BaseNode(Base):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
return self.children[0]
|
return self.children[0]
|
||||||
|
|
||||||
def get_next_leaf(self):
|
|
||||||
"""
|
|
||||||
Raises an IndexError if it's the last node. (Would be the module)
|
|
||||||
"""
|
|
||||||
c = self.parent.children
|
|
||||||
index = c.index(self)
|
|
||||||
if index == len(c) - 1:
|
|
||||||
# TODO WTF? recursion?
|
|
||||||
return self.get_next_leaf()
|
|
||||||
else:
|
|
||||||
return c[index + 1]
|
|
||||||
|
|
||||||
def last_leaf(self):
|
def last_leaf(self):
|
||||||
return self.children[-1].last_leaf()
|
return self.children[-1].last_leaf()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user