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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user