Allow newline before : as as? ?: || &&
This commit is contained in:
@@ -214,7 +214,14 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final TokenSet ALLOW_NEWLINE_OPERATIONS = TokenSet.create(DOT, SAFE_ACCESS);
|
public static final TokenSet ALLOW_NEWLINE_OPERATIONS = TokenSet.create(
|
||||||
|
DOT, SAFE_ACCESS,
|
||||||
|
COLON, AS_KEYWORD, AS_SAFE,
|
||||||
|
ELVIS,
|
||||||
|
// Can't allow `is` and `!is` because of when entry conditions: IS_KEYWORD, NOT_IS,
|
||||||
|
ANDAND,
|
||||||
|
OROR
|
||||||
|
);
|
||||||
|
|
||||||
public static final TokenSet ALL_OPERATIONS;
|
public static final TokenSet ALL_OPERATIONS;
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,29 @@ fun test() {
|
|||||||
str
|
str
|
||||||
|
|
||||||
?.length
|
?.length
|
||||||
|
|
||||||
|
str
|
||||||
|
|
||||||
|
: String
|
||||||
|
|
||||||
|
str
|
||||||
|
|
||||||
|
as String
|
||||||
|
|
||||||
|
str
|
||||||
|
|
||||||
|
as? String
|
||||||
|
|
||||||
|
str
|
||||||
|
|
||||||
|
?: foo
|
||||||
|
|
||||||
|
true
|
||||||
|
|
||||||
|
|| false
|
||||||
|
|
||||||
|
|
||||||
|
false
|
||||||
|
|
||||||
|
&& true
|
||||||
}
|
}
|
||||||
@@ -38,5 +38,71 @@ JetFile: NewLinesValidOperations.jet
|
|||||||
PsiElement(SAFE_ACCESS)('?.')
|
PsiElement(SAFE_ACCESS)('?.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('length')
|
PsiElement(IDENTIFIER)('length')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
BINARY_WITH_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('str')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('String')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
BINARY_WITH_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('str')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(as)('as')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('String')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
BINARY_WITH_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('str')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(AS_SAFE)('as?')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('String')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('str')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(ELVIS)('?:')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BOOLEAN_CONSTANT
|
||||||
|
PsiElement(true)('true') ª
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(OROR)('||')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BOOLEAN_CONSTANT
|
||||||
|
PsiElement(false)('false')
|
||||||
|
PsiWhiteSpace('\n\n\n ')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
BOOLEAN_CONSTANT
|
||||||
|
PsiElement(false)('false')
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(ANDAND)('&&')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BOOLEAN_CONSTANT
|
||||||
|
PsiElement(true)('true')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
PsiElement(RBRACE)('}')
|
PsiElement(RBRACE)('}')
|
||||||
Reference in New Issue
Block a user