Extend recovery set when expecting property accessor

#KT-12987 Fixed
This commit is contained in:
Denis Zharkov
2016-07-07 16:42:04 +03:00
parent f1026935a0
commit 3aa1a56cb9
7 changed files with 78 additions and 36 deletions
@@ -1279,7 +1279,9 @@ public class KotlinParsing extends AbstractKotlinParsing {
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, LBRACE, RBRACE)); errorUntil(
"Property getter or setter expected",
TokenSet.orSet(DECLARATION_FIRST, TokenSet.create(EOL_OR_SEMICOLON, LBRACE, RBRACE)));
} }
} }
else { else {
@@ -10,4 +10,6 @@ abstract class A {
private val<!SYNTAX!><!> private val<!SYNTAX!><!>
fun foo3() { fun foo3() {
} }
private val private<!SYNTAX!><!> fun foo() {}
} }
@@ -5,7 +5,9 @@ public abstract class A {
private final val <no name provided>: [ERROR : No type, no body] private final val <no name provided>: [ERROR : No type, no body]
private final val <no name provided>: [ERROR : No type, no body] private final val <no name provided>: [ERROR : No type, no body]
private final val <no name provided>: [ERROR : No type, no body] private final val <no name provided>: [ERROR : No type, no body]
private final val private: [ERROR : No type, no body]
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Unit
private final fun foo1(): kotlin.Unit private final fun foo1(): kotlin.Unit
protected abstract fun foo2(): kotlin.Unit protected abstract fun foo2(): kotlin.Unit
public final fun foo3(): kotlin.Unit public final fun foo3(): kotlin.Unit
+7 -6
View File
@@ -293,14 +293,15 @@ JetFile: DefaultKeyword.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('companion') PsiElement(IDENTIFIER)('companion')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
PsiElement(object)('object')
PsiWhiteSpace(' ')
FUN
PsiErrorElement:Expecting a top level declaration
<empty list> <empty list>
BLOCK PsiWhiteSpace(' ')
OBJECT_DECLARATION
PsiElement(object)('object')
PsiErrorElement:Name expected
<empty list>
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
+19 -10
View File
@@ -384,10 +384,13 @@ JetFile: FunctionExpressions_ERR.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('public') PsiElement(IDENTIFIER)('public')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
PsiElement(fun)('fun') <empty list>
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
@@ -400,10 +403,13 @@ JetFile: FunctionExpressions_ERR.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('open') PsiElement(IDENTIFIER)('open')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
PsiElement(fun)('fun') <empty list>
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
@@ -416,10 +422,13 @@ JetFile: FunctionExpressions_ERR.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('final') PsiElement(IDENTIFIER)('final')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
PsiElement(fun)('fun') <empty list>
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
@@ -647,4 +656,4 @@ JetFile: FunctionExpressions_ERR.kt
PsiElement(IDENTIFIER)('V') PsiElement(IDENTIFIER)('V')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
+12 -6
View File
@@ -7,10 +7,16 @@ JetFile: TypealiasIsKeyword.kt
PsiElement(val)('val') PsiElement(val)('val')
PsiErrorElement:Expecting property name or receiver type PsiErrorElement:Expecting property name or receiver type
<empty list> <empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
PsiElement(typealias)('typealias') <empty list>
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') TYPEALIAS
PsiWhiteSpace(' ') PsiElement(typealias)('typealias')
PsiElement(INTEGER_LITERAL)('0') PsiErrorElement:Type name expected
<empty list>
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
TYPE_REFERENCE
PsiErrorElement:Type expected
PsiElement(INTEGER_LITERAL)('0')
@@ -278,21 +278,41 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt
PsiElement(val)('val') PsiElement(val)('val')
PsiErrorElement:Expecting property name or receiver type PsiErrorElement:Expecting property name or receiver type
<empty list> <empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected PsiErrorElement:Property getter or setter expected
PsiElement(val)('val') <empty list>
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(AT)('@') DESTRUCTURING_DECLARATION
PsiElement(IDENTIFIER)('a') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('T') PsiErrorElement:Receiver type is not allowed on a destructuring declaration
PsiElement(LT)('<') TYPE_REFERENCE
PsiElement(IDENTIFIER)('T') ANNOTATION_ENTRY
PsiElement(GT)('>') PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiErrorElement:Destructuring declarations are only allowed for local variables/values
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(IDENTIFIER)('A') DESTRUCTURING_DECLARATION_ENTRY
PsiElement(LT)('<') PsiElement(IDENTIFIER)('A')
PsiErrorElement:Expecting ')'
PsiElement(LT)('<')
PsiErrorElement:Property getter or setter expected
PsiElement(IDENTIFIER)('B') PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>') PsiElement(GT)('>')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
@@ -433,4 +453,4 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A') PsiElement(IDENTIFIER)('A')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('B') PsiElement(IDENTIFIER)('B')