replace name and statement end_pos (this way we can get rid of all that end_pos crap soon)

This commit is contained in:
Dave Halter
2014-03-05 23:46:39 +01:00
parent 66a488b911
commit a97c91002f
2 changed files with 9 additions and 1 deletions

View File

@@ -860,6 +860,10 @@ class Statement(Simple, DocstringMixin):
# cache # cache
self._assignment_details = [] self._assignment_details = []
@property
def end_pos(self):
return self._token_list[-1].end_pos
def get_code(self, new_line=True): def get_code(self, new_line=True):
def assemble(command_list, assignment=None): def assemble(command_list, assignment=None):
pieces = [c.get_code() if isinstance(c, Simple) else c.string if pieces = [c.get_code() if isinstance(c, Simple) else c.string if
@@ -1427,6 +1431,10 @@ class Name(Simple):
""" Returns the names in a full string format """ """ Returns the names in a full string format """
return ".".join(unicode(n) for n in self.names) return ".".join(unicode(n) for n in self.names)
@property
def end_pos(self):
return self.names[-1].end_pos
@property @property
def docstr(self): def docstr(self):
"""Return attribute docstring (PEP 257) if exists.""" """Return attribute docstring (PEP 257) if exists."""

View File

@@ -89,7 +89,7 @@ def test_module():
name = module.name name = module.name
assert str(name) == 'example' assert str(name) == 'example'
assert name.start_pos == (0, 0) assert name.start_pos == (0, 0)
assert name.end_pos == (0, 0) assert name.end_pos == (0, 7)
module = Parser(u('asdf'), no_docstr=True).module module = Parser(u('asdf'), no_docstr=True).module
name = module.name name = module.name