mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix some last extract issues
This commit is contained in:
@@ -310,11 +310,13 @@ def _remove_unwanted_expression_nodes(parent_node, pos, until_pos):
|
||||
start_index -= 1
|
||||
break
|
||||
for i, n in reversed(list(enumerate(nodes))):
|
||||
if n.start_pos <= until_pos:
|
||||
if n.start_pos < until_pos:
|
||||
end_index = i
|
||||
if n.type == 'operator':
|
||||
end_index += 1
|
||||
break
|
||||
print(nodes, start_index, end_index)
|
||||
return nodes[start_index:end_index + 1]
|
||||
nodes = nodes[start_index:end_index + 1]
|
||||
nodes[0:1] = _remove_unwanted_expression_nodes(nodes[0], pos, until_pos)
|
||||
nodes[-1:] = _remove_unwanted_expression_nodes(nodes[-1], pos, until_pos)
|
||||
return nodes
|
||||
return [parent_node]
|
||||
|
||||
@@ -154,3 +154,45 @@ z = y + 1 + 2+ 3, 3
|
||||
#? 4 text {'new_name': 'x', 'until_column': 9}
|
||||
x = y + 1
|
||||
z = x + 2+ 3, 3
|
||||
# -------------------------------------------------- addition-2
|
||||
#? 8 text {'new_name': 'x', 'until_column': 12}
|
||||
z = y +1 + 2+ 3, 3
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#? 8 text {'new_name': 'x', 'until_column': 12}
|
||||
x = 1 + 2
|
||||
z = y +x+ 3, 3
|
||||
# -------------------------------------------------- addition-3
|
||||
#? 10 text {'new_name': 'x', 'until_column': 14}
|
||||
z = y + 1 + 2+ 3, 3
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#? 10 text {'new_name': 'x', 'until_column': 14}
|
||||
x = 1 + 2+ 3
|
||||
z = y + x, 3
|
||||
# -------------------------------------------------- addition-4
|
||||
#? 13 text {'new_name': 'x', 'until_column': 17}
|
||||
z = y + (1 + 2)+ 3, 3
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#? 13 text {'new_name': 'x', 'until_column': 17}
|
||||
x = (1 + 2)+ 3
|
||||
z = y + x, 3
|
||||
# -------------------------------------------------- mult-add-1
|
||||
#? 8 text {'new_name': 'x', 'until_column': 11}
|
||||
z = foo(y+1*2+3, 3)
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#? 8 text {'new_name': 'x', 'until_column': 11}
|
||||
x = y+1
|
||||
z = foo(x*2+3, 3)
|
||||
# -------------------------------------------------- mult-add-2
|
||||
#? 12 text {'new_name': 'x', 'until_column': 15}
|
||||
z = foo(y+1*2+3)
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#? 12 text {'new_name': 'x', 'until_column': 15}
|
||||
x = 2+3
|
||||
z = foo(y+1*x)
|
||||
# -------------------------------------------------- mult-add-3
|
||||
#? 9 text {'new_name': 'x', 'until_column': 13}
|
||||
z = (y+1*2+3)
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#? 9 text {'new_name': 'x', 'until_column': 13}
|
||||
x = (y+1*2+3)
|
||||
z = x
|
||||
|
||||
Reference in New Issue
Block a user