Disable newlines after 'is' etc in when
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
()
|
||||
}
|
||||
@@ -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)('}')
|
||||
Reference in New Issue
Block a user