Parse collection literals as atomic expressions
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
fun test() {
|
||||
[]
|
||||
[1]
|
||||
[1, 2]
|
||||
[[]]
|
||||
[[1]]
|
||||
[1, []]
|
||||
[[], 1]
|
||||
[[], [1, []]]
|
||||
[1,
|
||||
2]
|
||||
[1,
|
||||
[2]]
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
JetFile: CollectionLiterals.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('test')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
[,]
|
||||
[1, ]
|
||||
[, 1]
|
||||
[1, 2 3]
|
||||
[1, 2 3, ]
|
||||
[
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
JetFile: CollectionLiterals_ERR.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('test')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiErrorElement:Expecting an element
|
||||
PsiElement(COMMA)(',')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiErrorElement:Expecting an element
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiErrorElement:Expecting an element
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiErrorElement:Expecting ']'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiErrorElement:Expecting ']'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace('\n ')
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
PsiErrorElement:Expecting an expression
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
+32
-31
@@ -35,49 +35,50 @@ JetFile: oldAnnotationsRecovery.kt
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiErrorElement:Expecting an element
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('inline')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('inline')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
BLOCK
|
||||
RETURN
|
||||
PsiElement(return)('return')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
RETURN
|
||||
PsiElement(return)('return')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiErrorElement:Expecting an element
|
||||
COLLECTION_LITERAL_EXPRESSION
|
||||
PsiElement(LBRACKET)('[')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('suppress')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
STRING_TEMPLATE
|
||||
PsiElement(OPEN_QUOTE)('"')
|
||||
LITERAL_STRING_TEMPLATE_ENTRY
|
||||
PsiElement(REGULAR_STRING_PART)('1')
|
||||
PsiElement(CLOSING_QUOTE)('"')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('suppress')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_ARGUMENT
|
||||
STRING_TEMPLATE
|
||||
PsiElement(OPEN_QUOTE)('"')
|
||||
LITERAL_STRING_TEMPLATE_ENTRY
|
||||
PsiElement(REGULAR_STRING_PART)('1')
|
||||
PsiElement(CLOSING_QUOTE)('"')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(PLUS)('+')
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
|
||||
Reference in New Issue
Block a user