mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix an error of get_definition_end_pos, see #1584
This commit is contained in:
@@ -236,7 +236,7 @@ class BaseName(object):
|
||||
The (row, column) of the start of the definition range. Rows start with
|
||||
1, columns start with 0.
|
||||
|
||||
:rtype: Tuple[int, int]
|
||||
:rtype: Optional[Tuple[int, int]]
|
||||
"""
|
||||
definition = self._name.tree_name.get_definition()
|
||||
if definition is None:
|
||||
@@ -248,11 +248,13 @@ class BaseName(object):
|
||||
The (row, column) of the end of the definition range. Rows start with
|
||||
1, columns start with 0.
|
||||
|
||||
:rtype: Tuple[int, int]
|
||||
:rtype: Optional[Tuple[int, int]]
|
||||
"""
|
||||
definition = self._name.tree_name.get_definition()
|
||||
if definition is None:
|
||||
return self._name.end_pos
|
||||
if self._name.tree_name is None:
|
||||
return None
|
||||
return self._name.tree_name.end_pos
|
||||
if self.type in ("function", "class"):
|
||||
last_leaf = definition.get_last_leaf()
|
||||
if last_leaf.type == "newline":
|
||||
|
||||
@@ -619,6 +619,7 @@ class AClass:
|
||||
'code, pos, start, end', [
|
||||
('def a_func():\n return "bar"\n', (1, 4), (1, 0), (2, 16)),
|
||||
('var1 = 12', (1, 0), (1, 0), (1, 9)),
|
||||
('var1 + 1', (1, 0), (1, 0), (1, 4)),
|
||||
('class AClass: pass', (1, 6), (1, 0), (1, 18)),
|
||||
('class AClass: pass\n', (1, 6), (1, 0), (1, 18)),
|
||||
(cls_code, (1, 6), (1, 0), (6, 23)),
|
||||
|
||||
Reference in New Issue
Block a user