forked from VimPlug/jedi
use expression_list instead of commands or call_list
This commit is contained in:
@@ -441,7 +441,7 @@ class Script(object):
|
|||||||
defs, search_name = self._evaluator.goto(stmt)
|
defs, search_name = self._evaluator.goto(stmt)
|
||||||
definitions = follow_inexistent_imports(defs)
|
definitions = follow_inexistent_imports(defs)
|
||||||
if isinstance(user_stmt, pr.Statement):
|
if isinstance(user_stmt, pr.Statement):
|
||||||
c = user_stmt.get_commands()
|
c = user_stmt.expression_list()
|
||||||
if c and not isinstance(c[0], (str, unicode)) \
|
if c and not isinstance(c[0], (str, unicode)) \
|
||||||
and c[0].start_pos > self._pos \
|
and c[0].start_pos > self._pos \
|
||||||
and not re.search(r'\.\w+$', goto_path):
|
and not re.search(r'\.\w+$', goto_path):
|
||||||
@@ -466,7 +466,7 @@ class Script(object):
|
|||||||
user_stmt = self._user_stmt()
|
user_stmt = self._user_stmt()
|
||||||
definitions, search_name = self._goto(add_import_name=True)
|
definitions, search_name = self._goto(add_import_name=True)
|
||||||
if isinstance(user_stmt, pr.Statement):
|
if isinstance(user_stmt, pr.Statement):
|
||||||
c = user_stmt.get_commands()[0]
|
c = user_stmt.expression_list()[0]
|
||||||
if not isinstance(c, unicode) and self._pos < c.start_pos:
|
if not isinstance(c, unicode) and self._pos < c.start_pos:
|
||||||
# the search_name might be before `=`
|
# the search_name might be before `=`
|
||||||
definitions = [v for v in user_stmt.get_set_vars()
|
definitions = [v for v in user_stmt.get_set_vars()
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ def save_module(path, name, parser, pickling=True):
|
|||||||
|
|
||||||
class _ModulePickling(object):
|
class _ModulePickling(object):
|
||||||
|
|
||||||
version = 6
|
version = 7
|
||||||
"""
|
"""
|
||||||
Version number (integer) for file system cache.
|
Version number (integer) for file system cache.
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ To *visualize* this (simplified):
|
|||||||
- ``eval_statement`` - ``<Statement: datetime.date>``
|
- ``eval_statement`` - ``<Statement: datetime.date>``
|
||||||
|
|
||||||
- Unpacking of the statement into ``[[<Call: datetime.date>]]``
|
- Unpacking of the statement into ``[[<Call: datetime.date>]]``
|
||||||
- ``follow_call_list``, calls ``eval_call`` with ``<Call: datetime.date>``
|
- ``eval_expression_list``, calls ``eval_call`` with ``<Call: datetime.date>``
|
||||||
- ``eval_call`` - searches the ``datetime`` name within the module.
|
- ``eval_call`` - searches the ``datetime`` name within the module.
|
||||||
|
|
||||||
This is exactly where it starts to get complicated. Now recursions start to
|
This is exactly where it starts to get complicated. Now recursions start to
|
||||||
@@ -264,7 +264,7 @@ class Evaluator(object):
|
|||||||
if not r.is_generated:
|
if not r.is_generated:
|
||||||
res_new += dynamic.search_params(self, r)
|
res_new += dynamic.search_params(self, r)
|
||||||
if not res_new:
|
if not res_new:
|
||||||
c = r.get_commands()[0]
|
c = r.expression_list()[0]
|
||||||
if c in ('*', '**'):
|
if c in ('*', '**'):
|
||||||
t = 'tuple' if c == '*' else 'dict'
|
t = 'tuple' if c == '*' else 'dict'
|
||||||
res_new = [er.Instance(
|
res_new = [er.Instance(
|
||||||
@@ -312,7 +312,7 @@ class Evaluator(object):
|
|||||||
return []
|
return []
|
||||||
result = get_iterator_types(self.eval_statement(loop.inputs[0]))
|
result = get_iterator_types(self.eval_statement(loop.inputs[0]))
|
||||||
if len(loop.set_vars) > 1:
|
if len(loop.set_vars) > 1:
|
||||||
commands = loop.set_stmt.get_commands()
|
commands = loop.set_stmt.expression_list()
|
||||||
# loops with loop.set_vars > 0 only have one command
|
# loops with loop.set_vars > 0 only have one command
|
||||||
result = assign_tuples(commands[0], result, name_str)
|
result = assign_tuples(commands[0], result, name_str)
|
||||||
return result
|
return result
|
||||||
@@ -489,9 +489,9 @@ class Evaluator(object):
|
|||||||
:param seek_name: A string.
|
:param seek_name: A string.
|
||||||
"""
|
"""
|
||||||
debug.dbg('eval_statement %s (%s)' % (stmt, seek_name))
|
debug.dbg('eval_statement %s (%s)' % (stmt, seek_name))
|
||||||
commands = stmt.get_commands()
|
expression_list = stmt.expression_list()
|
||||||
|
|
||||||
result = self.follow_call_list(commands)
|
result = self.eval_expression_list(expression_list)
|
||||||
|
|
||||||
# Assignment checking is only important if the statement defines multiple
|
# Assignment checking is only important if the statement defines multiple
|
||||||
# variables.
|
# variables.
|
||||||
@@ -503,9 +503,9 @@ class Evaluator(object):
|
|||||||
return set(result)
|
return set(result)
|
||||||
|
|
||||||
@common.rethrow_uncaught
|
@common.rethrow_uncaught
|
||||||
def follow_call_list(self, call_list, follow_array=False):
|
def eval_expression_list(self, expression_list, follow_array=False):
|
||||||
"""
|
"""
|
||||||
`call_list` can be either `pr.Array` or `list of list`.
|
`expression_list` can be either `pr.Array` or `list of list`.
|
||||||
It is used to evaluate a two dimensional object, that has calls, arrays and
|
It is used to evaluate a two dimensional object, that has calls, arrays and
|
||||||
operators in it.
|
operators in it.
|
||||||
"""
|
"""
|
||||||
@@ -525,9 +525,9 @@ class Evaluator(object):
|
|||||||
loop = evaluate_list_comprehension(nested_lc, loop)
|
loop = evaluate_list_comprehension(nested_lc, loop)
|
||||||
return loop
|
return loop
|
||||||
|
|
||||||
debug.dbg('follow_call_list: %s' % call_list)
|
debug.dbg('eval_expression_list: %s' % expression_list)
|
||||||
result = []
|
result = []
|
||||||
calls_iterator = iter(call_list)
|
calls_iterator = iter(expression_list)
|
||||||
for call in calls_iterator:
|
for call in calls_iterator:
|
||||||
if pr.Array.is_type(call, pr.Array.NOARRAY):
|
if pr.Array.is_type(call, pr.Array.NOARRAY):
|
||||||
r = list(itertools.chain.from_iterable(self.eval_statement(s)
|
r = list(itertools.chain.from_iterable(self.eval_statement(s)
|
||||||
@@ -630,7 +630,7 @@ class Evaluator(object):
|
|||||||
foo.bar.baz
|
foo.bar.baz
|
||||||
|
|
||||||
`follow_path` is only responsible for completing `.bar.baz`, the rest is
|
`follow_path` is only responsible for completing `.bar.baz`, the rest is
|
||||||
done in the `eval_call` function.
|
done in the `follow_call` function.
|
||||||
"""
|
"""
|
||||||
# current is either an Array or a Scope.
|
# current is either an Array or a Scope.
|
||||||
try:
|
try:
|
||||||
@@ -669,7 +669,7 @@ class Evaluator(object):
|
|||||||
|
|
||||||
def goto(self, stmt, call_path=None):
|
def goto(self, stmt, call_path=None):
|
||||||
if call_path is None:
|
if call_path is None:
|
||||||
commands = stmt.get_commands()
|
commands = stmt.expression_list()
|
||||||
if len(commands) == 0:
|
if len(commands) == 0:
|
||||||
return [], ''
|
return [], ''
|
||||||
# Only the first command is important, the rest should basically not
|
# Only the first command is important, the rest should basically not
|
||||||
@@ -793,7 +793,7 @@ def assign_tuples(tup, results, seek_name):
|
|||||||
for i, stmt in enumerate(tup):
|
for i, stmt in enumerate(tup):
|
||||||
# Used in assignments. There is just one call and no other things,
|
# Used in assignments. There is just one call and no other things,
|
||||||
# therefore we can just assume, that the first part is important.
|
# therefore we can just assume, that the first part is important.
|
||||||
command = stmt.get_commands()[0]
|
command = stmt.expression_list()[0]
|
||||||
|
|
||||||
if tup.type == pr.Array.NOARRAY:
|
if tup.type == pr.Array.NOARRAY:
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ def search_params(evaluator, param):
|
|||||||
# first assignment details, others would be a syntax error
|
# first assignment details, others would be a syntax error
|
||||||
commands, op = param.assignment_details[0]
|
commands, op = param.assignment_details[0]
|
||||||
else:
|
else:
|
||||||
commands = param.get_commands()
|
commands = param.expression_list()
|
||||||
offset = 1 if commands[0] in ['*', '**'] else 0
|
offset = 1 if commands[0] in ['*', '**'] else 0
|
||||||
param_name = str(commands[offset].name)
|
param_name = str(commands[offset].name)
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ def _scan_statement(stmt, search_name, assignment_details=False):
|
|||||||
result += _scan_statement(stmt, search_name)
|
result += _scan_statement(stmt, search_name)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
check = list(stmt.get_commands())
|
check = list(stmt.expression_list())
|
||||||
if assignment_details:
|
if assignment_details:
|
||||||
for commands, op in stmt.assignment_details:
|
for commands, op in stmt.assignment_details:
|
||||||
check += commands
|
check += commands
|
||||||
@@ -465,7 +465,7 @@ def check_flow_information(evaluator, flow, search_name, pos):
|
|||||||
def _check_isinstance_type(evaluator, stmt, search_name):
|
def _check_isinstance_type(evaluator, stmt, search_name):
|
||||||
from jedi.evaluate import representation as er
|
from jedi.evaluate import representation as er
|
||||||
try:
|
try:
|
||||||
commands = stmt.get_commands()
|
commands = stmt.expression_list()
|
||||||
# this might be removed if we analyze and, etc
|
# this might be removed if we analyze and, etc
|
||||||
assert len(commands) == 1
|
assert len(commands) == 1
|
||||||
call = commands[0]
|
call = commands[0]
|
||||||
@@ -475,7 +475,7 @@ def _check_isinstance_type(evaluator, stmt, search_name):
|
|||||||
# isinstance check
|
# isinstance check
|
||||||
isinst = call.execution.values
|
isinst = call.execution.values
|
||||||
assert len(isinst) == 2 # has two params
|
assert len(isinst) == 2 # has two params
|
||||||
obj, classes = [statement.get_commands() for statement in isinst]
|
obj, classes = [statement.expression_list() for statement in isinst]
|
||||||
assert len(obj) == 1
|
assert len(obj) == 1
|
||||||
assert len(classes) == 1
|
assert len(classes) == 1
|
||||||
assert isinstance(obj[0], pr.Call)
|
assert isinstance(obj[0], pr.Call)
|
||||||
|
|||||||
@@ -227,11 +227,11 @@ class InstanceElement(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
return self
|
return self
|
||||||
return func
|
return func
|
||||||
|
|
||||||
def get_commands(self):
|
def expression_list(self):
|
||||||
# Copy and modify the array.
|
# Copy and modify the array.
|
||||||
return [InstanceElement(self.instance._evaluator, self.instance, command, self.is_class_var)
|
return [InstanceElement(self.instance._evaluator, self.instance, command, self.is_class_var)
|
||||||
if not isinstance(command, unicode) else command
|
if not isinstance(command, unicode) else command
|
||||||
for command in self.var.get_commands()]
|
for command in self.var.expression_list()]
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for el in self.var.__iter__():
|
for el in self.var.__iter__():
|
||||||
@@ -545,12 +545,12 @@ class Execution(Executable):
|
|||||||
key_stmts = []
|
key_stmts = []
|
||||||
for key in keys:
|
for key in keys:
|
||||||
stmt = pr.Statement(self._sub_module, [], start_pos, None)
|
stmt = pr.Statement(self._sub_module, [], start_pos, None)
|
||||||
stmt._commands = [key]
|
stmt._expression_list = [key]
|
||||||
key_stmts.append(stmt)
|
key_stmts.append(stmt)
|
||||||
arr.keys = key_stmts
|
arr.keys = key_stmts
|
||||||
arr.type = array_type
|
arr.type = array_type
|
||||||
|
|
||||||
new_param._commands = [arr]
|
new_param._expression_list = [arr]
|
||||||
|
|
||||||
name = copy.copy(param.get_name())
|
name = copy.copy(param.get_name())
|
||||||
name.parent = new_param
|
name.parent = new_param
|
||||||
@@ -594,7 +594,7 @@ class Execution(Executable):
|
|||||||
values=[value]))
|
values=[value]))
|
||||||
key, value = next(var_arg_iterator, (None, None))
|
key, value = next(var_arg_iterator, (None, None))
|
||||||
|
|
||||||
commands = param.get_commands()
|
commands = param.expression_list()
|
||||||
keys = []
|
keys = []
|
||||||
values = []
|
values = []
|
||||||
array_type = None
|
array_type = None
|
||||||
@@ -660,14 +660,14 @@ class Execution(Executable):
|
|||||||
# generate a statement if it's not already one.
|
# generate a statement if it's not already one.
|
||||||
module = builtin.Builtin.scope
|
module = builtin.Builtin.scope
|
||||||
stmt = pr.Statement(module, [], (0, 0), None)
|
stmt = pr.Statement(module, [], (0, 0), None)
|
||||||
stmt._commands = [old]
|
stmt._expression_list = [old]
|
||||||
|
|
||||||
# *args
|
# *args
|
||||||
commands = stmt.get_commands()
|
commands = stmt.expression_list()
|
||||||
if not len(commands):
|
if not len(commands):
|
||||||
continue
|
continue
|
||||||
if commands[0] == '*':
|
if commands[0] == '*':
|
||||||
arrays = self._evaluator.follow_call_list(commands[1:])
|
arrays = self._evaluator.eval_expression_list(commands[1:])
|
||||||
# *args must be some sort of an array, otherwise -> ignore
|
# *args must be some sort of an array, otherwise -> ignore
|
||||||
|
|
||||||
for array in arrays:
|
for array in arrays:
|
||||||
@@ -679,12 +679,12 @@ class Execution(Executable):
|
|||||||
yield None, helpers.FakeStatement(field_stmt)
|
yield None, helpers.FakeStatement(field_stmt)
|
||||||
# **kwargs
|
# **kwargs
|
||||||
elif commands[0] == '**':
|
elif commands[0] == '**':
|
||||||
arrays = self._evaluator.follow_call_list(commands[1:])
|
arrays = self._evaluator.eval_expression_list(commands[1:])
|
||||||
for array in arrays:
|
for array in arrays:
|
||||||
if isinstance(array, Array):
|
if isinstance(array, Array):
|
||||||
for key_stmt, value_stmt in array.items():
|
for key_stmt, value_stmt in array.items():
|
||||||
# first index, is the key if syntactically correct
|
# first index, is the key if syntactically correct
|
||||||
call = key_stmt.get_commands()[0]
|
call = key_stmt.expression_list()[0]
|
||||||
if isinstance(call, pr.Name):
|
if isinstance(call, pr.Name):
|
||||||
yield call, value_stmt
|
yield call, value_stmt
|
||||||
elif isinstance(call, pr.Call):
|
elif isinstance(call, pr.Call):
|
||||||
@@ -839,7 +839,7 @@ class Array(use_metaclass(CachedMetaClass, pr.Base, Iterable)):
|
|||||||
def get_index_types(self, index_arr=None):
|
def get_index_types(self, index_arr=None):
|
||||||
""" Get the types of a specific index or all, if not given """
|
""" Get the types of a specific index or all, if not given """
|
||||||
if index_arr is not None:
|
if index_arr is not None:
|
||||||
if index_arr and [x for x in index_arr if ':' in x.get_commands()]:
|
if index_arr and [x for x in index_arr if ':' in x.expression_list()]:
|
||||||
# array slicing
|
# array slicing
|
||||||
return [self]
|
return [self]
|
||||||
|
|
||||||
@@ -868,7 +868,7 @@ class Array(use_metaclass(CachedMetaClass, pr.Base, Iterable)):
|
|||||||
index = None
|
index = None
|
||||||
for i, key_statement in enumerate(self._array.keys):
|
for i, key_statement in enumerate(self._array.keys):
|
||||||
# Because we only want the key to be a string.
|
# Because we only want the key to be a string.
|
||||||
key_commands = key_statement.get_commands()
|
key_commands = key_statement.expression_list()
|
||||||
if len(key_commands) != 1: # cannot deal with complex strings
|
if len(key_commands) != 1: # cannot deal with complex strings
|
||||||
continue
|
continue
|
||||||
key = key_commands[0]
|
key = key_commands[0]
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ def array_for_pos(stmt, pos, array_types=None):
|
|||||||
if stmt.start_pos >= pos >= stmt.end_pos:
|
if stmt.start_pos >= pos >= stmt.end_pos:
|
||||||
return None, 0
|
return None, 0
|
||||||
|
|
||||||
for command in stmt.get_commands():
|
for command in stmt.expression_list():
|
||||||
arr = None
|
arr = None
|
||||||
if isinstance(command, pr.Array):
|
if isinstance(command, pr.Array):
|
||||||
arr, index = search_array(command, pos)
|
arr, index = search_array(command, pos)
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ def sys_path_with_modifications(module):
|
|||||||
for p in possible_stmts:
|
for p in possible_stmts:
|
||||||
if not isinstance(p, pr.Statement):
|
if not isinstance(p, pr.Statement):
|
||||||
continue
|
continue
|
||||||
commands = p.get_commands()
|
commands = p.expression_list()
|
||||||
# sys.path command is just one thing.
|
# sys.path command is just one thing.
|
||||||
if len(commands) != 1 or not isinstance(commands[0], pr.Call):
|
if len(commands) != 1 or not isinstance(commands[0], pr.Call):
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -749,7 +749,7 @@ class Statement(Simple):
|
|||||||
:type start_pos: 2-tuple of int
|
:type start_pos: 2-tuple of int
|
||||||
:param start_pos: Position (line, column) of the Statement.
|
:param start_pos: Position (line, column) of the Statement.
|
||||||
"""
|
"""
|
||||||
__slots__ = ('token_list', '_set_vars', 'as_names', '_commands',
|
__slots__ = ('token_list', '_set_vars', 'as_names', '_expression_list',
|
||||||
'_assignment_details', 'docstr', '_names_are_set_vars')
|
'_assignment_details', 'docstr', '_names_are_set_vars')
|
||||||
|
|
||||||
def __init__(self, module, token_list, start_pos, end_pos, parent=None,
|
def __init__(self, module, token_list, start_pos, end_pos, parent=None,
|
||||||
@@ -771,7 +771,7 @@ class Statement(Simple):
|
|||||||
self.as_names = list(as_names)
|
self.as_names = list(as_names)
|
||||||
|
|
||||||
# cache
|
# cache
|
||||||
self._commands = None
|
self._expression_list = None
|
||||||
self._assignment_details = []
|
self._assignment_details = []
|
||||||
# this is important for other scripts
|
# this is important for other scripts
|
||||||
|
|
||||||
@@ -788,7 +788,7 @@ class Statement(Simple):
|
|||||||
return '%s %s ' % (''.join(pieces), assignment)
|
return '%s %s ' % (''.join(pieces), assignment)
|
||||||
|
|
||||||
code = ''.join(assemble(*a) for a in self.assignment_details)
|
code = ''.join(assemble(*a) for a in self.assignment_details)
|
||||||
code += assemble(self.get_commands())
|
code += assemble(self.expression_list())
|
||||||
if self.docstr:
|
if self.docstr:
|
||||||
code += '\n"""%s"""' % self.docstr
|
code += '\n"""%s"""' % self.docstr
|
||||||
|
|
||||||
@@ -800,12 +800,12 @@ class Statement(Simple):
|
|||||||
def get_set_vars(self):
|
def get_set_vars(self):
|
||||||
""" Get the names for the statement. """
|
""" Get the names for the statement. """
|
||||||
if self._set_vars is None:
|
if self._set_vars is None:
|
||||||
self._set_vars = []
|
|
||||||
def search_calls(calls):
|
def search_calls(calls):
|
||||||
for call in calls:
|
for call in calls:
|
||||||
if isinstance(call, Array):
|
if isinstance(call, Array):
|
||||||
for stmt in call:
|
for stmt in call:
|
||||||
search_calls(stmt.get_commands())
|
search_calls(stmt.expression_list())
|
||||||
elif isinstance(call, Call):
|
elif isinstance(call, Call):
|
||||||
c = call
|
c = call
|
||||||
# Check if there's an execution in it, if so this is
|
# Check if there's an execution in it, if so this is
|
||||||
@@ -819,12 +819,13 @@ class Statement(Simple):
|
|||||||
continue
|
continue
|
||||||
self._set_vars.append(call.name)
|
self._set_vars.append(call.name)
|
||||||
|
|
||||||
|
self._set_vars = []
|
||||||
for calls, operation in self.assignment_details:
|
for calls, operation in self.assignment_details:
|
||||||
search_calls(calls)
|
search_calls(calls)
|
||||||
|
|
||||||
if not self.assignment_details and self._names_are_set_vars:
|
if not self.assignment_details and self._names_are_set_vars:
|
||||||
# In the case of Param, it's also a defining name without ``=``
|
# In the case of Param, it's also a defining name without ``=``
|
||||||
search_calls(self.get_commands())
|
search_calls(self.expression_list())
|
||||||
return self._set_vars + self.as_names
|
return self._set_vars + self.as_names
|
||||||
|
|
||||||
def is_global(self):
|
def is_global(self):
|
||||||
@@ -843,14 +844,14 @@ class Statement(Simple):
|
|||||||
would result in ``[(Name(x), '='), (Array([Name(y), Name(z)]), '=')]``.
|
would result in ``[(Name(x), '='), (Array([Name(y), Name(z)]), '=')]``.
|
||||||
"""
|
"""
|
||||||
# parse statement which creates the assignment details.
|
# parse statement which creates the assignment details.
|
||||||
self.get_commands()
|
self.expression_list()
|
||||||
return self._assignment_details
|
return self._assignment_details
|
||||||
|
|
||||||
def get_commands(self):
|
def expression_list(self):
|
||||||
if self._commands is None:
|
if self._expression_list is None:
|
||||||
self._commands = ['time neeeeed'] # avoid recursions
|
self._expression_list = ['time neeeeed'] # avoid recursions
|
||||||
self._commands = self._parse_statement()
|
self._expression_list = self._parse_statement()
|
||||||
return self._commands
|
return self._expression_list
|
||||||
|
|
||||||
def _parse_statement(self):
|
def _parse_statement(self):
|
||||||
"""
|
"""
|
||||||
@@ -1016,7 +1017,7 @@ class Statement(Simple):
|
|||||||
stmt = Statement(self._sub_module, token_list,
|
stmt = Statement(self._sub_module, token_list,
|
||||||
start_pos, arr.end_pos)
|
start_pos, arr.end_pos)
|
||||||
arr.parent = stmt
|
arr.parent = stmt
|
||||||
stmt.token_list = stmt._commands = [arr]
|
stmt.token_list = stmt._expression_list = [arr]
|
||||||
else:
|
else:
|
||||||
for t in stmt.token_list:
|
for t in stmt.token_list:
|
||||||
if isinstance(t, Name):
|
if isinstance(t, Name):
|
||||||
@@ -1126,7 +1127,7 @@ class Statement(Simple):
|
|||||||
self.parent,
|
self.parent,
|
||||||
set_name_parents=False
|
set_name_parents=False
|
||||||
)
|
)
|
||||||
stmt._commands = result
|
stmt._expression_list = result
|
||||||
arr, break_tok = parse_array(token_iterator, Array.TUPLE,
|
arr, break_tok = parse_array(token_iterator, Array.TUPLE,
|
||||||
stmt.start_pos, stmt)
|
stmt.start_pos, stmt)
|
||||||
result = [arr]
|
result = [arr]
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ def inline(script):
|
|||||||
if not stmt.start_pos <= (r.line, r.column) <= stmt.end_pos]
|
if not stmt.start_pos <= (r.line, r.column) <= stmt.end_pos]
|
||||||
inlines = sorted(inlines, key=lambda x: (x.module_path, x.line, x.column),
|
inlines = sorted(inlines, key=lambda x: (x.module_path, x.line, x.column),
|
||||||
reverse=True)
|
reverse=True)
|
||||||
commands = stmt.get_commands()
|
commands = stmt.expression_list()
|
||||||
# don't allow multiline refactorings for now.
|
# don't allow multiline refactorings for now.
|
||||||
assert stmt.start_pos[0] == stmt.end_pos[0]
|
assert stmt.start_pos[0] == stmt.end_pos[0]
|
||||||
index = stmt.start_pos[0] - 1
|
index = stmt.start_pos[0] - 1
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def test_user_statement_on_import():
|
|||||||
class TestCallAndName():
|
class TestCallAndName():
|
||||||
def get_call(self, source):
|
def get_call(self, source):
|
||||||
stmt = Parser(source, no_docstr=True).module.statements[0]
|
stmt = Parser(source, no_docstr=True).module.statements[0]
|
||||||
return stmt.get_commands()[0]
|
return stmt.expression_list()[0]
|
||||||
|
|
||||||
def test_name_and_call_positions(self):
|
def test_name_and_call_positions(self):
|
||||||
call = self.get_call('name\nsomething_else')
|
call = self.get_call('name\nsomething_else')
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class TestRegression(TestCase):
|
|||||||
s = "x()\nx( )\nx( )\nx ( )"
|
s = "x()\nx( )\nx( )\nx ( )"
|
||||||
parser = Parser(s)
|
parser = Parser(s)
|
||||||
for i, s in enumerate(parser.module.statements, 3):
|
for i, s in enumerate(parser.module.statements, 3):
|
||||||
for c in s.get_commands():
|
for c in s.expression_list():
|
||||||
self.assertEqual(c.execution.end_pos[1], i)
|
self.assertEqual(c.execution.end_pos[1], i)
|
||||||
|
|
||||||
def check_definition_by_marker(self, source, after_cursor, names):
|
def check_definition_by_marker(self, source, after_cursor, names):
|
||||||
|
|||||||
Reference in New Issue
Block a user