diff --git a/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java index d9517a8c31d..3d6e2338d21 100644 --- a/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -539,6 +539,7 @@ public class JetExpressionParsing extends AbstractJetParsing { */ private void parseWhenCondition() { PsiBuilder.Marker condition = mark(); + myBuilder.disableNewlines(); if (at(IN_KEYWORD) || at(NOT_IN)) { advance(); // IN_KEYWORD or NOT_IN @@ -562,6 +563,7 @@ public class JetExpressionParsing extends AbstractJetParsing { parseExpression(); } } + myBuilder.restoreNewlinesState(); condition.done(WHEN_CONDITION); } @@ -584,7 +586,7 @@ public class JetExpressionParsing extends AbstractJetParsing { if (at(NAMESPACE_KEYWORD) || at(IDENTIFIER)) { myJetParsing.parseUserType(); - if (at(LPAR)) { + if (!myBuilder.newlineBeforeCurrentToken() && at(LPAR)) { PsiBuilder.Marker list = mark(); parseTuplePattern(DECOMPOSER_ARGUMENT); list.done(DECOMPOSER_ARGUMENT_LIST); diff --git a/idea/testData/psi/NewlinesInParentheses.jet b/idea/testData/psi/NewlinesInParentheses.jet index 3ec6b6fe8d2..92297c070ce 100644 --- a/idea/testData/psi/NewlinesInParentheses.jet +++ b/idea/testData/psi/NewlinesInParentheses.jet @@ -20,8 +20,18 @@ fun foo() { + d} + d] - e match { - case A - () => foo; + when (e) { + is T + () => a + in f + () => a + !is T + () => a + !in f + () => a + f + () => a } + val f = a is T + () } \ No newline at end of file diff --git a/idea/testData/psi/NewlinesInParentheses.txt b/idea/testData/psi/NewlinesInParentheses.txt index d7496363e54..69b6b096fec 100644 --- a/idea/testData/psi/NewlinesInParentheses.txt +++ b/idea/testData/psi/NewlinesInParentheses.txt @@ -212,32 +212,120 @@ JetFile: NewlinesInParentheses.jet PsiElement(IDENTIFIER)('d') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n\n ') - MATCH_EXPRESSION + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('e') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(match)('match') - PsiWhiteSpace(' ') - MATCH_BLOCK - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - MATCH_ENTRY - PsiElement(case)('case') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION + PsiElement(is)('is') PsiWhiteSpace(' ') - PATTERN - USER_TYPE - PsiElement(IDENTIFIER)('A') + DECOMPOSER_PATTERN + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') PsiWhiteSpace('\n ') - TUPLE_PATTERN + DECOMPOSER_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION + PsiElement(in)('in') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION + PsiElement(NOT_IS)('!is') PsiWhiteSpace(' ') + DECOMPOSER_PATTERN + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + DECOMPOSER_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION + PsiElement(NOT_IN)('!in') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_WITH_PATTERN + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(is)('is') + PsiWhiteSpace(' ') + TYPE_PATTERN REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(SEMICOLON)(';') - PsiWhiteSpace('\n ') - PsiElement(RBRACE)('}') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + PARENTHESIZED + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file