diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/AbstractJetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/AbstractJetParsing.java index b01f4347ada..02c6a62202d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/AbstractJetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/AbstractJetParsing.java @@ -101,7 +101,7 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*; protected void errorWithRecovery(String message, TokenSet recoverySet) { IElementType tt = tt(); - if (recoverySet == null || recoverySet.contains(tt) + if (recoverySet == null || recoverySet.contains(tt) || tt == LBRACE || tt == RBRACE || (recoverySet.contains(EOL_OR_SEMICOLON) && (eof() || tt == SEMICOLON || myBuilder.newlineBeforeCurrentToken()))) { error(message); @@ -258,6 +258,8 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*; } protected void errorUntil(String message, TokenSet tokenSet) { + assert tokenSet.contains(LBRACE) : "Cannot include LBRACE into error element!"; + assert tokenSet.contains(RBRACE) : "Cannot include RBRACE into error element!"; PsiBuilder.Marker error = mark(); skipUntil(tokenSet); error.error(message); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index 5504bab7cc9..3ff1a189452 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -137,7 +137,7 @@ public class JetExpressionParsing extends AbstractJetParsing { TokenSet.create(EOL_OR_SEMICOLON)); /*package*/ static final TokenSet EXPRESSION_FOLLOW = TokenSet.create( - SEMICOLON, ARROW, COMMA, RBRACE, RPAR, RBRACKET + SEMICOLON, ARROW, COMMA, LBRACE, RBRACE, RPAR, RBRACKET ); @SuppressWarnings({"UnusedDeclaration"}) @@ -887,7 +887,7 @@ public class JetExpressionParsing extends AbstractJetParsing { advance(); // ELSE_KEYWORD if (!at(ARROW)) { - errorUntil("Expecting '->'", TokenSet.create(ARROW, + errorUntil("Expecting '->'", TokenSet.create(ARROW, LBRACE, RBRACE, EOL_OR_SEMICOLON)); } @@ -901,7 +901,7 @@ public class JetExpressionParsing extends AbstractJetParsing { parseExpressionPreferringBlocks(); } } - else if (!atSet(WHEN_CONDITION_RECOVERY_SET)) { + else if (!atSet(WHEN_CONDITION_RECOVERY_SET) && !at(LBRACE)) { errorAndAdvance("Expecting '->'"); } } @@ -1554,7 +1554,7 @@ public class JetExpressionParsing extends AbstractJetParsing { PsiBuilder.Marker catchBlock = mark(); advance(); // CATCH_KEYWORD - TokenSet recoverySet = TokenSet.create(LBRACE, FINALLY_KEYWORD, CATCH_KEYWORD); + TokenSet recoverySet = TokenSet.create(LBRACE, RBRACE, FINALLY_KEYWORD, CATCH_KEYWORD); if (atSet(recoverySet)) { error("Expecting exception variable declaration"); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index dfcccf4a910..0762c4043d1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -396,6 +396,11 @@ public class JetParsing extends AbstractJetParsing { parseObject(NameParsingMode.REQUIRED, true); declType = OBJECT_DECLARATION; } + else if (at(LBRACE)) { + error("Expecting a top level declaration"); + parseBlock(); + declType = FUN; + } if (declType == null) { errorAndAdvance("Expecting a top level declaration"); @@ -688,7 +693,7 @@ public class JetParsing extends AbstractJetParsing { beforeConstructorModifiers.drop(); if (at(LPAR)) { - parseValueParameterList(false, /* typeRequired = */ true, TokenSet.create(LBRACE)); + parseValueParameterList(false, /* typeRequired = */ true, TokenSet.create(LBRACE, RBRACE)); primaryConstructorMarker.done(PRIMARY_CONSTRUCTOR); } else if (hasConstructorModifiers) { @@ -929,7 +934,7 @@ public class JetParsing extends AbstractJetParsing { IElementType declType = parseMemberDeclarationRest(detector.isEnumDetected(), detector.isDefaultDetected()); if (declType == null) { - errorWithRecovery("Expecting member declaration", TokenSet.create(RBRACE)); + errorWithRecovery("Expecting member declaration", TokenSet.EMPTY); decl.drop(); } else { @@ -970,6 +975,11 @@ public class JetParsing extends AbstractJetParsing { parseSecondaryConstructor(); declType = SECONDARY_CONSTRUCTOR; } + else if (at(LBRACE)) { + error("Expecting member declaration"); + parseBlock(); + declType = FUN; + } return declType; } @@ -1194,7 +1204,7 @@ public class JetParsing extends AbstractJetParsing { } if (!atSet(EOL_OR_SEMICOLON, RBRACE)) { if (getLastToken() != SEMICOLON) { - errorUntil("Property getter or setter expected", TokenSet.create(EOL_OR_SEMICOLON)); + errorUntil("Property getter or setter expected", TokenSet.create(EOL_OR_SEMICOLON, LBRACE, RBRACE)); } } else { @@ -1308,7 +1318,7 @@ public class JetParsing extends AbstractJetParsing { setterParameter.done(VALUE_PARAMETER); parameterList.done(VALUE_PARAMETER_LIST); } - if (!at(RPAR)) errorUntil("Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ, EOL_OR_SEMICOLON)); + if (!at(RPAR)) errorUntil("Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, RBRACE, EQ, EOL_OR_SEMICOLON)); expect(RPAR, "Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ)); myBuilder.restoreNewlinesState(); @@ -1348,7 +1358,7 @@ public class JetParsing extends AbstractJetParsing { boolean typeParameterListOccurred = false; if (at(LT)) { - parseTypeParameterList(TokenSet.create(LBRACKET, LBRACE, LPAR)); + parseTypeParameterList(TokenSet.create(LBRACKET, LBRACE, RBRACE, LPAR)); typeParameterListOccurred = true; } @@ -1362,7 +1372,7 @@ public class JetParsing extends AbstractJetParsing { myBuilder.restoreJoiningComplexTokensState(); - TokenSet valueParametersFollow = TokenSet.create(EQ, LBRACE, SEMICOLON, RPAR); + TokenSet valueParametersFollow = TokenSet.create(EQ, LBRACE, RBRACE, SEMICOLON, RPAR); if (at(LT)) { PsiBuilder.Marker error = mark(); @@ -1473,11 +1483,12 @@ public class JetParsing extends AbstractJetParsing { 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)); if (!receiverFound) { - expect(IDENTIFIER, "Expecting " + title + " name or receiver type", nameFollow); + expect(IDENTIFIER, "Expecting " + title + " name or receiver type", recoverySet); } else { - expect(IDENTIFIER, "Expecting " + title + " name", nameFollow); + expect(IDENTIFIER, "Expecting " + title + " name", recoverySet); } } @@ -1497,7 +1508,7 @@ public class JetParsing extends AbstractJetParsing { consumeIf(SEMICOLON); } else { - errorAndAdvance("Expecting function body"); + error("Expecting function body"); } } @@ -1652,14 +1663,14 @@ public class JetParsing extends AbstractJetParsing { parseAnnotations(ONLY_ESCAPED_REGULAR_ANNOTATIONS); PsiBuilder.Marker reference = mark(); - if (expect(IDENTIFIER, "Expecting type parameter name", TokenSet.orSet(TokenSet.create(COLON, COMMA), TYPE_REF_FIRST))) { + if (expect(IDENTIFIER, "Expecting type parameter name", TokenSet.orSet(TokenSet.create(COLON, COMMA, LBRACE, RBRACE), TYPE_REF_FIRST))) { reference.done(REFERENCE_EXPRESSION); } else { reference.drop(); } - expect(COLON, "Expecting ':' before the upper bound", TYPE_REF_FIRST); + expect(COLON, "Expecting ':' before the upper bound", TokenSet.orSet(TokenSet.create(LBRACE, RBRACE), TYPE_REF_FIRST)); parseTypeRef(); @@ -1834,7 +1845,7 @@ public class JetParsing extends AbstractJetParsing { if (at(PACKAGE_KEYWORD)) { advance(); // PACKAGE_KEYWORD - expect(DOT, "Expecting '.'", TokenSet.create(IDENTIFIER)); + expect(DOT, "Expecting '.'", TokenSet.create(IDENTIFIER, LBRACE, RBRACE)); } PsiBuilder.Marker reference = mark(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNamedFunction.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNamedFunction.java index 94245759a51..3066d933b73 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNamedFunction.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNamedFunction.java @@ -26,7 +26,6 @@ import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.lexer.JetTokens; -import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.psi.stubs.KotlinFunctionStub; import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage; @@ -78,11 +77,10 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub) { \ No newline at end of file +class A : (categoryName: ) { \ No newline at end of file diff --git a/compiler/testData/psi/DefaultKeyword.txt b/compiler/testData/psi/DefaultKeyword.txt index 098e5cdc5f6..78874d15df0 100644 --- a/compiler/testData/psi/DefaultKeyword.txt +++ b/compiler/testData/psi/DefaultKeyword.txt @@ -250,58 +250,63 @@ JetFile: DefaultKeyword.kt PsiWhiteSpace('\n') OBJECT_DECLARATION_NAME PsiErrorElement:Name expected - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n') - CLASS - PsiElement(class)('class') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('A') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - OBJECT_DECLARATION - MODIFIER_LIST - PsiElement(companion)('companion') - PsiWhiteSpace(' ') - PsiElement(public)('public') - PsiWhiteSpace(' ') - PsiElement(final)('final') - PsiWhiteSpace(' ') - PsiElement(object)('object') - PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n') - CLASS - PsiComment(EOL_COMMENT)('//should be error') - PsiWhiteSpace('\n') + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + OBJECT_DECLARATION MODIFIER_LIST PsiElement(companion)('companion') - PsiWhiteSpace(' ') - PsiElement(class)('class') - PsiErrorElement:Name expected - - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n') - PROPERTY - PsiComment(EOL_COMMENT)('//should be error') - PsiWhiteSpace('\n') - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('t') - PsiWhiteSpace(' ') - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('companion') - PsiWhiteSpace(' ') - PsiErrorElement:Property getter or setter expected - PsiElement(object)('object') PsiWhiteSpace(' ') - PsiElement(LBRACE)('{') + PsiElement(public)('public') + PsiWhiteSpace(' ') + PsiElement(final)('final') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiComment(EOL_COMMENT)('//should be error') + PsiWhiteSpace('\n') + MODIFIER_LIST + PsiElement(companion)('companion') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiErrorElement:Name expected + + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiComment(EOL_COMMENT)('//should be error') + PsiWhiteSpace('\n') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('companion') + PsiWhiteSpace(' ') + PsiErrorElement:Property getter or setter expected + PsiElement(object)('object') + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/FunctionLiterals_ERR.txt b/compiler/testData/psi/FunctionLiterals_ERR.txt index 5ad088f2ec9..97cb3105bc8 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.txt +++ b/compiler/testData/psi/FunctionLiterals_ERR.txt @@ -504,12 +504,9 @@ JetFile: FunctionLiterals_ERR.kt PsiWhiteSpace(' ') VALUE_PARAMETER PsiErrorElement:Expecting parameter name - PsiElement(RBRACE)('}') - PsiErrorElement:Expecting '->' or ',' - - PsiWhiteSpace('\n') + BLOCK PsiElement(RBRACE)('}') - PsiErrorElement:Expecting '}' - \ No newline at end of file + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/ParameterType_ERR.txt b/compiler/testData/psi/ParameterType_ERR.txt index 42c0a87f6f5..438c16a43df 100644 --- a/compiler/testData/psi/ParameterType_ERR.txt +++ b/compiler/testData/psi/ParameterType_ERR.txt @@ -43,11 +43,13 @@ JetFile: ParameterType_ERR.kt PsiErrorElement:Expecting a top level declaration PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') FUN PsiElement(fun)('fun') @@ -74,10 +76,12 @@ JetFile: ParameterType_ERR.kt PsiErrorElement:Expecting a top level declaration PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n') FUN PsiElement(fun)('fun') diff --git a/compiler/testData/psi/PropertiesFollowedByInitializers.txt b/compiler/testData/psi/PropertiesFollowedByInitializers.txt index 792c527ef1d..c1afa79e3e9 100644 --- a/compiler/testData/psi/PropertiesFollowedByInitializers.txt +++ b/compiler/testData/psi/PropertiesFollowedByInitializers.txt @@ -259,7 +259,11 @@ JetFile: PropertiesFollowedByInitializers.kt PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(abstract)('abstract') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting member declaration + + BLOCK PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/Properties_ERR.txt b/compiler/testData/psi/Properties_ERR.txt index 0433355bb32..2580db6bea8 100644 --- a/compiler/testData/psi/Properties_ERR.txt +++ b/compiler/testData/psi/Properties_ERR.txt @@ -6,8 +6,13 @@ JetFile: Properties_ERR.kt PsiWhiteSpace(' ') PsiErrorElement:Expecting property name or receiver type PsiElement(MINUS)('-') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected + + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') @@ -15,8 +20,13 @@ JetFile: Properties_ERR.kt PsiElement(var)('var') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected + + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') @@ -159,10 +169,12 @@ JetFile: Properties_ERR.kt PsiErrorElement:Expecting a top level declaration PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') PsiErrorElement:Expecting a top level declaration PsiElement(LPAR)('(') @@ -209,6 +221,8 @@ JetFile: Properties_ERR.kt PsiElement(get)('get') PsiElement(LPAR)('(') PsiElement(RPAR)(')') - PsiWhiteSpace(' ') PsiErrorElement:Expecting function body - PsiElement(MINUS)('-') \ No newline at end of file + + PsiWhiteSpace(' ') + PsiErrorElement:Property getter or setter expected + PsiElement(MINUS)('-') \ No newline at end of file diff --git a/compiler/testData/psi/RootPackage.txt b/compiler/testData/psi/RootPackage.txt index 7014983f5bf..68f590482e9 100644 --- a/compiler/testData/psi/RootPackage.txt +++ b/compiler/testData/psi/RootPackage.txt @@ -18,114 +18,116 @@ JetFile: RootPackage.kt PsiErrorElement:Expecting a top level declaration PsiElement(package)('package') PsiWhiteSpace(' ') - MODIFIER_LIST - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') FUN - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('foo') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiErrorElement:Expecting a top level declaration + PsiWhiteSpace(' ') BLOCK PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - DOT_QUALIFIED_EXPRESSION - DOT_QUALIFIED_EXPRESSION - DOT_QUALIFIED_EXPRESSION - ROOT_PACKAGE - PsiElement(package)('package') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('X') - PsiWhiteSpace('\n ') - DOT_QUALIFIED_EXPRESSION - DOT_QUALIFIED_EXPRESSION - DOT_QUALIFIED_EXPRESSION - ROOT_PACKAGE - PsiElement(package)('package') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(DOT)('.') - CALL_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('X') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace('\n ') - WHEN - PsiElement(when)('when') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('e') - PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - WHEN_ENTRY - WHEN_CONDITION_IS_PATTERN - PsiElement(is)('is') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - USER_TYPE - USER_TYPE - PsiElement(package)('package') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + ROOT_PACKAGE + PsiElement(package)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('X') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('X') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + ROOT_PACKAGE + PsiElement(package)('package') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('X') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('e') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_IS_PATTERN + PsiElement(is)('is') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE USER_TYPE PsiElement(package)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Y') - PsiElement(GT)('>') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - BLOCK - PsiElement(LBRACE)('{') + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('X') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + PsiElement(package)('package') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Y') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') \ No newline at end of file + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceiversRecovery.txt b/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceiversRecovery.txt index 639d7859661..8f19285d139 100644 --- a/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceiversRecovery.txt +++ b/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceiversRecovery.txt @@ -534,67 +534,69 @@ JetFile: FunctionsWithFunctionReceiversRecovery.kt PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') - MODIFIER_LIST - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE + FUN + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('c') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('t') + PsiElement(GT)('>') + PsiElement(DOT)('.') + PsiWhiteSpace('\n\n') + PsiComment(EOL_COMMENT)('//-----------') + PsiWhiteSpace('\n') + PsiErrorElement:Expecting type name + PsiElement(class)('class') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') + PsiElement(IDENTIFIER)('A') TYPE_ARGUMENT_LIST PsiElement(LT)('<') TYPE_PROJECTION TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('t') + PsiElement(IDENTIFIER)('X') PsiElement(GT)('>') - PsiElement(DOT)('.') - PsiWhiteSpace('\n\n') - PsiComment(EOL_COMMENT)('//-----------') - PsiWhiteSpace('\n') - PsiErrorElement:Expecting type name - PsiElement(class)('class') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('X') - PsiElement(GT)('>') - PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - FUN - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('foo') - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('Y') - PsiElement(GT)('>') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') + PsiErrorElement:Expecting a top level declaration + PsiWhiteSpace(' ') BLOCK PsiElement(LBRACE)('{') PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('Y') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') PsiElement(RBRACE)('}') - PsiWhiteSpace('\n') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') FUN PsiElement(fun)('fun') diff --git a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt index c86632d926e..5a6bc4ce471 100644 --- a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt +++ b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt @@ -443,21 +443,23 @@ JetFile: PropertiesWithFunctionReceivers.kt PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') - MODIFIER_LIST - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('dfget') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') + FUN + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('dfget') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting a top level declaration + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') PROPERTY PsiElement(val)('val') @@ -518,18 +520,20 @@ JetFile: PropertiesWithFunctionReceivers.kt PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') - MODIFIER_LIST - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('set') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') \ No newline at end of file + FUN + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('set') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting a top level declaration + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt index b43625cbd3f..bdffb8ac0d9 100644 --- a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt +++ b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt @@ -29,7 +29,11 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt PsiElement(LT)('<') PsiElement(IDENTIFIER)('P') PsiElement(GT)('>') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK PsiElement(LBRACE)('{') PsiWhiteSpace(' ') PsiElement(RBRACE)('}') @@ -258,8 +262,13 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt PsiElement(RPAR)(')') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('foo') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected + + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/greatSyntacticShift/functionTypes.txt b/compiler/testData/psi/greatSyntacticShift/functionTypes.txt index e0a3938fc8c..b3db812c3dd 100644 --- a/compiler/testData/psi/greatSyntacticShift/functionTypes.txt +++ b/compiler/testData/psi/greatSyntacticShift/functionTypes.txt @@ -14,24 +14,26 @@ JetFile: functionTypes.kt PsiErrorElement:Expecting a top level declaration PsiElement(package)('package') PsiWhiteSpace(' ') - MODIFIER_LIST - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('n') - PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - CLASS - PsiElement(class)('class') + FUN + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('n') + PsiErrorElement:Expecting a top level declaration + PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('B') - PsiWhiteSpace('\n') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('B') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n') CLASS MODIFIER_LIST diff --git a/compiler/testData/psi/namelessObjectAsEnumMember.txt b/compiler/testData/psi/namelessObjectAsEnumMember.txt index db773842f92..761e69141db 100644 --- a/compiler/testData/psi/namelessObjectAsEnumMember.txt +++ b/compiler/testData/psi/namelessObjectAsEnumMember.txt @@ -32,6 +32,5 @@ JetFile: namelessObjectAsEnumMember.kt PsiWhiteSpace('\n') OBJECT_DECLARATION_NAME PsiErrorElement:Name expected - PsiElement(RBRACE)('}') - PsiErrorElement:Expecting '}' to close enum class body - \ No newline at end of file + + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/packages/PackageBlockFirst.txt b/compiler/testData/psi/packages/PackageBlockFirst.txt index 105026cdd32..e9dd55931a6 100644 --- a/compiler/testData/psi/packages/PackageBlockFirst.txt +++ b/compiler/testData/psi/packages/PackageBlockFirst.txt @@ -5,32 +5,34 @@ JetFile: PackageBlockFirst.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foobar') PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - PROPERTY - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - PsiWhiteSpace('\n ') - PROPERTY - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('b') - PsiWhiteSpace(' ') - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foobar') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') - PsiWhiteSpace('\n') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') \ No newline at end of file + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foobar') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt index ca3f5fc9b63..bed2825ad00 100644 --- a/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt +++ b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt @@ -69,7 +69,9 @@ JetFile: WrongWordInParentheses.kt PsiErrorElement:Expecting a top level declaration PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiErrorElement:Expecting a top level declaration - PsiElement(LBRACE)('{') - PsiErrorElement:Expecting a top level declaration - PsiElement(RBRACE)('}') \ No newline at end of file + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/CatchKeywordRBrace.kt b/compiler/testData/psi/recovery/CatchKeywordRBrace.kt new file mode 100644 index 00000000000..23a5976d139 --- /dev/null +++ b/compiler/testData/psi/recovery/CatchKeywordRBrace.kt @@ -0,0 +1,8 @@ +fun foo() { + try{ + + } + catch +} + +fun bar(){} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/CatchKeywordRBrace.txt b/compiler/testData/psi/recovery/CatchKeywordRBrace.txt new file mode 100644 index 00000000000..94638df8123 --- /dev/null +++ b/compiler/testData/psi/recovery/CatchKeywordRBrace.txt @@ -0,0 +1,38 @@ +JetFile: CatchKeywordRBrace.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + TRY + PsiElement(try)('try') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + CATCH + PsiElement(catch)('catch') + PsiErrorElement:Expecting exception variable declaration + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/CloseBraceAtTopLevel.kt b/compiler/testData/psi/recovery/CloseBraceAtTopLevel.kt new file mode 100644 index 00000000000..3048f9431ea --- /dev/null +++ b/compiler/testData/psi/recovery/CloseBraceAtTopLevel.kt @@ -0,0 +1,5 @@ +} + +class C + +fun bar(){} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/CloseBraceAtTopLevel.txt b/compiler/testData/psi/recovery/CloseBraceAtTopLevel.txt new file mode 100644 index 00000000000..b8a2b22ebf0 --- /dev/null +++ b/compiler/testData/psi/recovery/CloseBraceAtTopLevel.txt @@ -0,0 +1,21 @@ +JetFile: CloseBraceAtTopLevel.kt + PACKAGE_DIRECTIVE + + PsiErrorElement:Expecting a top level declaration + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('C') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IfKeywordRBrace.kt b/compiler/testData/psi/recovery/IfKeywordRBrace.kt new file mode 100644 index 00000000000..c5bed9cf8f6 --- /dev/null +++ b/compiler/testData/psi/recovery/IfKeywordRBrace.kt @@ -0,0 +1,5 @@ +fun foo() { + if +} + +fun bar(){} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IfKeywordRBrace.txt b/compiler/testData/psi/recovery/IfKeywordRBrace.txt new file mode 100644 index 00000000000..ea3b41ea3f4 --- /dev/null +++ b/compiler/testData/psi/recovery/IfKeywordRBrace.txt @@ -0,0 +1,34 @@ +JetFile: IfKeywordRBrace.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiErrorElement:Expecting a condition in parentheses '(...)' + + PsiWhiteSpace('\n') + THEN + PsiErrorElement:Expecting an expression + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteAccessor1.kt b/compiler/testData/psi/recovery/IncompleteAccessor1.kt new file mode 100644 index 00000000000..f6ab6ee6e6f --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteAccessor1.kt @@ -0,0 +1,5 @@ +class C { + val v: Int get( +} + +class D \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteAccessor1.txt b/compiler/testData/psi/recovery/IncompleteAccessor1.txt new file mode 100644 index 00000000000..f37d5037525 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteAccessor1.txt @@ -0,0 +1,36 @@ +JetFile: IncompleteAccessor1.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('C') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('v') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting ')' + + PsiErrorElement:Expecting ')' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('D') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteAccessor2.kt b/compiler/testData/psi/recovery/IncompleteAccessor2.kt new file mode 100644 index 00000000000..cb40c668684 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteAccessor2.kt @@ -0,0 +1,5 @@ +class C { + val v: Int get() +} + +class D \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteAccessor2.txt b/compiler/testData/psi/recovery/IncompleteAccessor2.txt new file mode 100644 index 00000000000..ce41fabc500 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteAccessor2.txt @@ -0,0 +1,35 @@ +JetFile: IncompleteAccessor2.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('C') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('v') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting function body + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('D') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteClassDeclaration.kt b/compiler/testData/psi/recovery/IncompleteClassDeclaration.kt new file mode 100644 index 00000000000..7c741e3ca58 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteClassDeclaration.kt @@ -0,0 +1,5 @@ +class Outer { + class Inner( +} + +class Next \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteClassDeclaration.txt b/compiler/testData/psi/recovery/IncompleteClassDeclaration.txt new file mode 100644 index 00000000000..d92f72890da --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteClassDeclaration.txt @@ -0,0 +1,27 @@ +JetFile: IncompleteClassDeclaration.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Inner') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteClassTypeParameters.kt b/compiler/testData/psi/recovery/IncompleteClassTypeParameters.kt new file mode 100644 index 00000000000..a7b8fee952d --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteClassTypeParameters.kt @@ -0,0 +1,5 @@ +class Outer { + class Inner + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Inner') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiErrorElement:Missing '>' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteForRBrace.kt b/compiler/testData/psi/recovery/IncompleteForRBrace.kt new file mode 100644 index 00000000000..6409cd77228 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteForRBrace.kt @@ -0,0 +1,5 @@ +fun foo() { + for( +} + +fun bar(){} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteForRBrace.txt b/compiler/testData/psi/recovery/IncompleteForRBrace.txt new file mode 100644 index 00000000000..b373cf66402 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteForRBrace.txt @@ -0,0 +1,35 @@ +JetFile: IncompleteForRBrace.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiElement(LPAR)('(') + PsiWhiteSpace('\n') + VALUE_PARAMETER + PsiErrorElement:Expecting a variable name + + BODY + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteFun.kt b/compiler/testData/psi/recovery/IncompleteFun.kt new file mode 100644 index 00000000000..186845fc5f5 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteFun.kt @@ -0,0 +1,5 @@ +fun { + x() +} + +fun bar(){} \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteFun.txt b/compiler/testData/psi/recovery/IncompleteFun.txt new file mode 100644 index 00000000000..704bb48336f --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteFun.txt @@ -0,0 +1,30 @@ +JetFile: IncompleteFun.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiErrorElement:Expecting function name or receiver type + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteFunDeclaration.kt b/compiler/testData/psi/recovery/IncompleteFunDeclaration.kt new file mode 100644 index 00000000000..6174e4f896f --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteFunDeclaration.kt @@ -0,0 +1,5 @@ +class Outer { + fun foo( +} + +class Next \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteFunDeclaration.txt b/compiler/testData/psi/recovery/IncompleteFunDeclaration.txt new file mode 100644 index 00000000000..849bf1f58fc --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteFunDeclaration.txt @@ -0,0 +1,26 @@ +JetFile: IncompleteFunDeclaration.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteFunTypeParameters.kt b/compiler/testData/psi/recovery/IncompleteFunTypeParameters.kt new file mode 100644 index 00000000000..5c52fb900c7 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteFunTypeParameters.kt @@ -0,0 +1,5 @@ +class Outer { + fun + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiErrorElement:Missing '>' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteTypeParameters.kt b/compiler/testData/psi/recovery/IncompleteTypeParameters.kt new file mode 100644 index 00000000000..1bdca56186a --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteTypeParameters.kt @@ -0,0 +1,5 @@ +class Outer { + fun + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiErrorElement:Type parameter name expected + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.kt b/compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.kt new file mode 100644 index 00000000000..e6e55ebdeb2 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.kt @@ -0,0 +1,8 @@ +fun foo() { + val v: package +} + +fun bar() { +} + + diff --git a/compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.txt b/compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.txt new file mode 100644 index 00000000000..bce9e7f37e5 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.txt @@ -0,0 +1,40 @@ +JetFile: IncompleteTypeRefWithPackageKeyword.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('v') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(package)('package') + PsiErrorElement:Expecting '.' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteValTypeParameters.kt b/compiler/testData/psi/recovery/IncompleteValTypeParameters.kt new file mode 100644 index 00000000000..5ea8eb854c6 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteValTypeParameters.kt @@ -0,0 +1,7 @@ +class C { + val + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('C') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiErrorElement:Missing '>' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('D') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteWhenElse.kt b/compiler/testData/psi/recovery/IncompleteWhenElse.kt new file mode 100644 index 00000000000..e58002a1472 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteWhenElse.kt @@ -0,0 +1,9 @@ +class C { + fun foo() { + when { + 1 -> foo() + else { doIt() } + } + + fun bar(){} +}} diff --git a/compiler/testData/psi/recovery/IncompleteWhenElse.txt b/compiler/testData/psi/recovery/IncompleteWhenElse.txt new file mode 100644 index 00000000000..98504513314 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteWhenElse.txt @@ -0,0 +1,79 @@ +JetFile: IncompleteWhenElse.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('C') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiErrorElement:Expecting '->' + + PsiWhiteSpace(' ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + BLOCK + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('doIt') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiErrorElement:Expecting '->' + + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteWhere.kt b/compiler/testData/psi/recovery/IncompleteWhere.kt new file mode 100644 index 00000000000..8c01d087231 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteWhere.kt @@ -0,0 +1,5 @@ +class Outer { + class Inner where +} + +class Next \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteWhere.txt b/compiler/testData/psi/recovery/IncompleteWhere.txt new file mode 100644 index 00000000000..c2f1ebddf20 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteWhere.txt @@ -0,0 +1,35 @@ +JetFile: IncompleteWhere.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Inner') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(where)('where') + PsiWhiteSpace('\n') + TYPE_CONSTRAINT_LIST + TYPE_CONSTRAINT + PsiErrorElement:Expecting type parameter name + + TYPE_REFERENCE + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteWhere2.kt b/compiler/testData/psi/recovery/IncompleteWhere2.kt new file mode 100644 index 00000000000..1fe1828070a --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteWhere2.kt @@ -0,0 +1,5 @@ +class Outer { + class Inner where T +} + +class Next \ No newline at end of file diff --git a/compiler/testData/psi/recovery/IncompleteWhere2.txt b/compiler/testData/psi/recovery/IncompleteWhere2.txt new file mode 100644 index 00000000000..1f5b804b963 --- /dev/null +++ b/compiler/testData/psi/recovery/IncompleteWhere2.txt @@ -0,0 +1,39 @@ +JetFile: IncompleteWhere2.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Outer') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Inner') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(where)('where') + PsiWhiteSpace(' ') + TYPE_CONSTRAINT_LIST + TYPE_CONSTRAINT + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiErrorElement:Expecting ':' before the upper bound + + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Next') \ No newline at end of file diff --git a/compiler/testData/psi/recovery/InvalidCharAfterPropertyName.kt b/compiler/testData/psi/recovery/InvalidCharAfterPropertyName.kt new file mode 100644 index 00000000000..e1c73d307a1 --- /dev/null +++ b/compiler/testData/psi/recovery/InvalidCharAfterPropertyName.kt @@ -0,0 +1,7 @@ +class C { + val prop: XX$ = run { + + } + + interface I +} diff --git a/compiler/testData/psi/recovery/InvalidCharAfterPropertyName.txt b/compiler/testData/psi/recovery/InvalidCharAfterPropertyName.txt new file mode 100644 index 00000000000..8ad39a9a8c9 --- /dev/null +++ b/compiler/testData/psi/recovery/InvalidCharAfterPropertyName.txt @@ -0,0 +1,45 @@ +JetFile: InvalidCharAfterPropertyName.kt + PACKAGE_DIRECTIVE + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('C') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('prop') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('XX') + PsiErrorElement:Property getter or setter expected + PsiElement(BAD_CHARACTER)('$') + PsiElement(LT)('<') + PsiElement(IDENTIFIER)('caret') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('run') + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting member declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CLASS + PsiElement(interface)('interface') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('I') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index 52a5a9470f3..936e3901fd9 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -1620,6 +1620,18 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("CatchKeywordRBrace.kt") + public void testCatchKeywordRBrace() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/CatchKeywordRBrace.kt"); + doParsingTest(fileName); + } + + @TestMetadata("CloseBraceAtTopLevel.kt") + public void testCloseBraceAtTopLevel() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/CloseBraceAtTopLevel.kt"); + doParsingTest(fileName); + } + @TestMetadata("DoWhileWithEmptyCondition.kt") public void testDoWhileWithEmptyCondition() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/DoWhileWithEmptyCondition.kt"); @@ -1698,6 +1710,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("IfKeywordRBrace.kt") + public void testIfKeywordRBrace() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IfKeywordRBrace.kt"); + doParsingTest(fileName); + } + @TestMetadata("IfWithEmptyCondition.kt") public void testIfWithEmptyCondition() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IfWithEmptyCondition.kt"); @@ -1716,12 +1734,102 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("IncompleteAccessor1.kt") + public void testIncompleteAccessor1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteAccessor1.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteAccessor2.kt") + public void testIncompleteAccessor2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteAccessor2.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteClassDeclaration.kt") + public void testIncompleteClassDeclaration() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteClassDeclaration.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteClassTypeParameters.kt") + public void testIncompleteClassTypeParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteClassTypeParameters.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteForRBrace.kt") + public void testIncompleteForRBrace() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteForRBrace.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteFun.kt") + public void testIncompleteFun() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteFun.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteFunDeclaration.kt") + public void testIncompleteFunDeclaration() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteFunDeclaration.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteFunTypeParameters.kt") + public void testIncompleteFunTypeParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteFunTypeParameters.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteTypeParameters.kt") + public void testIncompleteTypeParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteTypeParameters.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteTypeRefWithPackageKeyword.kt") + public void testIncompleteTypeRefWithPackageKeyword() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteTypeRefWithPackageKeyword.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteValTypeParameters.kt") + public void testIncompleteValTypeParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteValTypeParameters.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteWhenElse.kt") + public void testIncompleteWhenElse() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteWhenElse.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteWhere.kt") + public void testIncompleteWhere() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteWhere.kt"); + doParsingTest(fileName); + } + + @TestMetadata("IncompleteWhere2.kt") + public void testIncompleteWhere2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IncompleteWhere2.kt"); + doParsingTest(fileName); + } + @TestMetadata("initRecovery.kt") public void testInitRecovery() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/initRecovery.kt"); doParsingTest(fileName); } + @TestMetadata("InvalidCharAfterPropertyName.kt") + public void testInvalidCharAfterPropertyName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/InvalidCharAfterPropertyName.kt"); + doParsingTest(fileName); + } + @TestMetadata("InvalidCharInSingleLineLambda.kt") public void testInvalidCharInSingleLineLambda() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.kt"); diff --git a/idea/idea-completion/testData/basic/common/InterfaceNameBeforeRunBug.kt b/idea/idea-completion/testData/basic/common/InterfaceNameBeforeRunBug.kt new file mode 100644 index 00000000000..c99069d4477 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/InterfaceNameBeforeRunBug.kt @@ -0,0 +1,12 @@ +package a.b.c.d + +class B { + public val mark: M = run { + + } + + interface Mark { + } +} + +// EXIST: { itemText: "Mark", tailText: " (a.b.c.d.B)" } diff --git a/idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt b/idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt new file mode 100644 index 00000000000..a95241c6ef2 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt @@ -0,0 +1,12 @@ +package a.b.c.d + +class B { + public val mark: M = run { + + } + + interface Mark { + } +} + +// ELEMENT: Mark diff --git a/idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt.after b/idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt.after new file mode 100644 index 00000000000..2f3205bc5c0 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt.after @@ -0,0 +1,12 @@ +package a.b.c.d + +class B { + public val mark: Mark = run { + + } + + interface Mark { + } +} + +// ELEMENT: Mark diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index c378e68e72f..b136231c311 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -643,6 +643,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("InterfaceNameBeforeRunBug.kt") + public void testInterfaceNameBeforeRunBug() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InterfaceNameBeforeRunBug.kt"); + doTest(fileName); + } + @TestMetadata("JavaPackage.kt") public void testJavaPackage() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/JavaPackage.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index f1b0b50381c..551e6dc3be3 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -643,6 +643,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("InterfaceNameBeforeRunBug.kt") + public void testInterfaceNameBeforeRunBug() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InterfaceNameBeforeRunBug.kt"); + doTest(fileName); + } + @TestMetadata("JavaPackage.kt") public void testJavaPackage() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/JavaPackage.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java index d605f9b52f2..b9ed943b8db 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java @@ -95,6 +95,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } + @TestMetadata("InterfaceNameBeforeRunBug.kt") + public void testInterfaceNameBeforeRunBug() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/InterfaceNameBeforeRunBug.kt"); + doTest(fileName); + } + @TestMetadata("NestedTypeArg.kt") public void testNestedTypeArg() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/NestedTypeArg.kt"); diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt index 2b19b7b4c84..d72c1c55f22 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ChangeVisibilityModifierIntention.kt @@ -20,7 +20,6 @@ import com.intellij.codeInsight.intention.HighPriorityAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement -import com.intellij.psi.PsiModifier import org.jetbrains.kotlin.lexer.JetModifierKeywordToken import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* @@ -79,7 +78,7 @@ public open class ChangeVisibilityModifierIntention protected( private fun canAddVisibilityModifier(declaration: JetDeclaration): TextRange? { if (JetPsiUtil.isLocal(declaration)) return null return when (declaration) { - is JetNamedFunction -> declaration.getFunKeyword().getTextRange() + is JetNamedFunction -> declaration.getFunKeyword()?.getTextRange() is JetProperty -> declaration.getValOrVarNode().getTextRange() is JetClass -> declaration.getClassOrTraitKeyword()?.getTextRange() is JetObjectDeclaration -> declaration.getObjectKeyword().getTextRange() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt index e5c2441e839..9797aa76278 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt @@ -16,50 +16,40 @@ package org.jetbrains.kotlin.idea.intentions -import org.jetbrains.kotlin.psi.JetNamedFunction import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring -import org.jetbrains.kotlin.idea.refactoring.getAffectedCallables -import com.intellij.util.containers.MultiMap -import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper -import com.intellij.psi.PsiNamedElement -import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget -import org.jetbrains.kotlin.idea.search.usagesSearch.search -import org.jetbrains.kotlin.idea.references.JetSimpleNameReference -import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch -import org.jetbrains.kotlin.psi.JetCallElement -import java.util.ArrayList -import com.intellij.openapi.util.text.StringUtil -import org.jetbrains.kotlin.psi.JetPsiFactory -import org.jetbrains.kotlin.idea.util.application.executeWriteCommand -import com.intellij.psi.PsiMethod -import org.jetbrains.kotlin.codegen.PropertyCodegen import com.intellij.openapi.project.Project -import com.intellij.psi.PsiWhiteSpace -import org.jetbrains.kotlin.psi.psiUtil.siblings -import com.intellij.psi.PsiReference -import org.jetbrains.kotlin.psi.psiUtil.isAncestor -import org.jetbrains.kotlin.psi.JetElement -import org.jetbrains.kotlin.psi.UserDataProperty import com.intellij.openapi.util.Key -import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor -import org.jetbrains.kotlin.types.expressions.OperatorConventions -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.idea.util.supertypes -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import org.jetbrains.kotlin.psi.JetProperty +import com.intellij.openapi.util.text.StringUtil +import com.intellij.psi.* +import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.asJava.namedUnwrappedElement -import org.jetbrains.kotlin.idea.refactoring.getContainingScope +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.codegen.PropertyCodegen +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively import org.jetbrains.kotlin.idea.core.refactoring.reportDeclarationConflict +import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring +import org.jetbrains.kotlin.idea.refactoring.getAffectedCallables +import org.jetbrains.kotlin.idea.refactoring.getContainingScope +import org.jetbrains.kotlin.idea.references.JetSimpleNameReference +import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper +import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget +import org.jetbrains.kotlin.idea.search.usagesSearch.search +import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.util.ShortenReferences +import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.idea.util.supertypes +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch +import org.jetbrains.kotlin.psi.psiUtil.siblings +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.types.expressions.OperatorConventions +import java.util.ArrayList public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention(javaClass(), "Convert function to property") { private var JetNamedFunction.typeFqNameToAdd: String? by UserDataProperty(Key.create("TYPE_FQ_NAME_TO_ADD")) @@ -71,7 +61,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention(project, descriptor, context, getText()) { private val elementsToShorten = ArrayList() - private fun convertJetFunction(originalFunction: JetNamedFunction, psiFactory: JetPsiFactory) { + private fun convertFunction(originalFunction: JetNamedFunction, psiFactory: JetPsiFactory) { val function = originalFunction.copy() as JetNamedFunction val propertySample = psiFactory.createProperty("val foo: Int get() = 1") @@ -81,7 +71,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention convertJetFunction(it, psiFactory) + is JetNamedFunction -> convertFunction(it, psiFactory) is PsiMethod -> it.setName(getterName) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt index c6e25ad2167..af800bb0f1a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt @@ -17,42 +17,33 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.descriptors.CallableDescriptor import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring -import com.intellij.psi.PsiWhiteSpace -import org.jetbrains.kotlin.psi.psiUtil.siblings -import com.intellij.util.containers.MultiMap -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.idea.refactoring.getAffectedCallables -import java.util.ArrayList -import com.intellij.psi.PsiReference -import com.intellij.psi.PsiNamedElement -import com.intellij.refactoring.util.RefactoringUIUtil -import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper -import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget -import org.jetbrains.kotlin.idea.search.usagesSearch.search -import org.jetbrains.kotlin.idea.references.JetSimpleNameReference import com.intellij.openapi.util.text.StringUtil -import org.jetbrains.kotlin.resolve.calls.callUtil.getCall -import org.jetbrains.kotlin.idea.references.JetReference -import com.intellij.psi.PsiMethod -import com.intellij.psi.PsiField -import com.intellij.psi.PsiReferenceExpression -import com.intellij.psi.PsiElementFactory -import org.jetbrains.kotlin.idea.util.application.executeWriteCommand -import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import com.intellij.psi.PsiJavaReference -import org.jetbrains.kotlin.psi.psiUtil.isAncestor -import org.jetbrains.kotlin.codegen.PropertyCodegen +import com.intellij.psi.* +import com.intellij.refactoring.util.RefactoringUIUtil +import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.asJava.namedUnwrappedElement -import org.jetbrains.kotlin.idea.refactoring.getContainingScope +import org.jetbrains.kotlin.codegen.PropertyCodegen +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively import org.jetbrains.kotlin.idea.core.refactoring.reportDeclarationConflict +import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring +import org.jetbrains.kotlin.idea.refactoring.getAffectedCallables +import org.jetbrains.kotlin.idea.refactoring.getContainingScope +import org.jetbrains.kotlin.idea.references.JetReference +import org.jetbrains.kotlin.idea.references.JetSimpleNameReference +import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper +import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget +import org.jetbrains.kotlin.idea.search.usagesSearch.search +import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import org.jetbrains.kotlin.psi.psiUtil.siblings +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.callUtil.getCall +import java.util.ArrayList public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention(javaClass(), "Convert property to function") { private inner class Converter( @@ -61,13 +52,13 @@ public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention(project, descriptor, context, getText()) { - private fun convertJetProperty(originalProperty: JetProperty, psiFactory: JetPsiFactory) { + private fun convertProperty(originalProperty: JetProperty, psiFactory: JetPsiFactory) { val property = originalProperty.copy() as JetProperty; val getter = property.getGetter(); val sampleFunction = psiFactory.createFunction("fun foo() {\n\n}"); - property.getValOrVarNode().getPsi().replace(sampleFunction.getFunKeyword()); + property.getValOrVarNode().getPsi().replace(sampleFunction.getFunKeyword()!!); property.addAfter(psiFactory.createParameterList("()"), property.getNameIdentifier()); if (property.getInitializer() == null) { if (getter != null) { @@ -164,7 +155,7 @@ public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention convertJetProperty(it, kotlinPsiFactory) + is JetProperty -> convertProperty(it, kotlinPsiFactory) is PsiMethod -> it.setName(propertyName) } } diff --git a/idea/testData/checker/regression/BadParseForClass.kt b/idea/testData/checker/regression/BadParseForClass.kt index 992183ebeae..5ea57af0892 100644 --- a/idea/testData/checker/regression/BadParseForClass.kt +++ b/idea/testData/checker/regression/BadParseForClass.kt @@ -1,5 +1,5 @@ fun main(args: Array) { - String.class -} + String.class +} // EA-56152: An attempt to build light class in checker to get diagnotics \ No newline at end of file diff --git a/idea/testData/quickfix/abstract/nonMemberFunctionNoBody.kt.after b/idea/testData/quickfix/abstract/nonMemberFunctionNoBody.kt.after index f54348ace84..2ba629e72c6 100644 --- a/idea/testData/quickfix/abstract/nonMemberFunctionNoBody.kt.after +++ b/idea/testData/quickfix/abstract/nonMemberFunctionNoBody.kt.after @@ -1,5 +1,5 @@ // "Add function body" "true" package a { -fun foo() { -} + fun foo() { + } } \ No newline at end of file