Change parsing of annotations on block level expressions
Attach annotations to the closest prefix expression instead of whole statement if no new line found after annotations The motivation is for a simple annotated expression like '@ann x + y' its syntax form must not change after prepending 'val z = ' just before it
This commit is contained in:
@@ -1258,13 +1258,20 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
|
||||
/*
|
||||
* blockLevelExpression
|
||||
* : annotations expression
|
||||
* : annotations + ("\n")+ expression
|
||||
* ;
|
||||
*/
|
||||
private void parseBlockLevelExpression() {
|
||||
if (at(AT)) {
|
||||
PsiBuilder.Marker expression = mark();
|
||||
myKotlinParsing.parseAnnotations(DEFAULT);
|
||||
|
||||
if (!myBuilder.newlineBeforeCurrentToken()) {
|
||||
expression.rollbackTo();
|
||||
parseExpression();
|
||||
return;
|
||||
}
|
||||
|
||||
parseBlockLevelExpression();
|
||||
expression.done(ANNOTATED_EXPRESSION);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user