forked from VimPlug/jedi
Use ExprStmt pretty much everywhere where it should be used.
ExprStmt is now really a normal statement. All the other statements are from now on considered legacy code. As a side effect this increases the parser pickling version.
This commit is contained in:
@@ -275,7 +275,7 @@ class Script(object):
|
||||
raise NotFoundError()
|
||||
if isinstance(stmt, pr.KeywordStatement):
|
||||
stmt = stmt.stmt
|
||||
if not isinstance(stmt, pr.Statement):
|
||||
if not isinstance(stmt, pr.ExprStmt):
|
||||
raise NotFoundError()
|
||||
|
||||
user_stmt = self._parser.user_stmt()
|
||||
@@ -465,7 +465,7 @@ class Script(object):
|
||||
# The Evaluator.goto function checks for definitions, but since we
|
||||
# use a reverse tokenizer, we have new name_part objects, so we
|
||||
# have to check the user_stmt here for positions.
|
||||
if isinstance(user_stmt, pr.Statement):
|
||||
if isinstance(user_stmt, pr.ExprStmt):
|
||||
for name in user_stmt.get_defined_names():
|
||||
if name.start_pos <= self._pos <= name.end_pos \
|
||||
and len(name.names) == 1:
|
||||
@@ -497,7 +497,7 @@ class Script(object):
|
||||
|
||||
# Once Script._goto works correct, we can probably remove this
|
||||
# branch.
|
||||
if isinstance(user_stmt, pr.Statement):
|
||||
if isinstance(user_stmt, pr.ExprStmt):
|
||||
c = user_stmt.expression_list()[0]
|
||||
if not isinstance(c, unicode) and self._pos < c.start_pos:
|
||||
# The lookup might be before `=`
|
||||
|
||||
@@ -332,7 +332,7 @@ class BaseDefinition(object):
|
||||
# Functions, classes and modules are already fixed definitions, we
|
||||
# cannot follow them anymore.
|
||||
return [self]
|
||||
stmt_or_imp = self._definition.get_parent_until((pr.Statement, pr.Import))
|
||||
stmt_or_imp = self._definition.get_parent_until((pr.ExprStmt, pr.Import))
|
||||
call_path = call_path_for_name_part(stmt_or_imp, self._definition)
|
||||
names = self._evaluator.goto(stmt_or_imp, call_path)
|
||||
return [Definition(self._evaluator, n) for n in names]
|
||||
@@ -352,7 +352,7 @@ class BaseDefinition(object):
|
||||
elif isinstance(stripped, pr.Class):
|
||||
stripped = er.Class(self._evaluator, stripped)
|
||||
|
||||
if stripped.isinstance(pr.Statement):
|
||||
if stripped.isinstance(pr.ExprStmt):
|
||||
return self._evaluator.eval_statement(stripped)
|
||||
elif stripped.isinstance(pr.Import):
|
||||
return imports.follow_imports(self._evaluator, [stripped])
|
||||
@@ -606,7 +606,7 @@ class Definition(use_metaclass(CachedMetaClass, BaseDefinition)):
|
||||
return None
|
||||
elif isinstance(d, pr.Param):
|
||||
name = d.get_name()
|
||||
elif isinstance(d, pr.Statement):
|
||||
elif isinstance(d, pr.ExprStmt):
|
||||
try:
|
||||
expression_list = d.assignment_details[0][0]
|
||||
name = expression_list[0].name.names[-1]
|
||||
|
||||
Reference in New Issue
Block a user