Add val/var tokens in parameter name recovery set
Recovery after val/var everywhere beside value parameters works properly without this change #KT-7915 Fixed
This commit is contained in:
@@ -53,7 +53,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
private static final TokenSet CLASS_NAME_RECOVERY_SET = TokenSet.orSet(TokenSet.create(LT, LPAR, COLON, LBRACE),
|
||||
TOP_LEVEL_DECLARATION_FIRST);
|
||||
private static final TokenSet TYPE_PARAMETER_GT_RECOVERY_SET = TokenSet.create(WHERE_KEYWORD, LPAR, COLON, LBRACE, GT);
|
||||
private static final TokenSet PARAMETER_NAME_RECOVERY_SET = TokenSet.create(COLON, EQ, COMMA, RPAR);
|
||||
private static final TokenSet PARAMETER_NAME_RECOVERY_SET = TokenSet.create(COLON, EQ, COMMA, RPAR, VAL_KEYWORD, VAR_KEYWORD);
|
||||
private static final TokenSet PACKAGE_NAME_RECOVERY_SET = TokenSet.create(DOT, EOL_OR_SEMICOLON);
|
||||
private static final TokenSet IMPORT_RECOVERY_SET = TokenSet.create(AS_KEYWORD, DOT, EOL_OR_SEMICOLON);
|
||||
private static final TokenSet TYPE_REF_FIRST = TokenSet.create(LBRACKET, IDENTIFIER, LPAR, HASH, DYNAMIC_KEYWORD);
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// VAL
|
||||
class A(
|
||||
val<!SYNTAX!><!>
|
||||
val x: Int,
|
||||
val
|
||||
private<!SYNTAX!><!> val z: Int,
|
||||
val<!SYNTAX!><!>
|
||||
)
|
||||
|
||||
val<!SYNTAX!><!>
|
||||
fun foo() {}
|
||||
|
||||
class B {
|
||||
val<!SYNTAX!><!>
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
val<!SYNTAX!><!>
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
// VAR
|
||||
class C(
|
||||
var<!SYNTAX!><!>
|
||||
val x: Int,
|
||||
var
|
||||
private<!SYNTAX!><!> val z: Int,
|
||||
var<!SYNTAX!><!>
|
||||
)
|
||||
|
||||
var<!SYNTAX!><!>
|
||||
fun baz() {}
|
||||
|
||||
class D {
|
||||
var<!SYNTAX!><!>
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
var<!SYNTAX!><!>
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package
|
||||
|
||||
public val <no name provided>: [ERROR : No type, no body]
|
||||
public var <no name provided>: [ERROR : No type, no body]
|
||||
public fun baz(): kotlin.Unit
|
||||
public fun foo(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A(/*0*/ <no name provided>: [ERROR : Type annotation was missing for parameter <no name provided>], /*1*/ x: kotlin.Int, /*2*/ private: [ERROR : Type annotation was missing for parameter private], /*3*/ z: kotlin.Int, /*4*/ <no name provided>: [ERROR : Type annotation was missing for parameter <no name provided>])
|
||||
public final val <no name provided>: [ERROR : Annotation is absent]
|
||||
public final val <no name provided>: [ERROR : Annotation is absent]
|
||||
public final val private: [ERROR : Annotation is absent]
|
||||
public final val x: kotlin.Int
|
||||
public final val z: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
public final val <no name provided>: [ERROR : No type, no body]
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class C {
|
||||
public constructor C(/*0*/ <no name provided>: [ERROR : Type annotation was missing for parameter <no name provided>], /*1*/ x: kotlin.Int, /*2*/ private: [ERROR : Type annotation was missing for parameter private], /*3*/ z: kotlin.Int, /*4*/ <no name provided>: [ERROR : Type annotation was missing for parameter <no name provided>])
|
||||
public final var <no name provided>: [ERROR : Annotation is absent]
|
||||
public final var <no name provided>: [ERROR : Annotation is absent]
|
||||
public final var private: [ERROR : Annotation is absent]
|
||||
public final val x: kotlin.Int
|
||||
public final val z: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class D {
|
||||
public constructor D()
|
||||
public final var <no name provided>: [ERROR : No type, no body]
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// VAL
|
||||
class A(
|
||||
val
|
||||
val x: Int,
|
||||
val
|
||||
private val z: Int,
|
||||
val
|
||||
)
|
||||
|
||||
val
|
||||
fun foo() {}
|
||||
|
||||
class B {
|
||||
val
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
val
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
// VAR
|
||||
class C(
|
||||
var
|
||||
val x: Int,
|
||||
var
|
||||
private val z: Int,
|
||||
var
|
||||
)
|
||||
|
||||
var
|
||||
fun baz() {}
|
||||
|
||||
class D {
|
||||
var
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {
|
||||
var
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
JetFile: ValNoName.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
CLASS
|
||||
PsiComment(EOL_COMMENT)('// VAL')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('A')
|
||||
PRIMARY_CONSTRUCTOR
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiErrorElement:Parameter name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(IDENTIFIER)('private')
|
||||
PsiErrorElement:Parameters must have type annotation
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('z')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiErrorElement:Parameter name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n\n')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
CLASS
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('B')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
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 ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
CLASS
|
||||
PsiComment(EOL_COMMENT)('// VAR')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('C')
|
||||
PRIMARY_CONSTRUCTOR
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(var)('var')
|
||||
PsiErrorElement:Parameter name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(var)('var')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(IDENTIFIER)('private')
|
||||
PsiErrorElement:Parameters must have type annotation
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('z')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(var)('var')
|
||||
PsiErrorElement:Parameter name expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n\n')
|
||||
PROPERTY
|
||||
PsiElement(var)('var')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('baz')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
CLASS
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('D')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(var)('var')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
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 ')
|
||||
PROPERTY
|
||||
PsiElement(var)('var')
|
||||
PsiErrorElement:Expecting property name or receiver type
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -8776,6 +8776,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/typeReferenceError.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valNoName.kt")
|
||||
public void testValNoName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valNoName.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2262,6 +2262,12 @@ public class ParsingTestGenerated extends AbstractParsingTest {
|
||||
doParsingTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ValNoName.kt")
|
||||
public void testValNoName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/recovery/ValNoName.kt");
|
||||
doParsingTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ValueParameterNoTypeRecovery.kt")
|
||||
public void testValueParameterNoTypeRecovery() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/recovery/ValueParameterNoTypeRecovery.kt");
|
||||
|
||||
Reference in New Issue
Block a user