Change annotations parsing in bodies of operators

This change only matters in cases of if/when/for/while having braceless
blocks

Annotations on them are parsed now as on block-level expressions, i.e.
they're attached to the whole expression
This commit is contained in:
Denis Zharkov
2016-10-06 16:05:38 +03:00
parent c01b4156d8
commit 9ff439e39e
7 changed files with 315 additions and 32 deletions
@@ -1237,7 +1237,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
/*
* statement
* : declaration
* : annotations expression
* : blockLevelExpression
* ;
*/
private void parseStatement(boolean isScriptTopLevel) {
@@ -1247,20 +1247,25 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
}
else if (isScriptTopLevel){
PsiBuilder.Marker scriptInitializer = mark();
parseStatementLevelExpression();
parseBlockLevelExpression();
scriptInitializer.done(SCRIPT_INITIALIZER);
}
else {
parseStatementLevelExpression();
parseBlockLevelExpression();
}
}
}
private void parseStatementLevelExpression() {
/*
* blockLevelExpression
* : annotations expression
* ;
*/
private void parseBlockLevelExpression() {
if (at(AT)) {
PsiBuilder.Marker expression = mark();
myKotlinParsing.parseAnnotations(DEFAULT);
parseStatementLevelExpression();
parseBlockLevelExpression();
expression.done(ANNOTATED_EXPRESSION);
return;
}
@@ -1424,7 +1429,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
private void parseControlStructureBody() {
if (!parseAnnotatedLambda(/* preferBlock = */true)) {
parseExpression();
parseBlockLevelExpression();
}
}