From fd3df74c1ff3898e96d1bc798fc1e39e5f7e3185 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Mon, 14 Feb 2011 22:17:12 +0300 Subject: [PATCH] Calls with closures parsed to a single node --- .../lang/parsing/JetExpressionParsing.java | 11 ++--- idea/testData/psi/CallWithManyClosures.jet | 3 +- idea/testData/psi/CallWithManyClosures.txt | 43 +++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java index efe5626d80e..4edf37472ce 100644 --- a/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -299,11 +299,11 @@ public class JetExpressionParsing extends AbstractJetParsing { advance(); // operation expression.done(POSTFIX_EXPRESSION); } else if (parseCallWithClosure()) { - while (parseCallWithClosure()); + parseCallWithClosure(); expression.done(CALL_EXPRESSION); } else if (at(LPAR)) { parseValueArgumentList(); - while (parseCallWithClosure()); + parseCallWithClosure(); expression.done(CALL_EXPRESSION); } else if (at(LT)) { // TODO: be (even) more clever @@ -357,11 +357,12 @@ public class JetExpressionParsing extends AbstractJetParsing { * expression functionLiteral? */ protected boolean parseCallWithClosure() { - if (!myBuilder.newlineBeforeCurrentToken() && at(LBRACE)) { + boolean success = false; + while (!myBuilder.newlineBeforeCurrentToken() && at(LBRACE)) { parseFunctionLiteral(); - return true; + success = true; } - return false; + return success; } /* diff --git a/idea/testData/psi/CallWithManyClosures.jet b/idea/testData/psi/CallWithManyClosures.jet index 9731b09b8f9..6418e2bad58 100644 --- a/idea/testData/psi/CallWithManyClosures.jet +++ b/idea/testData/psi/CallWithManyClosures.jet @@ -3,4 +3,5 @@ val a = f {} {} {} val a = f {} val a = f() {} val a = (f) {} {} {} -val a = (f)() {} {} {} \ No newline at end of file +val a = (f)() {} {} {} +val a = (f)() {} {} {} \ No newline at end of file diff --git a/idea/testData/psi/CallWithManyClosures.txt b/idea/testData/psi/CallWithManyClosures.txt index 4148265a4e9..3b25af4a6e4 100644 --- a/idea/testData/psi/CallWithManyClosures.txt +++ b/idea/testData/psi/CallWithManyClosures.txt @@ -159,6 +159,49 @@ JetFile: CallWithManyClosures.jet PsiElement(RBRACE)('}') PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiElement(RPAR)(')') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') FUNCTION_LITERAL PsiElement(LBRACE)('{') BODY