Special modifier parsing for enum entries: last of them is considered as an enum entry name #KT-9088 Fixed
This commit is contained in:
@@ -962,8 +962,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
private ParseEnumEntryResult parseEnumEntry() {
|
||||
PsiBuilder.Marker entry = mark();
|
||||
|
||||
ModifierDetector detector = new ModifierDetector();
|
||||
parseModifierList(detector, ONLY_ESCAPED_REGULAR_ANNOTATIONS);
|
||||
parseModifierListWithStopAt(TokenSet.create(COMMA, SEMICOLON, RBRACE), ONLY_ESCAPED_REGULAR_ANNOTATIONS);
|
||||
|
||||
if (!atSet(SOFT_KEYWORDS_AT_MEMBER_START) && at(IDENTIFIER)) {
|
||||
PsiBuilder.Marker nameAsDeclaration = mark();
|
||||
@@ -2125,12 +2124,20 @@ public class JetParsing extends AbstractJetParsing {
|
||||
}
|
||||
|
||||
public void parseModifierListWithUnescapedAnnotations(TokenSet stopAt) {
|
||||
parseModifierListWithUnescapedAnnotations(TokenSet.create(IDENTIFIER), stopAt);
|
||||
parseModifierListWithLookForStopAt(TokenSet.create(IDENTIFIER), stopAt, ALLOW_UNESCAPED_REGULAR_ANNOTATIONS);
|
||||
}
|
||||
|
||||
public void parseModifierListWithStopAt(TokenSet stopAt, AnnotationParsingMode mode) {
|
||||
parseModifierListWithLookForStopAt(TokenSet.create(IDENTIFIER), stopAt, mode);
|
||||
}
|
||||
|
||||
public void parseModifierListWithUnescapedAnnotations(TokenSet lookFor, TokenSet stopAt) {
|
||||
parseModifierListWithLookForStopAt(lookFor, stopAt, ALLOW_UNESCAPED_REGULAR_ANNOTATIONS);
|
||||
}
|
||||
|
||||
public void parseModifierListWithLookForStopAt(TokenSet lookFor, TokenSet stopAt, AnnotationParsingMode mode) {
|
||||
int lastId = matchTokenStreamPredicate(new LastBefore(new AtSet(lookFor), new AnnotationTargetStop(stopAt, ANNOTATION_TARGETS), false));
|
||||
createTruncatedBuilder(lastId).parseModifierList(ALLOW_UNESCAPED_REGULAR_ANNOTATIONS);
|
||||
createTruncatedBuilder(lastId).parseModifierList(mode);
|
||||
}
|
||||
|
||||
private class AnnotationTargetStop extends AbstractTokenStreamPredicate {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
enum class My {
|
||||
inline
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public final enum class My : kotlin.Enum<My> {
|
||||
enum entry inline
|
||||
|
||||
private constructor My()
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<My>
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
enum class My {
|
||||
inline
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
JetFile: EnumInline.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
CLASS
|
||||
MODIFIER_LIST
|
||||
PsiElement(enum)('enum')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('My')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
ENUM_ENTRY
|
||||
OBJECT_DECLARATION_NAME
|
||||
PsiElement(IDENTIFIER)('inline')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
enum class My {
|
||||
inline public,
|
||||
inner private;
|
||||
|
||||
companion object {}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
JetFile: EnumInlinePublic.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
CLASS
|
||||
MODIFIER_LIST
|
||||
PsiElement(enum)('enum')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('My')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
ENUM_ENTRY
|
||||
MODIFIER_LIST
|
||||
PsiElement(inline)('inline')
|
||||
PsiWhiteSpace(' ')
|
||||
OBJECT_DECLARATION_NAME
|
||||
PsiElement(IDENTIFIER)('public')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace('\n ')
|
||||
ENUM_ENTRY
|
||||
MODIFIER_LIST
|
||||
PsiElement(inner)('inner')
|
||||
PsiWhiteSpace(' ')
|
||||
OBJECT_DECLARATION_NAME
|
||||
PsiElement(IDENTIFIER)('private')
|
||||
PsiElement(SEMICOLON)(';')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
OBJECT_DECLARATION
|
||||
MODIFIER_LIST
|
||||
PsiElement(companion)('companion')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(object)('object')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace(' \n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -5322,6 +5322,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inline.kt")
|
||||
public void testInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/inline.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("InsideEntryConstructorCall.kt")
|
||||
public void testInsideEntryConstructorCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/InsideEntryConstructorCall.kt");
|
||||
|
||||
@@ -271,6 +271,18 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
|
||||
doParsingTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumInline.kt")
|
||||
public void testEnumInline() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumInline.kt");
|
||||
doParsingTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumInlinePublic.kt")
|
||||
public void testEnumInlinePublic() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumInlinePublic.kt");
|
||||
doParsingTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("EnumMissingName.kt")
|
||||
public void testEnumMissingName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumMissingName.kt");
|
||||
|
||||
Reference in New Issue
Block a user