forked from VimPlug/jedi
fixed refactoring: inline
This commit is contained in:
@@ -11,7 +11,6 @@ following functions (sometimes bug-prone):
|
|||||||
- rename
|
- rename
|
||||||
- extract variable
|
- extract variable
|
||||||
- inline variable
|
- inline variable
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
@@ -19,6 +18,7 @@ from __future__ import with_statement
|
|||||||
import modules
|
import modules
|
||||||
import difflib
|
import difflib
|
||||||
import helpers
|
import helpers
|
||||||
|
import parsing_representation as pr
|
||||||
|
|
||||||
|
|
||||||
class Refactoring(object):
|
class Refactoring(object):
|
||||||
@@ -183,11 +183,13 @@ def inline(script):
|
|||||||
index = stmt.start_pos[0] - 1
|
index = stmt.start_pos[0] - 1
|
||||||
|
|
||||||
line = new_lines[index]
|
line = new_lines[index]
|
||||||
replace_str = line[stmt.start_pos[1]:stmt.end_pos[1] + 1]
|
replace_str = line[commands[0].start_pos[1]:stmt.end_pos[1] + 1]
|
||||||
replace_str = replace_str.strip()
|
replace_str = replace_str.strip()
|
||||||
# tuples need parentheses
|
# tuples need parentheses
|
||||||
if len(commands) > 1:
|
if commands and isinstance(commands[0], pr.Array):
|
||||||
replace_str = '(%s)' % replace_str
|
arr = commands[0]
|
||||||
|
if replace_str[0] not in ['(', '[', '{'] and len(arr) > 1:
|
||||||
|
replace_str = '(%s)' % replace_str
|
||||||
|
|
||||||
# if it's the only assignment, remove the statement
|
# if it's the only assignment, remove the statement
|
||||||
if len(stmt.set_vars) == 1:
|
if len(stmt.set_vars) == 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user