diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index 775b4eca895..5504bab7cc9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -1465,7 +1465,15 @@ public class JetExpressionParsing extends AbstractJetParsing { if (!at(RPAR)) { PsiBuilder.Marker parameter = mark(); + + if (!at(IN_KEYWORD)) { + myJetParsing.parseModifierListWithUnescapedAnnotations( + TokenSet.create(IDENTIFIER, LPAR), TokenSet.create(IN_KEYWORD, RPAR, COLON) + ); + } + 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); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index 2c36ee81b4f..0eda4392dcd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -1172,6 +1172,9 @@ public class JetParsing extends AbstractJetParsing { break; } PsiBuilder.Marker property = mark(); + + parseModifierListWithUnescapedAnnotations(TokenSet.create(COMMA, RPAR, COLON, IN_KEYWORD, EQ)); + expect(IDENTIFIER, "Expecting a name", recoverySet); if (at(COLON)) { @@ -1916,8 +1919,12 @@ public class JetParsing extends AbstractJetParsing { return atGT; } - private void parseModifierListWithUnescapedAnnotations(TokenSet stopAt) { - int lastId = findLastBefore(IDENTIFIER, stopAt, false); + public void parseModifierListWithUnescapedAnnotations(TokenSet stopAt) { + parseModifierListWithUnescapedAnnotations(TokenSet.create(IDENTIFIER), stopAt); + } + + public void parseModifierListWithUnescapedAnnotations(TokenSet lookFor, TokenSet stopAt) { + int lastId = findLastBefore(lookFor, stopAt, false); createTruncatedBuilder(lastId).parseModifierList(ALLOW_UNESCAPED_REGULAR_ANNOTATIONS); } diff --git a/compiler/testData/psi/annotation/at/declarationsJustAtTyped.txt b/compiler/testData/psi/annotation/at/declarationsJustAtTyped.txt index 17914ef7abd..e7d96cdfe85 100644 --- a/compiler/testData/psi/annotation/at/declarationsJustAtTyped.txt +++ b/compiler/testData/psi/annotation/at/declarationsJustAtTyped.txt @@ -242,42 +242,33 @@ JetFile: declarationsJustAtTyped.kt PsiElement(RBRACE)('}') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n ') - BINARY_EXPRESSION - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - VALUE_PARAMETER - PsiErrorElement:Expecting a variable name + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiErrorElement:Expected modifier or annotation after '@' PsiElement(AT)('@') PsiWhiteSpace(' ') - PsiErrorElement:Expecting 'in' - PsiElement(IDENTIFIER)('x') - PsiErrorElement:Expecting ')' - - PsiWhiteSpace(' ') - BODY - PsiErrorElement:Expecting an expression - - OPERATION_REFERENCE - PsiElement(in)('in') + PsiElement(IDENTIFIER)('x') PsiWhiteSpace(' ') - BINARY_EXPRESSION - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - OPERATION_REFERENCE - PsiElement(RANGE)('..') - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('100') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + BODY BLOCK - - PsiElement(RBRACE)('}') + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') diff --git a/compiler/testData/psi/annotation/at/invalidExpressions.kt b/compiler/testData/psi/annotation/at/invalidExpressions.kt deleted file mode 100644 index b29c685d1c1..00000000000 --- a/compiler/testData/psi/annotation/at/invalidExpressions.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun foo() { - for (@volatile x in 1..100) {} -} diff --git a/compiler/testData/psi/annotation/at/invalidExpressions.txt b/compiler/testData/psi/annotation/at/invalidExpressions.txt deleted file mode 100644 index 7e581762ccc..00000000000 --- a/compiler/testData/psi/annotation/at/invalidExpressions.txt +++ /dev/null @@ -1,52 +0,0 @@ -JetFile: invalidExpressions.kt - PACKAGE_DIRECTIVE - - FUN - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('foo') - 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(AT)('@') - PsiErrorElement:Expecting 'in' - PsiElement(IDENTIFIER)('volatile') - PsiErrorElement:Expecting ')' - - PsiWhiteSpace(' ') - BODY - BINARY_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(in)('in') - PsiWhiteSpace(' ') - BINARY_EXPRESSION - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - OPERATION_REFERENCE - PsiElement(RANGE)('..') - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('100') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/forParameters.kt b/compiler/testData/psi/annotation/forParameters.kt new file mode 100644 index 00000000000..e41b3e611de --- /dev/null +++ b/compiler/testData/psi/annotation/forParameters.kt @@ -0,0 +1,21 @@ +fun foo() { + for (@volatile x in z) {} + + for ([ann]) {} + for (@ in z) {} + + for ((x, private data @ann [ann] y) in x) {} + + for (([ann], x) in pair) {} + + for (volatile x in 1..100) {} + for (volatile(1) x in 1..100) {} + for (volatile() (x, volatile y) in 1..100) {} + for (volatile (x, volatile y) in 1..100) {} + + for (volatile var x in 1..100) {} + for (volatile val (x, volatile y) in 1..100) {} + + for (private volatile var x in 1..100) {} + for (private volatile val (x, volatile y) in 1..100) {} +} diff --git a/compiler/testData/psi/annotation/forParameters.txt b/compiler/testData/psi/annotation/forParameters.txt new file mode 100644 index 00000000000..a8299c239ed --- /dev/null +++ b/compiler/testData/psi/annotation/forParameters.txt @@ -0,0 +1,523 @@ +JetFile: forParameters.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('z') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiErrorElement:Expecting a variable name + PsiElement(RPAR)(')') + PsiErrorElement:Expecting 'in' + + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiErrorElement:Expected modifier or annotation after '@' + PsiElement(AT)('@') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('z') + PsiErrorElement:Expecting a variable name + PsiElement(RPAR)(')') + PsiErrorElement:Expecting 'in' + + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace(' ') + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiErrorElement:Expecting a name + + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('pair') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + OPERATION_REFERENCE + PsiElement(RANGE)('..') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('100') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/multiDeclaration.kt b/compiler/testData/psi/annotation/multiDeclaration.kt new file mode 100644 index 00000000000..ebd0c8dfa88 --- /dev/null +++ b/compiler/testData/psi/annotation/multiDeclaration.kt @@ -0,0 +1,7 @@ +fun foo() { + val (x, private data @ann [ann] y) = pair + val ([ann], x) = pair + + @volatile val (@ann x, y) = 1 + @volatile val (@ann x, y = 1 +} diff --git a/compiler/testData/psi/annotation/multiDeclaration.txt b/compiler/testData/psi/annotation/multiDeclaration.txt new file mode 100644 index 00000000000..c790cb7adf8 --- /dev/null +++ b/compiler/testData/psi/annotation/multiDeclaration.txt @@ -0,0 +1,159 @@ +JetFile: multiDeclaration.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MULTI_VARIABLE_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace(' ') + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('pair') + PsiWhiteSpace('\n ') + MULTI_VARIABLE_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiErrorElement:Expecting a name + + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('pair') + PsiWhiteSpace('\n\n ') + MULTI_VARIABLE_DECLARATION + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + MULTI_VARIABLE_DECLARATION + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('volatile') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + MULTI_VARIABLE_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + MULTI_VARIABLE_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('y') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index 586c8af1f2d..39a99950a7b 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -651,6 +651,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("forParameters.kt") + public void testForParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/forParameters.kt"); + doParsingTest(fileName); + } + @TestMetadata("lambda.kt") public void testLambda() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/lambda.kt"); @@ -663,6 +669,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("multiDeclaration.kt") + public void testMultiDeclaration() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/multiDeclaration.kt"); + doParsingTest(fileName); + } + @TestMetadata("ShortAnnotations.kt") public void testShortAnnotations() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/ShortAnnotations.kt"); @@ -707,12 +719,6 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } - @TestMetadata("invalidExpressions.kt") - public void testInvalidExpressions() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/invalidExpressions.kt"); - doParsingTest(fileName); - } - @TestMetadata("modifierAtFileStart.kt") public void testModifierAtFileStart() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/modifierAtFileStart.kt");