diff --git a/python/src/com/jetbrains/python/parsing/FunctionParsing.java b/python/src/com/jetbrains/python/parsing/FunctionParsing.java index 4045b6e19582..05d359ebc0d7 100644 --- a/python/src/com/jetbrains/python/parsing/FunctionParsing.java +++ b/python/src/com/jetbrains/python/parsing/FunctionParsing.java @@ -50,9 +50,7 @@ public class FunctionParsing extends Parsing { parseReturnTypeAnnotation(); checkMatches(PyTokenTypes.COLON, message("PARSE.expected.colon")); final ParsingContext context = getParsingContext(); - ParsingScope newScope = context.getScope().withFunction(true); - if (async) newScope = newScope.withAsync(); - context.pushScope(newScope); + context.pushScope(context.getScope().withFunction(async)); getStatementParser().parseSuite(functionMarker, getFunctionType()); context.popScope(); } diff --git a/python/src/com/jetbrains/python/parsing/ParsingScope.java b/python/src/com/jetbrains/python/parsing/ParsingScope.java index d720fbaa9068..49843bca27b3 100644 --- a/python/src/com/jetbrains/python/parsing/ParsingScope.java +++ b/python/src/com/jetbrains/python/parsing/ParsingScope.java @@ -27,27 +27,22 @@ public class ParsingScope { protected ParsingScope() {} - public ParsingScope withFunction(boolean flag) { + public ParsingScope withFunction(boolean async) { final ParsingScope result = copy(); - result.myFunction = flag; + result.myFunction = true; + result.myAsync = async; return result; } - public ParsingScope withClass(boolean flag) { + public ParsingScope withClass() { final ParsingScope result = copy(); - result.myClass = flag; + result.myClass = true; return result; } - public ParsingScope withSuite(boolean flag) { + public ParsingScope withSuite() { final ParsingScope result = copy(); - result.mySuite = flag; - return result; - } - - public ParsingScope withAsync() { - final ParsingScope result = copy(); - result.myAsync = true; + result.mySuite = true; return result; } diff --git a/python/src/com/jetbrains/python/parsing/StatementParsing.java b/python/src/com/jetbrains/python/parsing/StatementParsing.java index a14ba4cbfef8..70c229262811 100644 --- a/python/src/com/jetbrains/python/parsing/StatementParsing.java +++ b/python/src/com/jetbrains/python/parsing/StatementParsing.java @@ -807,7 +807,7 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper { inheritMarker.done(PyElementTypes.ARGUMENT_LIST); } final ParsingContext context = getParsingContext(); - context.pushScope(context.getScope().withClass(true)); + context.pushScope(context.getScope().withClass()); parseColonAndSuite(); context.popScope(); classMarker.done(PyElementTypes.CLASS_DECLARATION); @@ -874,14 +874,14 @@ public class StatementParsing extends Parsing implements ITokenTypeRemapper { } else { final ParsingContext context = getParsingContext(); - context.pushScope(context.getScope().withSuite(true)); + context.pushScope(context.getScope().withSuite()); parseSimpleStatement(); context.popScope(); while (matchToken(PyTokenTypes.SEMICOLON)) { if (matchToken(PyTokenTypes.STATEMENT_BREAK)) { break; } - context.pushScope(context.getScope().withSuite(true)); + context.pushScope(context.getScope().withSuite()); parseSimpleStatement(); context.popScope(); }