Merge pull request #795 from mcgee/KT-10124

#KT-10124 Fixed
This commit is contained in:
Dmitry Jemerov
2015-12-09 15:28:31 +01:00
5 changed files with 78 additions and 37 deletions
@@ -1573,7 +1573,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
private void parseFunctionOrPropertyName(boolean receiverFound, String title, TokenSet nameFollow, boolean nameRequired) {
if (nameRequired && atSet(nameFollow)) return; // no name
TokenSet recoverySet = TokenSet.orSet(nameFollow, TokenSet.create(LBRACE, RBRACE));
TokenSet recoverySet = TokenSet.orSet(nameFollow, TokenSet.create(LBRACE, RBRACE), TOP_LEVEL_DECLARATION_FIRST);
if (!receiverFound) {
expect(IDENTIFIER, "Expecting " + title + " name or receiver type", recoverySet);
}
@@ -294,46 +294,54 @@ JetFile: FunctionsWithFunctionReceiversRecovery.kt
PsiWhiteSpace('\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting function name or receiver type
PsiElement(fun)('fun')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace(' ')
MODIFIER_LIST
ANNOTATION
PsiElement(AT)('@')
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration
PsiElement(IDENTIFIER)('T')
PsiErrorElement:Expecting a top level declaration
PsiElement(LT)('<')
PsiErrorElement:Expecting a top level declaration
PsiElement(IDENTIFIER)('T')
PsiErrorElement:Expecting a top level declaration
PsiElement(GT)('>')
PsiErrorElement:Expecting a top level declaration
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
TYPE_REFERENCE
ANNOTATION
PsiElement(AT)('@')
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiElement(DOT)('.')
PsiErrorElement:Expecting a top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting a top level declaration
PsiElement(IDENTIFIER)('A')
PsiErrorElement:Expecting a top level declaration
PsiElement(LT)('<')
PsiErrorElement:Expecting a top level declaration
PsiElement(IDENTIFIER)('B')
PsiErrorElement:Expecting a top level declaration
PsiElement(GT)('>')
PsiErrorElement:Expecting a top level declaration
PsiElement(RPAR)(')')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiErrorElement:Parameter name expected
<empty list>
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('A')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>')
PsiElement(RPAR)(')')
PsiErrorElement:Expecting a top level declaration
PsiElement(DOT)('.')
PsiErrorElement:Expecting a top level declaration
+5
View File
@@ -0,0 +1,5 @@
fun
fun foo() {
}
+22
View File
@@ -0,0 +1,22 @@
JetFile: FunFun.kt
PACKAGE_DIRECTIVE
<empty list>
IMPORT_LIST
<empty list>
FUN
PsiElement(fun)('fun')
PsiErrorElement:Expecting function name or receiver type
<empty list>
PsiWhiteSpace('\n\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}')
@@ -2046,6 +2046,12 @@ public class ParsingTestGenerated extends AbstractParsingTest {
doParsingTest(fileName);
}
@TestMetadata("FunFun.kt")
public void testFunFun() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/recovery/FunFun.kt");
doParsingTest(fileName);
}
@TestMetadata("IfKeywordRBrace.kt")
public void testIfKeywordRBrace() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/recovery/IfKeywordRBrace.kt");