1
0
forked from VimPlug/jedi

Add BaseName.definition_[start,end]_position

Provides two public (property) methods getting the (row, column) of the
start / end of the definition range. Rows start with 1, columns start
with 0.

:rtype: Tuple[int, int]
This commit is contained in:
Sam Roeca
2020-05-16 15:08:36 -04:00
parent d4aa583e16
commit 716beae455

View File

@@ -231,6 +231,37 @@ class BaseName(object):
return None
return start_pos[1]
@property
def definition_start_position(self):
"""
The (row, column) of the start of the definition range. Rows start with
1, columns start with 0.
:rtype: Tuple[int, int]
"""
definition = self._name.tree_name.get_definition()
if definition is None:
return self._name.start_pos
return definition.start_pos
@property
def definition_end_position(self):
"""
The (row, column) of the end of the definition range. Rows start with
1, columns start with 0.
:rtype: Tuple[int, int]
"""
definition = self._name.tree_name.get_definition()
if definition is None:
return self._name.end_pos
if self.type in ("function", "class"):
last_leaf = definition.get_last_leaf()
if last_leaf.type == "newline":
return last_leaf.get_previous_leaf().end_pos
return last_leaf.end_pos
return definition.end_pos
def docstring(self, raw=False, fast=True):
r"""
Return a document string for this completion object.