Don't parse condition if there's no ( for if

This commit is contained in:
Nikolay Krasko
2014-06-23 20:20:24 +04:00
parent e06154c204
commit 2571797411
14 changed files with 286 additions and 7 deletions
@@ -0,0 +1,7 @@
fun test(): Boolean {
do {
} while()
return true
}
@@ -0,0 +1,43 @@
JetFile: DoWhileWithEmptyCondition.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('test')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Boolean')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
DO_WHILE
PsiElement(do)('do')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace(' ')
PsiElement(while)('while')
PsiElement(LPAR)('(')
CONDITION
PsiErrorElement:Expecting an expression
<empty list>
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,7 @@
fun test(): Boolean {
do {
} while
return true
}
@@ -0,0 +1,40 @@
JetFile: DoWhileWithoutLPar.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('test')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Boolean')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
DO_WHILE
PsiElement(do)('do')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace(' ')
PsiElement(while)('while')
PsiErrorElement:Expecting a condition in parentheses '(...)'
<empty list>
PsiWhiteSpace('\n\n ')
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,5 @@
fun test() {
if ()
return true
}
@@ -0,0 +1,31 @@
JetFile: IfWithEmptyCondition.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('test')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
IF
PsiElement(if)('if')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
PsiErrorElement:Expecting an expression
<empty list>
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
THEN
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,6 @@
fun test() {
if
if (other) {
}
}
@@ -0,0 +1,36 @@
JetFile: IfWithoutLPar.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('test')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
IF
PsiElement(if)('if')
PsiErrorElement:Expecting a condition in parentheses '(...)'
<empty list>
PsiWhiteSpace('\n\n ')
THEN
IF
PsiElement(if)('if')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('other')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
THEN
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,5 @@
fun test() {
while ()
return
}
@@ -0,0 +1,28 @@
JetFile: WhileWithEmptyCondition.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('test')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
WHILE
PsiElement(while)('while')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
PsiErrorElement:Expecting an expression
<empty list>
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
BODY
RETURN
PsiElement(return)('return')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,5 @@
fun test(): Boolean {
while
return true
}
@@ -0,0 +1,33 @@
JetFile: WhileWithoutLPar.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('test')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Boolean')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
WHILE
PsiElement(while)('while')
PsiErrorElement:Expecting a condition in parentheses '(...)'
<empty list>
PsiWhiteSpace('\n\n ')
BODY
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')