Corrected parser: incomplete code should never cause brace disbalance

Fixed KT-7539 fq name inserted when completing nested traits name

 #KT-7539
This commit is contained in:
Valentin Kipyatkov
2015-05-15 01:08:18 +03:00
parent c8b1dd6425
commit 60b0236101
66 changed files with 1335 additions and 402 deletions
@@ -101,7 +101,7 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
protected void errorWithRecovery(String message, TokenSet recoverySet) { protected void errorWithRecovery(String message, TokenSet recoverySet) {
IElementType tt = tt(); IElementType tt = tt();
if (recoverySet == null || recoverySet.contains(tt) if (recoverySet == null || recoverySet.contains(tt) || tt == LBRACE || tt == RBRACE
|| (recoverySet.contains(EOL_OR_SEMICOLON) || (recoverySet.contains(EOL_OR_SEMICOLON)
&& (eof() || tt == SEMICOLON || myBuilder.newlineBeforeCurrentToken()))) { && (eof() || tt == SEMICOLON || myBuilder.newlineBeforeCurrentToken()))) {
error(message); error(message);
@@ -258,6 +258,8 @@ import static org.jetbrains.kotlin.lexer.JetTokens.*;
} }
protected void errorUntil(String message, TokenSet tokenSet) { 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(); PsiBuilder.Marker error = mark();
skipUntil(tokenSet); skipUntil(tokenSet);
error.error(message); error.error(message);
@@ -137,7 +137,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
TokenSet.create(EOL_OR_SEMICOLON)); TokenSet.create(EOL_OR_SEMICOLON));
/*package*/ static final TokenSet EXPRESSION_FOLLOW = TokenSet.create( /*package*/ static final TokenSet EXPRESSION_FOLLOW = TokenSet.create(
SEMICOLON, ARROW, COMMA, RBRACE, RPAR, RBRACKET SEMICOLON, ARROW, COMMA, LBRACE, RBRACE, RPAR, RBRACKET
); );
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
@@ -887,7 +887,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance(); // ELSE_KEYWORD advance(); // ELSE_KEYWORD
if (!at(ARROW)) { if (!at(ARROW)) {
errorUntil("Expecting '->'", TokenSet.create(ARROW, errorUntil("Expecting '->'", TokenSet.create(ARROW, LBRACE,
RBRACE, EOL_OR_SEMICOLON)); RBRACE, EOL_OR_SEMICOLON));
} }
@@ -901,7 +901,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
parseExpressionPreferringBlocks(); parseExpressionPreferringBlocks();
} }
} }
else if (!atSet(WHEN_CONDITION_RECOVERY_SET)) { else if (!atSet(WHEN_CONDITION_RECOVERY_SET) && !at(LBRACE)) {
errorAndAdvance("Expecting '->'"); errorAndAdvance("Expecting '->'");
} }
} }
@@ -1554,7 +1554,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
PsiBuilder.Marker catchBlock = mark(); PsiBuilder.Marker catchBlock = mark();
advance(); // CATCH_KEYWORD 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)) { if (atSet(recoverySet)) {
error("Expecting exception variable declaration"); error("Expecting exception variable declaration");
} }
@@ -396,6 +396,11 @@ public class JetParsing extends AbstractJetParsing {
parseObject(NameParsingMode.REQUIRED, true); parseObject(NameParsingMode.REQUIRED, true);
declType = OBJECT_DECLARATION; declType = OBJECT_DECLARATION;
} }
else if (at(LBRACE)) {
error("Expecting a top level declaration");
parseBlock();
declType = FUN;
}
if (declType == null) { if (declType == null) {
errorAndAdvance("Expecting a top level declaration"); errorAndAdvance("Expecting a top level declaration");
@@ -688,7 +693,7 @@ public class JetParsing extends AbstractJetParsing {
beforeConstructorModifiers.drop(); beforeConstructorModifiers.drop();
if (at(LPAR)) { if (at(LPAR)) {
parseValueParameterList(false, /* typeRequired = */ true, TokenSet.create(LBRACE)); parseValueParameterList(false, /* typeRequired = */ true, TokenSet.create(LBRACE, RBRACE));
primaryConstructorMarker.done(PRIMARY_CONSTRUCTOR); primaryConstructorMarker.done(PRIMARY_CONSTRUCTOR);
} }
else if (hasConstructorModifiers) { else if (hasConstructorModifiers) {
@@ -929,7 +934,7 @@ public class JetParsing extends AbstractJetParsing {
IElementType declType = parseMemberDeclarationRest(detector.isEnumDetected(), detector.isDefaultDetected()); IElementType declType = parseMemberDeclarationRest(detector.isEnumDetected(), detector.isDefaultDetected());
if (declType == null) { if (declType == null) {
errorWithRecovery("Expecting member declaration", TokenSet.create(RBRACE)); errorWithRecovery("Expecting member declaration", TokenSet.EMPTY);
decl.drop(); decl.drop();
} }
else { else {
@@ -970,6 +975,11 @@ public class JetParsing extends AbstractJetParsing {
parseSecondaryConstructor(); parseSecondaryConstructor();
declType = SECONDARY_CONSTRUCTOR; declType = SECONDARY_CONSTRUCTOR;
} }
else if (at(LBRACE)) {
error("Expecting member declaration");
parseBlock();
declType = FUN;
}
return declType; return declType;
} }
@@ -1194,7 +1204,7 @@ public class JetParsing extends AbstractJetParsing {
} }
if (!atSet(EOL_OR_SEMICOLON, RBRACE)) { if (!atSet(EOL_OR_SEMICOLON, RBRACE)) {
if (getLastToken() != SEMICOLON) { 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 { else {
@@ -1308,7 +1318,7 @@ public class JetParsing extends AbstractJetParsing {
setterParameter.done(VALUE_PARAMETER); setterParameter.done(VALUE_PARAMETER);
parameterList.done(VALUE_PARAMETER_LIST); 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)); expect(RPAR, "Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ));
myBuilder.restoreNewlinesState(); myBuilder.restoreNewlinesState();
@@ -1348,7 +1358,7 @@ public class JetParsing extends AbstractJetParsing {
boolean typeParameterListOccurred = false; boolean typeParameterListOccurred = false;
if (at(LT)) { if (at(LT)) {
parseTypeParameterList(TokenSet.create(LBRACKET, LBRACE, LPAR)); parseTypeParameterList(TokenSet.create(LBRACKET, LBRACE, RBRACE, LPAR));
typeParameterListOccurred = true; typeParameterListOccurred = true;
} }
@@ -1362,7 +1372,7 @@ public class JetParsing extends AbstractJetParsing {
myBuilder.restoreJoiningComplexTokensState(); myBuilder.restoreJoiningComplexTokensState();
TokenSet valueParametersFollow = TokenSet.create(EQ, LBRACE, SEMICOLON, RPAR); TokenSet valueParametersFollow = TokenSet.create(EQ, LBRACE, RBRACE, SEMICOLON, RPAR);
if (at(LT)) { if (at(LT)) {
PsiBuilder.Marker error = mark(); PsiBuilder.Marker error = mark();
@@ -1473,11 +1483,12 @@ public class JetParsing extends AbstractJetParsing {
private void parseFunctionOrPropertyName(boolean receiverFound, String title, TokenSet nameFollow, boolean nameRequired) { private void parseFunctionOrPropertyName(boolean receiverFound, String title, TokenSet nameFollow, boolean nameRequired) {
if (nameRequired && atSet(nameFollow)) return; // no name if (nameRequired && atSet(nameFollow)) return; // no name
TokenSet recoverySet = TokenSet.orSet(nameFollow, TokenSet.create(LBRACE, RBRACE));
if (!receiverFound) { if (!receiverFound) {
expect(IDENTIFIER, "Expecting " + title + " name or receiver type", nameFollow); expect(IDENTIFIER, "Expecting " + title + " name or receiver type", recoverySet);
} }
else { else {
expect(IDENTIFIER, "Expecting " + title + " name", nameFollow); expect(IDENTIFIER, "Expecting " + title + " name", recoverySet);
} }
} }
@@ -1497,7 +1508,7 @@ public class JetParsing extends AbstractJetParsing {
consumeIf(SEMICOLON); consumeIf(SEMICOLON);
} }
else { else {
errorAndAdvance("Expecting function body"); error("Expecting function body");
} }
} }
@@ -1652,14 +1663,14 @@ public class JetParsing extends AbstractJetParsing {
parseAnnotations(ONLY_ESCAPED_REGULAR_ANNOTATIONS); parseAnnotations(ONLY_ESCAPED_REGULAR_ANNOTATIONS);
PsiBuilder.Marker reference = mark(); 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); reference.done(REFERENCE_EXPRESSION);
} }
else { else {
reference.drop(); 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(); parseTypeRef();
@@ -1834,7 +1845,7 @@ public class JetParsing extends AbstractJetParsing {
if (at(PACKAGE_KEYWORD)) { if (at(PACKAGE_KEYWORD)) {
advance(); // PACKAGE_KEYWORD advance(); // PACKAGE_KEYWORD
expect(DOT, "Expecting '.'", TokenSet.create(IDENTIFIER)); expect(DOT, "Expecting '.'", TokenSet.create(IDENTIFIER, LBRACE, RBRACE));
} }
PsiBuilder.Marker reference = mark(); PsiBuilder.Marker reference = mark();
@@ -26,7 +26,6 @@ import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.lexer.JetTokens; 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.KotlinFunctionStub;
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage; import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage;
@@ -78,11 +77,10 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<KotlinFuncti
return getEqualsToken() == null; return getEqualsToken() == null;
} }
@NotNull @Nullable
@IfNotParsed // "function" with no "fun" keyword is created by parser for "{...}" on top-level or in class body
public PsiElement getFunKeyword() { public PsiElement getFunKeyword() {
PsiElement element = findChildByType(JetTokens.FUN_KEYWORD); return findChildByType(JetTokens.FUN_KEYWORD);
assert element != null : "'fun' must be present: " + PsiUtilPackage.getElementTextWithContext(this);
return element;
} }
@Override @Override
@@ -1 +1 @@
class A : (categoryName: <!SYNTAX!><!>) <!SYNTAX!>{<!SYNTAX!><!><!> class A : (categoryName: <!SYNTAX!><!>)<!SYNTAX!><!> <!SYNTAX!><!>{<!SYNTAX!><!>
+54 -49
View File
@@ -250,58 +250,63 @@ JetFile: DefaultKeyword.kt
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
OBJECT_DECLARATION_NAME OBJECT_DECLARATION_NAME
PsiErrorElement:Name expected PsiErrorElement:Name expected
PsiElement(RBRACE)('}') <empty list>
PsiWhiteSpace('\n\n') PsiElement(RBRACE)('}')
CLASS PsiWhiteSpace('\n\n')
PsiElement(class)('class') CLASS
PsiWhiteSpace(' ') PsiElement(class)('class')
PsiElement(IDENTIFIER)('A') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('A')
CLASS_BODY PsiWhiteSpace(' ')
PsiElement(LBRACE)('{') CLASS_BODY
PsiWhiteSpace('\n ') PsiElement(LBRACE)('{')
OBJECT_DECLARATION PsiWhiteSpace('\n ')
MODIFIER_LIST OBJECT_DECLARATION
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')
MODIFIER_LIST MODIFIER_LIST
PsiElement(companion)('companion') PsiElement(companion)('companion')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiErrorElement:Name expected
<empty list>
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(' ') 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
<empty list>
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
<empty list>
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
@@ -504,12 +504,9 @@ JetFile: FunctionLiterals_ERR.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
VALUE_PARAMETER VALUE_PARAMETER
PsiErrorElement:Expecting parameter name PsiErrorElement:Expecting parameter name
PsiElement(RBRACE)('}') <empty list>
PsiErrorElement:Expecting '->' or ','
<empty list>
PsiWhiteSpace('\n')
BLOCK BLOCK
<empty list> <empty list>
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiErrorElement:Expecting '}' PsiWhiteSpace('\n')
<empty list> PsiElement(RBRACE)('}')
+13 -9
View File
@@ -43,11 +43,13 @@ JetFile: ParameterType_ERR.kt
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration FUN
PsiElement(LBRACE)('{') PsiErrorElement:Expecting a top level declaration
PsiWhiteSpace(' ') <empty list>
PsiErrorElement:Expecting a top level declaration BLOCK
PsiElement(RBRACE)('}') PsiElement(LBRACE)('{')
PsiWhiteSpace(' ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
FUN FUN
PsiElement(fun)('fun') PsiElement(fun)('fun')
@@ -74,10 +76,12 @@ JetFile: ParameterType_ERR.kt
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration FUN
PsiElement(LBRACE)('{') PsiErrorElement:Expecting a top level declaration
PsiErrorElement:Expecting a top level declaration <empty list>
PsiElement(RBRACE)('}') BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
FUN FUN
PsiElement(fun)('fun') PsiElement(fun)('fun')
@@ -259,7 +259,11 @@ JetFile: PropertiesFollowedByInitializers.kt
PsiElement(RBRACKET)(']') PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(abstract)('abstract') PsiElement(abstract)('abstract')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUN
PsiErrorElement:Expecting member declaration
<empty list>
BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
+22 -8
View File
@@ -6,8 +6,13 @@ JetFile: Properties_ERR.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting property name or receiver type PsiErrorElement:Expecting property name or receiver type
PsiElement(MINUS)('-') PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
<empty list>
PsiWhiteSpace(' ')
FUN
PsiErrorElement:Expecting a top level declaration
<empty list>
BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
@@ -15,8 +20,13 @@ JetFile: Properties_ERR.kt
PsiElement(var)('var') PsiElement(var)('var')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f') PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
<empty list>
PsiWhiteSpace(' ')
FUN
PsiErrorElement:Expecting a top level declaration
<empty list>
BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
@@ -159,10 +169,12 @@ JetFile: Properties_ERR.kt
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration FUN
PsiElement(LBRACE)('{') PsiErrorElement:Expecting a top level declaration
PsiErrorElement:Expecting a top level declaration <empty list>
PsiElement(RBRACE)('}') BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
@@ -209,6 +221,8 @@ JetFile: Properties_ERR.kt
PsiElement(get)('get') PsiElement(get)('get')
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting function body PsiErrorElement:Expecting function body
PsiElement(MINUS)('-') <empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected
PsiElement(MINUS)('-')
+100 -98
View File
@@ -18,114 +18,116 @@ JetFile: RootPackage.kt
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(package)('package') PsiElement(package)('package')
PsiWhiteSpace(' ') 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 FUN
PsiElement(fun)('fun') MODIFIER_LIST
PsiWhiteSpace(' ') ANNOTATION_ENTRY
PsiElement(IDENTIFIER)('foo') CONSTRUCTOR_CALLEE
VALUE_PARAMETER_LIST TYPE_REFERENCE
PsiElement(LPAR)('(') USER_TYPE
PsiElement(RPAR)(')') USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiErrorElement:Expecting a top level declaration
<empty list>
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
DOT_QUALIFIED_EXPRESSION FUN
DOT_QUALIFIED_EXPRESSION PsiElement(fun)('fun')
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(' ') PsiWhiteSpace(' ')
PsiElement(LPAR)('(') PsiElement(IDENTIFIER)('foo')
REFERENCE_EXPRESSION VALUE_PARAMETER_LIST
PsiElement(IDENTIFIER)('e') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(LBRACE)('{') BLOCK
PsiWhiteSpace('\n ') PsiElement(LBRACE)('{')
WHEN_ENTRY PsiWhiteSpace('\n ')
WHEN_CONDITION_IS_PATTERN DOT_QUALIFIED_EXPRESSION
PsiElement(is)('is') DOT_QUALIFIED_EXPRESSION
PsiWhiteSpace(' ') DOT_QUALIFIED_EXPRESSION
TYPE_REFERENCE ROOT_PACKAGE
USER_TYPE PsiElement(package)('package')
USER_TYPE
USER_TYPE
PsiElement(package)('package')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.') PsiElement(DOT)('.')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('X') PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST PsiElement(DOT)('.')
PsiElement(LT)('<') REFERENCE_EXPRESSION
TYPE_PROJECTION PsiElement(IDENTIFIER)('bar')
TYPE_REFERENCE 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 USER_TYPE
PsiElement(package)('package') PsiElement(package)('package')
PsiElement(DOT)('.') PsiElement(DOT)('.')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Y') PsiElement(IDENTIFIER)('foo')
PsiElement(GT)('>') PsiElement(DOT)('.')
PsiWhiteSpace(' ') REFERENCE_EXPRESSION
PsiElement(ARROW)('->') PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ') PsiElement(DOT)('.')
BLOCK REFERENCE_EXPRESSION
PsiElement(LBRACE)('{') 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)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiErrorElement:Expecting a top level declaration
PsiElement(RBRACE)('}')
@@ -534,67 +534,69 @@ JetFile: FunctionsWithFunctionReceiversRecovery.kt
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
MODIFIER_LIST FUN
ANNOTATION_ENTRY MODIFIER_LIST
CONSTRUCTOR_CALLEE ANNOTATION_ENTRY
TYPE_REFERENCE CONSTRUCTOR_CALLEE
USER_TYPE 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 USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c') PsiElement(IDENTIFIER)('A')
TYPE_ARGUMENT_LIST TYPE_ARGUMENT_LIST
PsiElement(LT)('<') PsiElement(LT)('<')
TYPE_PROJECTION TYPE_PROJECTION
TYPE_REFERENCE TYPE_REFERENCE
USER_TYPE USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('t') PsiElement(IDENTIFIER)('X')
PsiElement(GT)('>') PsiElement(GT)('>')
PsiElement(DOT)('.') PsiErrorElement:Expecting a top level declaration
PsiWhiteSpace('\n\n') <empty list>
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)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ') 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)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiErrorElement:Expecting a top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
FUN FUN
PsiElement(fun)('fun') PsiElement(fun)('fun')
@@ -443,21 +443,23 @@ JetFile: PropertiesWithFunctionReceivers.kt
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
MODIFIER_LIST FUN
ANNOTATION_ENTRY MODIFIER_LIST
CONSTRUCTOR_CALLEE ANNOTATION_ENTRY
TYPE_REFERENCE CONSTRUCTOR_CALLEE
USER_TYPE TYPE_REFERENCE
REFERENCE_EXPRESSION USER_TYPE
PsiElement(IDENTIFIER)('dfget') REFERENCE_EXPRESSION
VALUE_ARGUMENT_LIST PsiElement(IDENTIFIER)('dfget')
PsiElement(LPAR)('(') VALUE_ARGUMENT_LIST
PsiElement(RPAR)(')') PsiElement(LPAR)('(')
PsiWhiteSpace(' ') PsiElement(RPAR)(')')
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(LBRACE)('{') <empty list>
PsiErrorElement:Expecting a top level declaration PsiWhiteSpace(' ')
PsiElement(RBRACE)('}') BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
@@ -518,18 +520,20 @@ JetFile: PropertiesWithFunctionReceivers.kt
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
MODIFIER_LIST FUN
ANNOTATION_ENTRY MODIFIER_LIST
CONSTRUCTOR_CALLEE ANNOTATION_ENTRY
TYPE_REFERENCE CONSTRUCTOR_CALLEE
USER_TYPE TYPE_REFERENCE
REFERENCE_EXPRESSION USER_TYPE
PsiElement(IDENTIFIER)('set') REFERENCE_EXPRESSION
VALUE_ARGUMENT_LIST PsiElement(IDENTIFIER)('set')
PsiElement(LPAR)('(') VALUE_ARGUMENT_LIST
PsiElement(RPAR)(')') PsiElement(LPAR)('(')
PsiWhiteSpace(' ') PsiElement(RPAR)(')')
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(LBRACE)('{') <empty list>
PsiErrorElement:Expecting a top level declaration PsiWhiteSpace(' ')
PsiElement(RBRACE)('}') BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -29,7 +29,11 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt
PsiElement(LT)('<') PsiElement(LT)('<')
PsiElement(IDENTIFIER)('P') PsiElement(IDENTIFIER)('P')
PsiElement(GT)('>') PsiElement(GT)('>')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUN
PsiErrorElement:Expecting a top level declaration
<empty list>
BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
@@ -258,8 +262,13 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
<empty list>
PsiWhiteSpace(' ')
FUN
PsiErrorElement:Expecting a top level declaration
<empty list>
BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
@@ -14,24 +14,26 @@ JetFile: functionTypes.kt
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(package)('package') PsiElement(package)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
MODIFIER_LIST FUN
ANNOTATION_ENTRY MODIFIER_LIST
CONSTRUCTOR_CALLEE ANNOTATION_ENTRY
TYPE_REFERENCE CONSTRUCTOR_CALLEE
USER_TYPE TYPE_REFERENCE
REFERENCE_EXPRESSION USER_TYPE
PsiElement(IDENTIFIER)('n') REFERENCE_EXPRESSION
PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('n')
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(LBRACE)('{') <empty list>
PsiWhiteSpace('\n ')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('B') BLOCK
PsiWhiteSpace('\n') PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a top level declaration PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}') CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('B')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
CLASS CLASS
MODIFIER_LIST MODIFIER_LIST
@@ -32,6 +32,5 @@ JetFile: namelessObjectAsEnumMember.kt
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
OBJECT_DECLARATION_NAME OBJECT_DECLARATION_NAME
PsiErrorElement:Name expected PsiErrorElement:Name expected
PsiElement(RBRACE)('}') <empty list>
PsiErrorElement:Expecting '}' to close enum class body PsiElement(RBRACE)('}')
<empty list>
@@ -5,32 +5,34 @@ JetFile: PackageBlockFirst.kt
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foobar') PsiElement(IDENTIFIER)('foobar')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration FUN
PsiElement(LBRACE)('{') PsiErrorElement:Expecting a top level declaration
PsiWhiteSpace('\n ') <empty list>
PROPERTY BLOCK
PsiElement(val)('val') PsiElement(LBRACE)('{')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
PsiElement(IDENTIFIER)('a') PROPERTY
PsiWhiteSpace(' ') PsiElement(val)('val')
PsiElement(EQ)('=') PsiWhiteSpace(' ')
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') PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n') PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration PsiElement(EQ)('=')
PsiElement(RBRACE)('}') 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)('}')
@@ -69,7 +69,9 @@ JetFile: WrongWordInParentheses.kt
PsiErrorElement:Expecting a top level declaration PsiErrorElement:Expecting a top level declaration
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting a top level declaration FUN
PsiElement(LBRACE)('{') PsiErrorElement:Expecting a top level declaration
PsiErrorElement:Expecting a top level declaration <empty list>
PsiElement(RBRACE)('}') BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -0,0 +1,8 @@
fun foo() {
try{
}
catch
}
fun bar(){}
@@ -0,0 +1,38 @@
JetFile: CatchKeywordRBrace.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
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)('}')
@@ -0,0 +1,5 @@
}
class C
fun bar(){}
@@ -0,0 +1,21 @@
JetFile: CloseBraceAtTopLevel.kt
PACKAGE_DIRECTIVE
<empty list>
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)('}')
@@ -0,0 +1,5 @@
fun foo() {
if
}
fun bar(){}
@@ -0,0 +1,34 @@
JetFile: IfKeywordRBrace.kt
PACKAGE_DIRECTIVE
<empty list>
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 '(...)'
<empty list>
PsiWhiteSpace('\n')
THEN
PsiErrorElement:Expecting an expression
<empty list>
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)('}')
@@ -0,0 +1,5 @@
class C {
val v: Int get(
}
class D
@@ -0,0 +1,36 @@
JetFile: IncompleteAccessor1.kt
PACKAGE_DIRECTIVE
<empty list>
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 ')'
<empty list>
PsiErrorElement:Expecting ')'
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('D')
@@ -0,0 +1,5 @@
class C {
val v: Int get()
}
class D
@@ -0,0 +1,35 @@
JetFile: IncompleteAccessor2.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('D')
@@ -0,0 +1,5 @@
class Outer {
class Inner(
}
class Next
@@ -0,0 +1,27 @@
JetFile: IncompleteClassDeclaration.kt
PACKAGE_DIRECTIVE
<empty list>
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 ')'
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,5 @@
class Outer {
class Inner<T
}
class Next
@@ -0,0 +1,28 @@
JetFile: IncompleteClassTypeParameters.kt
PACKAGE_DIRECTIVE
<empty list>
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 '>'
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,5 @@
fun foo() {
for(
}
fun bar(){}
@@ -0,0 +1,35 @@
JetFile: IncompleteForRBrace.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
BODY
<empty list>
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)('}')
@@ -0,0 +1,5 @@
fun {
x()
}
fun bar(){}
@@ -0,0 +1,30 @@
JetFile: IncompleteFun.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiErrorElement:Expecting function name or receiver type
<empty list>
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)('}')
@@ -0,0 +1,5 @@
class Outer {
fun foo(
}
class Next
@@ -0,0 +1,26 @@
JetFile: IncompleteFunDeclaration.kt
PACKAGE_DIRECTIVE
<empty list>
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 ')'
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,5 @@
class Outer {
fun <T
}
class Next
@@ -0,0 +1,27 @@
JetFile: IncompleteFunTypeParameters.kt
PACKAGE_DIRECTIVE
<empty list>
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 '>'
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,5 @@
class Outer {
fun <in
}
class Next
@@ -0,0 +1,28 @@
JetFile: IncompleteTypeParameters.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,8 @@
fun foo() {
val v: package
}
fun bar() {
}
@@ -0,0 +1,40 @@
JetFile: IncompleteTypeRefWithPackageKeyword.kt
PACKAGE_DIRECTIVE
<empty list>
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 '.'
<empty list>
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)('}')
@@ -0,0 +1,7 @@
class C {
val <T
}
class D
@@ -0,0 +1,27 @@
JetFile: IncompleteValTypeParameters.kt
PACKAGE_DIRECTIVE
<empty list>
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 '>'
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('D')
@@ -0,0 +1,9 @@
class C {
fun foo() {
when {
1 -> foo()
else { doIt() }
}
fun bar(){}
}}
@@ -0,0 +1,79 @@
JetFile: IncompleteWhenElse.kt
PACKAGE_DIRECTIVE
<empty list>
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 '->'
<empty list>
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 '->'
<empty list>
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)('}')
@@ -0,0 +1,5 @@
class Outer {
class Inner<T> where
}
class Next
@@ -0,0 +1,35 @@
JetFile: IncompleteWhere.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
TYPE_REFERENCE
<empty list>
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,5 @@
class Outer {
class Inner<T> where T
}
class Next
@@ -0,0 +1,39 @@
JetFile: IncompleteWhere2.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
PsiWhiteSpace('\n')
TYPE_REFERENCE
PsiErrorElement:Type expected
<empty list>
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Next')
@@ -0,0 +1,7 @@
class C {
val prop: XX$<caret> = run {
}
interface I
}
@@ -0,0 +1,45 @@
JetFile: InvalidCharAfterPropertyName.kt
PACKAGE_DIRECTIVE
<empty list>
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
<empty list>
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
CLASS
PsiElement(interface)('interface')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('I')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -1620,6 +1620,18 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
doParsingTest(fileName); 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") @TestMetadata("DoWhileWithEmptyCondition.kt")
public void testDoWhileWithEmptyCondition() throws Exception { public void testDoWhileWithEmptyCondition() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/DoWhileWithEmptyCondition.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/DoWhileWithEmptyCondition.kt");
@@ -1698,6 +1710,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
doParsingTest(fileName); 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") @TestMetadata("IfWithEmptyCondition.kt")
public void testIfWithEmptyCondition() throws Exception { public void testIfWithEmptyCondition() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IfWithEmptyCondition.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/IfWithEmptyCondition.kt");
@@ -1716,12 +1734,102 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
doParsingTest(fileName); 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") @TestMetadata("initRecovery.kt")
public void testInitRecovery() throws Exception { public void testInitRecovery() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/initRecovery.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/initRecovery.kt");
doParsingTest(fileName); 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") @TestMetadata("InvalidCharInSingleLineLambda.kt")
public void testInvalidCharInSingleLineLambda() throws Exception { public void testInvalidCharInSingleLineLambda() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.kt");
@@ -0,0 +1,12 @@
package a.b.c.d
class B {
public val mark: M<caret> = run {
}
interface Mark {
}
}
// EXIST: { itemText: "Mark", tailText: " (a.b.c.d.B)" }
@@ -0,0 +1,12 @@
package a.b.c.d
class B {
public val mark: M<caret> = run {
}
interface Mark {
}
}
// ELEMENT: Mark
@@ -0,0 +1,12 @@
package a.b.c.d
class B {
public val mark: Mark<caret> = run {
}
interface Mark {
}
}
// ELEMENT: Mark
@@ -643,6 +643,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
doTest(fileName); 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") @TestMetadata("JavaPackage.kt")
public void testJavaPackage() throws Exception { public void testJavaPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/JavaPackage.kt"); String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/JavaPackage.kt");
@@ -643,6 +643,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
doTest(fileName); 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") @TestMetadata("JavaPackage.kt")
public void testJavaPackage() throws Exception { public void testJavaPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/JavaPackage.kt"); String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/JavaPackage.kt");
@@ -95,6 +95,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
doTest(fileName); 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") @TestMetadata("NestedTypeArg.kt")
public void testNestedTypeArg() throws Exception { public void testNestedTypeArg() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/NestedTypeArg.kt"); String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/NestedTypeArg.kt");
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.intention.HighPriorityAction
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.util.TextRange import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.PsiModifier
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
@@ -79,7 +78,7 @@ public open class ChangeVisibilityModifierIntention protected(
private fun canAddVisibilityModifier(declaration: JetDeclaration): TextRange? { private fun canAddVisibilityModifier(declaration: JetDeclaration): TextRange? {
if (JetPsiUtil.isLocal(declaration)) return null if (JetPsiUtil.isLocal(declaration)) return null
return when (declaration) { return when (declaration) {
is JetNamedFunction -> declaration.getFunKeyword().getTextRange() is JetNamedFunction -> declaration.getFunKeyword()?.getTextRange()
is JetProperty -> declaration.getValOrVarNode().getTextRange() is JetProperty -> declaration.getValOrVarNode().getTextRange()
is JetClass -> declaration.getClassOrTraitKeyword()?.getTextRange() is JetClass -> declaration.getClassOrTraitKeyword()?.getTextRange()
is JetObjectDeclaration -> declaration.getObjectKeyword().getTextRange() is JetObjectDeclaration -> declaration.getObjectKeyword().getTextRange()
@@ -16,50 +16,40 @@
package org.jetbrains.kotlin.idea.intentions package org.jetbrains.kotlin.idea.intentions
import org.jetbrains.kotlin.psi.JetNamedFunction
import com.intellij.openapi.editor.Editor 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.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 com.intellij.openapi.util.Key
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.types.expressions.OperatorConventions import com.intellij.psi.*
import org.jetbrains.kotlin.name.Name import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.idea.util.supertypes
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.psi.JetProperty
import org.jetbrains.kotlin.asJava.namedUnwrappedElement 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.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
import org.jetbrains.kotlin.idea.core.refactoring.reportDeclarationConflict 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.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<JetNamedFunction>(javaClass(), "Convert function to property") { public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention<JetNamedFunction>(javaClass(), "Convert function to property") {
private var JetNamedFunction.typeFqNameToAdd: String? by UserDataProperty(Key.create("TYPE_FQ_NAME_TO_ADD")) private var JetNamedFunction.typeFqNameToAdd: String? by UserDataProperty(Key.create("TYPE_FQ_NAME_TO_ADD"))
@@ -71,7 +61,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention<JetN
): CallableRefactoring<FunctionDescriptor>(project, descriptor, context, getText()) { ): CallableRefactoring<FunctionDescriptor>(project, descriptor, context, getText()) {
private val elementsToShorten = ArrayList<JetElement>() private val elementsToShorten = ArrayList<JetElement>()
private fun convertJetFunction(originalFunction: JetNamedFunction, psiFactory: JetPsiFactory) { private fun convertFunction(originalFunction: JetNamedFunction, psiFactory: JetPsiFactory) {
val function = originalFunction.copy() as JetNamedFunction val function = originalFunction.copy() as JetNamedFunction
val propertySample = psiFactory.createProperty("val foo: Int get() = 1") val propertySample = psiFactory.createProperty("val foo: Int get() = 1")
@@ -81,7 +71,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention<JetN
originalFunction.typeFqNameToAdd?.let { function.setTypeReference(psiFactory.createType(it)) } originalFunction.typeFqNameToAdd?.let { function.setTypeReference(psiFactory.createType(it)) }
} }
function.getFunKeyword().replace(propertySample.getValOrVarNode().getPsi()) function.getFunKeyword()!!.replace(propertySample.getValOrVarNode().getPsi())
function.getValueParameterList()?.delete() function.getValueParameterList()?.delete()
val insertAfter = (function.getEqualsToken() ?: function.getBodyExpression()) val insertAfter = (function.getEqualsToken() ?: function.getBodyExpression())
?.siblings(forward = false, withItself = false) ?.siblings(forward = false, withItself = false)
@@ -172,7 +162,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention<JetN
callables.forEach { callables.forEach {
when (it) { when (it) {
is JetNamedFunction -> convertJetFunction(it, psiFactory) is JetNamedFunction -> convertFunction(it, psiFactory)
is PsiMethod -> it.setName(getterName) is PsiMethod -> it.setName(getterName)
} }
} }
@@ -17,42 +17,33 @@
package org.jetbrains.kotlin.idea.intentions package org.jetbrains.kotlin.idea.intentions
import com.intellij.openapi.editor.Editor 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 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 com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import com.intellij.psi.*
import org.jetbrains.kotlin.idea.references.JetReference import com.intellij.refactoring.util.RefactoringUIUtil
import com.intellij.psi.PsiMethod import com.intellij.util.containers.MultiMap
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 org.jetbrains.kotlin.asJava.namedUnwrappedElement 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.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively import org.jetbrains.kotlin.idea.core.refactoring.checkConflictsInteractively
import org.jetbrains.kotlin.idea.core.refactoring.reportDeclarationConflict 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.*
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<JetProperty>(javaClass(), "Convert property to function") { public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention<JetProperty>(javaClass(), "Convert property to function") {
private inner class Converter( private inner class Converter(
@@ -61,13 +52,13 @@ public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention<JetP
context: BindingContext context: BindingContext
): CallableRefactoring<CallableDescriptor>(project, descriptor, context, getText()) { ): CallableRefactoring<CallableDescriptor>(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 property = originalProperty.copy() as JetProperty;
val getter = property.getGetter(); val getter = property.getGetter();
val sampleFunction = psiFactory.createFunction("fun foo() {\n\n}"); 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()); property.addAfter(psiFactory.createParameterList("()"), property.getNameIdentifier());
if (property.getInitializer() == null) { if (property.getInitializer() == null) {
if (getter != null) { if (getter != null) {
@@ -164,7 +155,7 @@ public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention<JetP
callables.forEach { callables.forEach {
when (it) { when (it) {
is JetProperty -> convertJetProperty(it, kotlinPsiFactory) is JetProperty -> convertProperty(it, kotlinPsiFactory)
is PsiMethod -> it.setName(propertyName) is PsiMethod -> it.setName(propertyName)
} }
} }
@@ -1,5 +1,5 @@
fun main(args: Array<String>) { fun main(args: Array<String>) {
String.class String.class<EOLError descr="Name expected"></EOLError>
<error descr="Name expected">}</error><EOLError descr="Expecting '}'"></EOLError> }
// EA-56152: An attempt to build light class in checker to get diagnotics // EA-56152: An attempt to build light class in checker to get diagnotics
@@ -1,5 +1,5 @@
// "Add function body" "true" // "Add function body" "true"
package a { package a {
fun <caret>foo() { fun foo() {
} }
} }