From f36f1796d66b8eb1e46864082c0d456a457bb19f Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 20 Jun 2014 15:28:42 +0400 Subject: [PATCH] Fix recovery for 'for' expression --- .../lang/parsing/JetExpressionParsing.java | 51 +++++++++-------- .../incompleteCode/checkNothingIsSubtype.kt | 6 +- compiler/testData/psi/ForWithMultiDecl.txt | 16 ++---- .../psi/recovery/ForEmptyParentheses.kt | 7 +++ .../psi/recovery/ForEmptyParentheses.txt | 41 ++++++++++++++ .../psi/recovery/ForEmptyWithoutBody.kt | 5 ++ .../psi/recovery/ForEmptyWithoutBody.txt | 36 ++++++++++++ .../psi/recovery/ForNoBodyBeforeRBrace.kt | 5 ++ .../psi/recovery/ForNoBodyBeforeRBrace.txt | 41 ++++++++++++++ .../psi/recovery/ForWithOnlyOneLParInEOF.kt | 1 + .../psi/recovery/ForWithOnlyOneLParInEOF.txt | 26 +++++++++ .../psi/recovery/ForWithoutBodyInEOF.kt | 1 + .../psi/recovery/ForWithoutBodyInEOF.txt | 23 ++++++++ .../testData/psi/recovery/ForWithoutLPar.kt | 5 ++ .../testData/psi/recovery/ForWithoutLPar.txt | 33 +++++++++++ .../psi/recovery/ForWithoutLParInEOF.kt | 1 + .../psi/recovery/ForWithoutLParInEOF.txt | 20 +++++++ .../recovery/ForWithoutParamButWithRange.kt | 4 ++ .../recovery/ForWithoutParamButWithRange.txt | 39 +++++++++++++ .../testData/psi/recovery/ForWithoutRange.kt | 5 ++ .../testData/psi/recovery/ForWithoutRange.txt | 33 +++++++++++ .../WithWithoutInAndMultideclaration.kt | 5 ++ .../WithWithoutInAndMultideclaration.txt | 40 +++++++++++++ .../jet/parsing/JetParsingTestGenerated.java | 56 +++++++++++++++++-- 24 files changed, 458 insertions(+), 42 deletions(-) create mode 100644 compiler/testData/psi/recovery/ForEmptyParentheses.kt create mode 100644 compiler/testData/psi/recovery/ForEmptyParentheses.txt create mode 100644 compiler/testData/psi/recovery/ForEmptyWithoutBody.kt create mode 100644 compiler/testData/psi/recovery/ForEmptyWithoutBody.txt create mode 100644 compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.kt create mode 100644 compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.txt create mode 100644 compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.kt create mode 100644 compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.txt create mode 100644 compiler/testData/psi/recovery/ForWithoutBodyInEOF.kt create mode 100644 compiler/testData/psi/recovery/ForWithoutBodyInEOF.txt create mode 100644 compiler/testData/psi/recovery/ForWithoutLPar.kt create mode 100644 compiler/testData/psi/recovery/ForWithoutLPar.txt create mode 100644 compiler/testData/psi/recovery/ForWithoutLParInEOF.kt create mode 100644 compiler/testData/psi/recovery/ForWithoutLParInEOF.txt create mode 100644 compiler/testData/psi/recovery/ForWithoutParamButWithRange.kt create mode 100644 compiler/testData/psi/recovery/ForWithoutParamButWithRange.txt create mode 100644 compiler/testData/psi/recovery/ForWithoutRange.kt create mode 100644 compiler/testData/psi/recovery/ForWithoutRange.txt create mode 100644 compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.kt create mode 100644 compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java index 4cd7dc20ced..2373777862e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -1370,35 +1370,40 @@ public class JetExpressionParsing extends AbstractJetParsing { advance(); // FOR_KEYWORD - myBuilder.disableNewlines(); - expect(LPAR, "Expecting '(' to open a loop range", TokenSet.create(RPAR, VAL_KEYWORD, VAR_KEYWORD, IDENTIFIER)); + if (expect(LPAR, "Expecting '(' to open a loop range", EXPRESSION_FIRST)) { + myBuilder.disableNewlines(); - PsiBuilder.Marker parameter = mark(); - if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) advance(); // VAL_KEYWORD or VAR_KEYWORD - if (at(LPAR)) { - myJetParsing.parseMultiDeclarationName(TokenSet.create(IN_KEYWORD, LBRACE)); + if (!at(RPAR)) { + PsiBuilder.Marker parameter = mark(); + if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) advance(); // VAL_KEYWORD or VAR_KEYWORD + if (at(LPAR)) { + myJetParsing.parseMultiDeclarationName(TokenSet.create(IN_KEYWORD, LBRACE)); + parameter.done(MULTI_VARIABLE_DECLARATION); + } + else { + expect(IDENTIFIER, "Expecting a variable name", TokenSet.create(COLON, IN_KEYWORD)); - parameter.done(MULTI_VARIABLE_DECLARATION); - } - else { - expect(IDENTIFIER, "Expecting a variable name", TokenSet.create(COLON)); + if (at(COLON)) { + advance(); // COLON + myJetParsing.parseTypeRef(TokenSet.create(IN_KEYWORD)); + } + parameter.done(VALUE_PARAMETER); + } - if (at(COLON)) { - advance(); // COLON - myJetParsing.parseTypeRef(TokenSet.create(IN_KEYWORD)); + if (expect(IN_KEYWORD, "Expecting 'in'", TokenSet.create(LPAR, LBRACE, RPAR))) { + PsiBuilder.Marker range = mark(); + parseExpression(); + range.done(LOOP_RANGE); + } } - parameter.done(VALUE_PARAMETER); + else { + error("Expecting a variable name"); + } + + expectNoAdvance(RPAR, "Expecting ')'"); + myBuilder.restoreNewlinesState(); } - expect(IN_KEYWORD, "Expecting 'in'", TokenSet.create(LPAR, LBRACE)); - - PsiBuilder.Marker range = mark(); - parseExpression(); - range.done(LOOP_RANGE); - - expectNoAdvance(RPAR, "Expecting ')'"); - myBuilder.restoreNewlinesState(); - parseControlStructureBody(); loop.done(FOR); diff --git a/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt b/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt index 8eee69ddae7..a4510fc8b5d 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt @@ -9,6 +9,6 @@ fun test(nothing: Nothing?) { } fun sum(a : IntArray) : Int { - for (n - return "?" -} \ No newline at end of file +for (n +return "?" +} \ No newline at end of file diff --git a/compiler/testData/psi/ForWithMultiDecl.txt b/compiler/testData/psi/ForWithMultiDecl.txt index 72b4094e80e..50fce4d50bf 100644 --- a/compiler/testData/psi/ForWithMultiDecl.txt +++ b/compiler/testData/psi/ForWithMultiDecl.txt @@ -658,17 +658,9 @@ JetFile: ForWithMultiDecl.kt PsiErrorElement:Expecting 'in' PsiWhiteSpace(' ') - LOOP_RANGE - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - - PsiElement(RBRACE)('}') - PsiErrorElement:Expecting ')' - - PsiWhiteSpace('\n') BODY - PsiErrorElement:Expecting an expression - + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForEmptyParentheses.kt b/compiler/testData/psi/recovery/ForEmptyParentheses.kt new file mode 100644 index 00000000000..d650562110c --- /dev/null +++ b/compiler/testData/psi/recovery/ForEmptyParentheses.kt @@ -0,0 +1,7 @@ +fun test(): Int { + for () { + + } + + return 1 +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForEmptyParentheses.txt b/compiler/testData/psi/recovery/ForEmptyParentheses.txt new file mode 100644 index 00000000000..54637bcd5c6 --- /dev/null +++ b/compiler/testData/psi/recovery/ForEmptyParentheses.txt @@ -0,0 +1,41 @@ +JetFile: ForEmptyParentheses.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a variable name + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForEmptyWithoutBody.kt b/compiler/testData/psi/recovery/ForEmptyWithoutBody.kt new file mode 100644 index 00000000000..ee39105562d --- /dev/null +++ b/compiler/testData/psi/recovery/ForEmptyWithoutBody.kt @@ -0,0 +1,5 @@ +fun test(): Int { + for () + + return 1 +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForEmptyWithoutBody.txt b/compiler/testData/psi/recovery/ForEmptyWithoutBody.txt new file mode 100644 index 00000000000..a2fb1b359e0 --- /dev/null +++ b/compiler/testData/psi/recovery/ForEmptyWithoutBody.txt @@ -0,0 +1,36 @@ +JetFile: ForEmptyWithoutBody.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a variable name + + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + BODY + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.kt b/compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.kt new file mode 100644 index 00000000000..6bea4afc769 --- /dev/null +++ b/compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.kt @@ -0,0 +1,5 @@ +fun test() { + while (true) { + for () + } +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.txt b/compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.txt new file mode 100644 index 00000000000..47a3fe600de --- /dev/null +++ b/compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.txt @@ -0,0 +1,41 @@ +JetFile: ForNoBodyBeforeRBrace.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHILE + PsiElement(while)('while') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a variable name + + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BODY + PsiErrorElement:Expecting an expression + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.kt b/compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.kt new file mode 100644 index 00000000000..f27c0d2aa4b --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.kt @@ -0,0 +1 @@ +fun test() = for ( \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.txt b/compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.txt new file mode 100644 index 00000000000..f64c5e36c16 --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.txt @@ -0,0 +1,26 @@ +JetFile: ForWithOnlyOneLParInEOF.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiErrorElement:Expecting a variable name + + PsiErrorElement:Expecting 'in' + + PsiErrorElement:Expecting ')' + + BODY + \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutBodyInEOF.kt b/compiler/testData/psi/recovery/ForWithoutBodyInEOF.kt new file mode 100644 index 00000000000..9d6b05d33bf --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutBodyInEOF.kt @@ -0,0 +1 @@ +fun test() = for () \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutBodyInEOF.txt b/compiler/testData/psi/recovery/ForWithoutBodyInEOF.txt new file mode 100644 index 00000000000..8fcf670047c --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutBodyInEOF.txt @@ -0,0 +1,23 @@ +JetFile: ForWithoutBodyInEOF.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a variable name + + PsiElement(RPAR)(')') + BODY + PsiErrorElement:Expecting an expression + \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutLPar.kt b/compiler/testData/psi/recovery/ForWithoutLPar.kt new file mode 100644 index 00000000000..bae4369a47e --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutLPar.kt @@ -0,0 +1,5 @@ +fun test(): Int { + for + + return 1 +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutLPar.txt b/compiler/testData/psi/recovery/ForWithoutLPar.txt new file mode 100644 index 00000000000..b7db1cf5028 --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutLPar.txt @@ -0,0 +1,33 @@ +JetFile: ForWithoutLPar.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiErrorElement:Expecting '(' to open a loop range + + PsiWhiteSpace('\n\n ') + BODY + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutLParInEOF.kt b/compiler/testData/psi/recovery/ForWithoutLParInEOF.kt new file mode 100644 index 00000000000..297c47865fa --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutLParInEOF.kt @@ -0,0 +1 @@ +fun test() = for \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutLParInEOF.txt b/compiler/testData/psi/recovery/ForWithoutLParInEOF.txt new file mode 100644 index 00000000000..b5bb46c5dff --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutLParInEOF.txt @@ -0,0 +1,20 @@ +JetFile: ForWithoutLParInEOF.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FOR + PsiElement(for)('for') + PsiErrorElement:Expecting '(' to open a loop range + + BODY + PsiErrorElement:Expecting an expression + \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutParamButWithRange.kt b/compiler/testData/psi/recovery/ForWithoutParamButWithRange.kt new file mode 100644 index 00000000000..ace3d6f7f84 --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutParamButWithRange.kt @@ -0,0 +1,4 @@ +fun test() { + for (in some()) { + } +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutParamButWithRange.txt b/compiler/testData/psi/recovery/ForWithoutParamButWithRange.txt new file mode 100644 index 00000000000..e62d99b1c18 --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutParamButWithRange.txt @@ -0,0 +1,39 @@ +JetFile: ForWithoutParamButWithRange.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiErrorElement:Expecting a variable name + + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('some') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutRange.kt b/compiler/testData/psi/recovery/ForWithoutRange.kt new file mode 100644 index 00000000000..9cbd45e8906 --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutRange.kt @@ -0,0 +1,5 @@ +fun test() { + for (some) + + bar() +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/ForWithoutRange.txt b/compiler/testData/psi/recovery/ForWithoutRange.txt new file mode 100644 index 00000000000..078249feef5 --- /dev/null +++ b/compiler/testData/psi/recovery/ForWithoutRange.txt @@ -0,0 +1,33 @@ +JetFile: ForWithoutRange.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('some') + PsiErrorElement:Expecting 'in' + + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + BODY + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.kt b/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.kt new file mode 100644 index 00000000000..6f010e85fcb --- /dev/null +++ b/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.kt @@ -0,0 +1,5 @@ +fun test() { + for ((i, j)) + + foo() +} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt b/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt new file mode 100644 index 00000000000..2125b2e4d26 --- /dev/null +++ b/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt @@ -0,0 +1,40 @@ +JetFile: WithWithoutInAndMultideclaration.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('i') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('j') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting 'in' + + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + BODY + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java index 72677bc4863..bc669636385 100644 --- a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java @@ -882,9 +882,7 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { } public void testAllFilesPresentInRecovery() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", - new File("compiler/testData/psi/recovery"), Pattern.compile("^(.*)\\.kts?$"), - true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/psi/recovery"), Pattern.compile("^(.*)\\.kts?$"), true); } @TestMetadata("DoWhileWithEmptyCondition.kt") @@ -901,12 +899,57 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { public void testEnumEntryInitList() throws Exception { doParsingTest("compiler/testData/psi/recovery/EnumEntryInitList.kt"); } - + + @TestMetadata("ForEmptyParentheses.kt") + public void testForEmptyParentheses() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForEmptyParentheses.kt"); + } + + @TestMetadata("ForEmptyWithoutBody.kt") + public void testForEmptyWithoutBody() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForEmptyWithoutBody.kt"); + } + + @TestMetadata("ForNoBodyBeforeRBrace.kt") + public void testForNoBodyBeforeRBrace() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForNoBodyBeforeRBrace.kt"); + } + @TestMetadata("ForRecovery.kt") public void testForRecovery() throws Exception { doParsingTest("compiler/testData/psi/recovery/ForRecovery.kt"); } + @TestMetadata("ForWithOnlyOneLParInEOF.kt") + public void testForWithOnlyOneLParInEOF() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForWithOnlyOneLParInEOF.kt"); + } + + @TestMetadata("ForWithoutBodyInEOF.kt") + public void testForWithoutBodyInEOF() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForWithoutBodyInEOF.kt"); + } + + @TestMetadata("ForWithoutLPar.kt") + public void testForWithoutLPar() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForWithoutLPar.kt"); + } + + @TestMetadata("ForWithoutLParInEOF.kt") + public void testForWithoutLParInEOF() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForWithoutLParInEOF.kt"); + } + + @TestMetadata("ForWithoutParamButWithRange.kt") + public void testForWithoutParamButWithRange() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForWithoutParamButWithRange.kt"); + } + + @TestMetadata("ForWithoutRange.kt") + public void testForWithoutRange() throws Exception { + doParsingTest("compiler/testData/psi/recovery/ForWithoutRange.kt"); + } + @TestMetadata("IfWithEmptyCondition.kt") public void testIfWithEmptyCondition() throws Exception { doParsingTest("compiler/testData/psi/recovery/IfWithEmptyCondition.kt"); @@ -982,6 +1025,11 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest("compiler/testData/psi/recovery/WhileWithoutLPar.kt"); } + @TestMetadata("WithWithoutInAndMultideclaration.kt") + public void testWithWithoutInAndMultideclaration() throws Exception { + doParsingTest("compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.kt"); + } + } @TestMetadata("compiler/testData/psi/script")