diff options
author | Bill Wendling <isanbard@gmail.com> | 2021-12-25 02:09:20 -0600 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2021-12-25 02:09:20 -0600 |
commit | 46180bc4f9f803b319f6dcc9748c74d5a743d8f2 (patch) | |
tree | 815bae0e5019ddb277b6ec4ef451e0d1bbc1de3e | |
parent | 42f4da7d9590891a8b5dd1236e6d6d4265f86078 (diff) | |
download | yapf-46180bc4f9f803b319f6dcc9748c74d5a743d8f2.tar.gz |
Add "start" and "end" properties
This gives the starting (lineno, column) and ending (lineno, column) for
a logical line.
-rw-r--r-- | yapf/yapflib/unwrapped_line.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py index 778cd8e..3b480a0 100644 --- a/yapf/yapflib/unwrapped_line.py +++ b/yapf/yapflib/unwrapped_line.py @@ -212,6 +212,24 @@ class UnwrappedLine(object): return self.first.lineno @property + def start(self): + """The start of the logical line. + + Returns: + A tuple of the starting line number and column. + """ + return (self.first.lineno, self.first.column) + + @property + def end(self): + """The end of the logical line. + + Returns: + A tuple of the ending line number and column. + """ + return (self.last.lineno, self.last.column + len(self.last.value)) + + @property def is_comment(self): return self.first.is_comment |