1
0
forked from VimPlug/jedi

Add a Name.get_parent_stmt() function.

This commit is contained in:
Dave Halter
2014-09-05 22:26:55 +02:00
parent 6c07c7acfe
commit 99116cdcb7
3 changed files with 13 additions and 7 deletions

View File

@@ -1223,7 +1223,7 @@ class Statement(Simple, DocstringMixin):
self._expression_list = lst
class ExprStatement(Statement):
class ExprStmt(Statement):
"""
This class exists temporarily, to be able to distinguish real statements
(``small_stmt`` in Python grammar) from the so called ``test`` parts, that
@@ -1235,7 +1235,7 @@ class ExprStatement(Statement):
"""
class Param(ExprStatement):
class Param(ExprStmt):
"""
The class which shows definitions of params of classes and functions.
But this is not to define function calls.
@@ -1463,6 +1463,9 @@ class NamePart(object):
def get_code(self):
return self._string
def get_parent_stmt(self):
return self.parent.parent_stmt()
def get_parent_until(self, *args, **kwargs):
return self.parent.get_parent_until(*args, **kwargs)
@@ -1501,6 +1504,9 @@ class Name(Simple):
""" Returns the names in a full string format """
return self._get_code
def get_parent_stmt(self):
return self.get_parent_until(ExprStmt)
@property
def end_pos(self):
return self.names[-1].end_pos