Don't parse entries if left brace absent in 'when'
This commit is contained in:
@@ -780,13 +780,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
// Parse when block
|
// Parse when block
|
||||||
myBuilder.enableNewlines();
|
myBuilder.enableNewlines();
|
||||||
expect(LBRACE, "Expecting '{'");
|
if (expect(LBRACE, "Expecting '{'")) {
|
||||||
|
while (!eof() && !at(RBRACE)) {
|
||||||
|
parseWhenEntry();
|
||||||
|
}
|
||||||
|
|
||||||
while (!eof() && !at(RBRACE)) {
|
expect(RBRACE, "Expecting '}'");
|
||||||
parseWhenEntry();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(RBRACE, "Expecting '}'");
|
|
||||||
myBuilder.restoreNewlinesState();
|
myBuilder.restoreNewlinesState();
|
||||||
|
|
||||||
when.done(WHEN);
|
when.done(WHEN);
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
fun test(a: Any) {
|
fun test(a: Any) {
|
||||||
when (a)<!SYNTAX!><!>
|
when (a)<!SYNTAX!><!>
|
||||||
}<!SYNTAX!><!>
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun test() {
|
||||||
|
when
|
||||||
|
|
||||||
|
bar()
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
JetFile: WhenWithoutBraces.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 ')
|
||||||
|
WHEN
|
||||||
|
PsiElement(when)('when')
|
||||||
|
PsiErrorElement:Expecting '{'
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace('\n\n ')
|
||||||
|
CALL_EXPRESSION
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
VALUE_ARGUMENT_LIST
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
@@ -1015,6 +1015,11 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
|
|||||||
doParsingTest("compiler/testData/psi/recovery/ValueParameterNoTypeRecovery.kt");
|
doParsingTest("compiler/testData/psi/recovery/ValueParameterNoTypeRecovery.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhenWithoutBraces.kt")
|
||||||
|
public void testWhenWithoutBraces() throws Exception {
|
||||||
|
doParsingTest("compiler/testData/psi/recovery/WhenWithoutBraces.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WhileWithEmptyCondition.kt")
|
@TestMetadata("WhileWithEmptyCondition.kt")
|
||||||
public void testWhileWithEmptyCondition() throws Exception {
|
public void testWhileWithEmptyCondition() throws Exception {
|
||||||
doParsingTest("compiler/testData/psi/recovery/WhileWithEmptyCondition.kt");
|
doParsingTest("compiler/testData/psi/recovery/WhileWithEmptyCondition.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user