diff --git a/compiler/frontend/src/org/jetbrains/kotlin/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/kotlin/JetNodeTypes.java index 53a4f5e189c..25cc719d19b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/JetNodeTypes.java @@ -120,6 +120,7 @@ public interface JetNodeTypes { JetNodeType ANNOTATED_EXPRESSION = new JetNodeType("ANNOTATED_EXPRESSION", JetAnnotatedExpression.class); IElementType REFERENCE_EXPRESSION = JetStubElementTypes.REFERENCE_EXPRESSION; + IElementType ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = JetStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION; JetNodeType OPERATION_REFERENCE = new JetNodeType("OPERATION_REFERENCE", JetOperationReferenceExpression.class); JetNodeType LABEL = new JetNodeType("LABEL", JetLabelReferenceExpression.class); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index 0bc966d7255..ff2274faffc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -740,7 +740,7 @@ public class JetParsing extends AbstractJetParsing { /* * enumClassBody - * : "{" enumEntries members "}" + * : "{" enumEntries ";"? members "}" * ; */ private void parseEnumClassBody() { @@ -752,6 +752,8 @@ public class JetParsing extends AbstractJetParsing { advance(); // LBRACE parseEnumEntries(); + // TODO: syntax without SEMICOLON is deprecated, KT-7605 + consumeIf(SEMICOLON); parseMembers(); expect(RBRACE, "Expecting '}' to close enum class body"); @@ -761,52 +763,73 @@ public class JetParsing extends AbstractJetParsing { /** * enumEntries - * : enumEntry* + * : (enumEntry ","? )? * ; */ private void parseEnumEntries() { while (!eof() && !at(RBRACE)) { - PsiBuilder.Marker entry = mark(); - - ModifierDetector detector = new ModifierDetector(); - parseModifierList(detector, ONLY_ESCAPED_REGULAR_ANNOTATIONS); - - // ?: how can we find ourselves at SOFT_KEYWORDS_AT_MEMBER_START if we are at identifier? - // Or, is it just for performance? - if (!atSet(SOFT_KEYWORDS_AT_MEMBER_START) && at(IDENTIFIER)) { - parseEnumEntry(); - closeDeclarationWithCommentBinders(entry, ENUM_ENTRY, true); - } - else { - entry.rollbackTo(); + if (!parseEnumEntry()) { break; } + // TODO: syntax without COMMA is deprecated (only last entry is an exception), KT-7605 + consumeIf(COMMA); } } /* * enumEntry - * : modifiers SimpleName (":" initializer{","})? classBody? + * : modifiers SimpleName ((":" initializer) | ("(" arguments ")"))? classBody? * ; */ - private void parseEnumEntry() { - assert _at(IDENTIFIER); + private boolean parseEnumEntry() { + PsiBuilder.Marker entry = mark(); - PsiBuilder.Marker nameAsDeclaration = mark(); - advance(); // IDENTIFIER - nameAsDeclaration.done(OBJECT_DECLARATION_NAME); + ModifierDetector detector = new ModifierDetector(); + parseModifierList(detector, ONLY_ESCAPED_REGULAR_ANNOTATIONS); - if (at(COLON)) { - advance(); // COLON + if (!atSet(SOFT_KEYWORDS_AT_MEMBER_START) && at(IDENTIFIER)) { + PsiBuilder.Marker nameAsDeclaration = mark(); + advance(); // IDENTIFIER + nameAsDeclaration.done(OBJECT_DECLARATION_NAME); - parseInitializerList(); + if (at(LPAR)) { + // Arguments should be parsed here + // Also, "fake" constructor call tree is created, + // with empty type name inside + PsiBuilder.Marker initializerList = mark(); + PsiBuilder.Marker delegatorSuperCall = mark(); + + PsiBuilder.Marker callee = mark(); + PsiBuilder.Marker typeReference = mark(); + PsiBuilder.Marker type = mark(); + PsiBuilder.Marker referenceExpr = mark(); + referenceExpr.done(ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION); + type.done(USER_TYPE); + typeReference.done(TYPE_REFERENCE); + callee.done(CONSTRUCTOR_CALLEE); + + myExpressionParsing.parseValueArgumentList(); + delegatorSuperCall.done(DELEGATOR_SUPER_CALL); + initializerList.done(INITIALIZER_LIST); + } + // TODO: syntax with COLON is deprecated, should be changed to syntax with LPAR above, KT-7605 + else if (at(COLON)) { + advance(); // COLON + + parseInitializerList(); + } + if (at(LBRACE)) { + parseClassBody(); + } + + // Probably some helper function + closeDeclarationWithCommentBinders(entry, ENUM_ENTRY, true); + return true; } - - if (at(LBRACE)) { - parseClassBody(); + else { + entry.rollbackTo(); + return false; } - - consumeIf(SEMICOLON); } /* @@ -988,16 +1011,15 @@ public class JetParsing extends AbstractJetParsing { } /* - * initializer{","} + * initializerList + * : initializer + * */ private void parseInitializerList() { + // In practice, only one initializer is always in use PsiBuilder.Marker list = mark(); - while (true) { - if (at(COMMA)) errorAndAdvance("Expecting a this or super constructor call"); - parseInitializer(); - if (!at(COMMA)) break; - advance(); // COMMA - } + if (at(COMMA)) errorAndAdvance("Expecting a this or super constructor call"); + parseInitializer(); list.done(INITIALIZER_LIST); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntrySuperclassReferenceExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntrySuperclassReferenceExpression.kt new file mode 100644 index 00000000000..66d7fceb482 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetEnumEntrySuperclassReferenceExpression.kt @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi + +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.tree.IElementType +import com.intellij.psi.tree.TokenSet +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.name.SpecialNames +import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import org.jetbrains.kotlin.psi.stubs.KotlinEnumEntrySuperclassReferenceExpressionStub +import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes + +// This node represents "fake" reference expression for ENUM_ENTRY(arguments) constructor syntax +// It uses the superclass enum node to provide access to the real constructor name +public class JetEnumEntrySuperclassReferenceExpression: + JetExpressionImplStub, JetSimpleNameExpression { + + public constructor(node: ASTNode) : super(node) + + public constructor(stub: KotlinEnumEntrySuperclassReferenceExpressionStub) : + super(stub, JetStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION) + + // It is the owner enum class (not an enum entry but the whole enum) + private val referencedElement: JetClass + get() = calcReferencedElement()!! + + private fun calcReferencedElement(): JetClass? { + val owner = this.getStrictParentOfType() as? JetEnumEntry + return owner?.getParent()?.getParent() as? JetClass + } + + override fun getReferencedName(): String { + val stub = getStub() + if (stub != null) { + return stub.getReferencedName() + } + val text = getReferencedNameElement().getNode()!!.getText() + return JetPsiUtil.unquoteIdentifierOrFieldReference(text) + } + + override fun getReferencedNameAsName(): Name { + return referencedElement.getName()?.let { Name.guess(it) } ?: SpecialNames.NO_NAME_PROVIDED; + } + + override fun getReferencedNameElement(): PsiElement { + return referencedElement + } + + override fun getIdentifier(): PsiElement? { + return referencedElement.getNameIdentifier() + } + + override fun getReferencedNameElementType(): IElementType { + return getReferencedNameElement().getNode()!!.getElementType() + } + + override fun accept(visitor: JetVisitor, data: D): R { + return visitor.visitSimpleNameExpression(this, data) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetUserType.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetUserType.java index e3d4e181acd..cba29f4c13f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetUserType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetUserType.java @@ -72,8 +72,9 @@ public class JetUserType extends JetElementImplStub implemen } @Nullable @IfNotParsed - public JetNameReferenceExpression getReferenceExpression() { - return getStubOrPsiChild(JetStubElementTypes.REFERENCE_EXPRESSION); + public JetSimpleNameExpression getReferenceExpression() { + JetNameReferenceExpression nameRefExpr = getStubOrPsiChild(JetStubElementTypes.REFERENCE_EXPRESSION); + return nameRefExpr != null ? nameRefExpr : getStubOrPsiChild(JetStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION); } @Nullable @@ -92,7 +93,7 @@ public class JetUserType extends JetElementImplStub implemen @Nullable public String getReferencedName() { - JetNameReferenceExpression referenceExpression = getReferenceExpression(); + JetSimpleNameExpression referenceExpression = getReferenceExpression(); return referenceExpression == null ? null : referenceExpression.getReferencedName(); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt index a8141b5c78e..a0ad0c4eac1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt @@ -77,6 +77,10 @@ public trait KotlinNameReferenceExpressionStub : StubElement { + public fun getReferencedName(): String +} + public trait KotlinParameterStub : KotlinStubWithFqName { public fun isMutable(): Boolean public fun hasValOrVarNode(): Boolean diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetEnumEntrySuperClassReferenceExpressionElementType.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetEnumEntrySuperClassReferenceExpressionElementType.kt new file mode 100644 index 00000000000..e87e782d766 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetEnumEntrySuperClassReferenceExpressionElementType.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi.stubs.elements + +import com.intellij.psi.PsiElement +import com.intellij.psi.stubs.StubElement +import com.intellij.psi.stubs.StubInputStream +import com.intellij.psi.stubs.StubOutputStream +import com.intellij.util.io.StringRef +import org.jetbrains.annotations.NonNls +import org.jetbrains.kotlin.psi.JetEnumEntrySuperclassReferenceExpression +import org.jetbrains.kotlin.psi.stubs.KotlinEnumEntrySuperclassReferenceExpressionStub +import org.jetbrains.kotlin.psi.stubs.impl.KotlinEnumEntrySuperclassReferenceExpressionStubImpl + +public class JetEnumEntrySuperClassReferenceExpressionElementType(NonNls debugName: String) + : JetStubElementType( + debugName, + javaClass(), + javaClass() + ) { + + override fun createStub(psi: JetEnumEntrySuperclassReferenceExpression, parentStub: StubElement<*>): KotlinEnumEntrySuperclassReferenceExpressionStub { + return KotlinEnumEntrySuperclassReferenceExpressionStubImpl(parentStub, StringRef.fromString(psi.getReferencedName())!!) + } + + override fun serialize(stub: KotlinEnumEntrySuperclassReferenceExpressionStub, dataStream: StubOutputStream) { + dataStream.writeName(stub.getReferencedName()) + } + + override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>): KotlinEnumEntrySuperclassReferenceExpressionStub { + return KotlinEnumEntrySuperclassReferenceExpressionStubImpl(parentStub, dataStream.readName()) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java index 22eba9a3e18..2b17bda0ca6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.stubs.impl.KotlinFileStubImpl; import java.io.IOException; public class JetFileElementType extends IStubFileElementType { - public static final int STUB_VERSION = 43; + public static final int STUB_VERSION = 44; private static final String NAME = "kotlin.FILE"; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetStubElementTypes.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetStubElementTypes.java index b86f8a7cb59..fa100b48255 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetStubElementTypes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetStubElementTypes.java @@ -93,6 +93,8 @@ public interface JetStubElementTypes { JetNameReferenceExpressionElementType REFERENCE_EXPRESSION = new JetNameReferenceExpressionElementType("REFERENCE_EXPRESSION"); JetDotQualifiedExpressionElementType DOT_QUALIFIED_EXPRESSION = new JetDotQualifiedExpressionElementType("DOT_QUALIFIED_EXPRESSION"); + JetEnumEntrySuperClassReferenceExpressionElementType + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = new JetEnumEntrySuperClassReferenceExpressionElementType("ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION"); JetPlaceHolderStubElementType TYPE_ARGUMENT_LIST = new JetPlaceHolderStubElementType("TYPE_ARGUMENT_LIST", JetTypeArgumentList.class); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinEnumEntrySuperclassReferenceExpressionStubImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinEnumEntrySuperclassReferenceExpressionStubImpl.kt new file mode 100644 index 00000000000..4d8ea607355 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinEnumEntrySuperclassReferenceExpressionStubImpl.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi.stubs.impl + +import com.intellij.psi.PsiElement +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.kotlin.psi.JetEnumEntrySuperclassReferenceExpression +import org.jetbrains.kotlin.psi.stubs.KotlinEnumEntrySuperclassReferenceExpressionStub +import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes + +public class KotlinEnumEntrySuperclassReferenceExpressionStubImpl(parent: StubElement<*>, private val referencedName: StringRef) + : KotlinStubBaseImpl(parent, JetStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION), KotlinEnumEntrySuperclassReferenceExpressionStub { + + override fun getReferencedName() = referencedName.getString() +} diff --git a/compiler/testData/codegen/box/classes/kt2626.kt b/compiler/testData/codegen/box/classes/kt2626.kt index e01febbd377..34ba1d2ad8d 100644 --- a/compiler/testData/codegen/box/classes/kt2626.kt +++ b/compiler/testData/codegen/box/classes/kt2626.kt @@ -5,6 +5,6 @@ fun box() = Context.OsType.OK.toString() object Context { public enum class OsType { - WIN2000; WINDOWS; MACOSX; LINUX; OTHER; OK + WIN2000, WINDOWS, MACOSX, LINUX, OTHER, OK; } } diff --git a/compiler/testData/codegen/box/enum/enumShort.kt b/compiler/testData/codegen/box/enum/enumShort.kt new file mode 100644 index 00000000000..78935006d2b --- /dev/null +++ b/compiler/testData/codegen/box/enum/enumShort.kt @@ -0,0 +1,11 @@ +enum class Color(val rgb: Int) { + RED(0xff0000), + GREEN(0x00ff00), + BLUE(0x0000ff); +} + +fun foo(): Int { + return Color.RED.rgb + Color.GREEN.rgb + Color.BLUE.rgb +} + +fun box() = if (foo() == 0xffffff) "OK" else "Fail: ${foo()}" diff --git a/compiler/testData/codegen/box/enum/inclassobj.kt b/compiler/testData/codegen/box/enum/inclassobj.kt index f949bf91581..5006013d4b7 100644 --- a/compiler/testData/codegen/box/enum/inclassobj.kt +++ b/compiler/testData/codegen/box/enum/inclassobj.kt @@ -5,8 +5,8 @@ public class Context companion object { public enum class OsType { - LINUX; - OTHER + LINUX, + OTHER; } public val operatingSystemType: OsType diff --git a/compiler/testData/diagnostics/tests/enum/enumMissingName.kt b/compiler/testData/diagnostics/tests/enum/enumMissingName.kt new file mode 100644 index 00000000000..3c643de9647 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/enumMissingName.kt @@ -0,0 +1,6 @@ +// Error: name should present +enum class(val rgb : Int) { + RED(0xFF000), + GREEN(0x00FF00), + BLUE(0x0000FF) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/enum/enumMissingName.txt b/compiler/testData/diagnostics/tests/enum/enumMissingName.txt new file mode 100644 index 00000000000..4ba360affec --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/enumMissingName.txt @@ -0,0 +1,49 @@ +package + +internal final enum class : kotlin.Enum<> { + public enum entry RED : { + private constructor RED() + internal final override /*1*/ /*fake_override*/ val rgb: kotlin.Int + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: ): 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 + } + + public enum entry GREEN : { + private constructor GREEN() + internal final override /*1*/ /*fake_override*/ val rgb: kotlin.Int + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: ): 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 + } + + public enum entry BLUE : { + private constructor BLUE() + internal final override /*1*/ /*fake_override*/ val rgb: kotlin.Int + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: ): 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 + } + + private constructor (/*0*/ rgb: kotlin.Int) + internal final val rgb: kotlin.Int + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: ): 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): + public final /*synthesized*/ fun values(): kotlin.Array<> +} diff --git a/compiler/testData/psi/EnumCommas.kt b/compiler/testData/psi/EnumCommas.kt new file mode 100644 index 00000000000..8b4d8457e94 --- /dev/null +++ b/compiler/testData/psi/EnumCommas.kt @@ -0,0 +1,7 @@ +enum class Color { + NORTH, + SOUTH, + WEST, + EAST, + ; +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumCommas.txt b/compiler/testData/psi/EnumCommas.txt new file mode 100644 index 00000000000..a000f01414f --- /dev/null +++ b/compiler/testData/psi/EnumCommas.txt @@ -0,0 +1,37 @@ +JetFile: EnumCommas.kt + PACKAGE_DIRECTIVE + + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Color') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('NORTH') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('SOUTH') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('WEST') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('EAST') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/EnumMissingName.kt b/compiler/testData/psi/EnumMissingName.kt new file mode 100644 index 00000000000..8c1bed1a20c --- /dev/null +++ b/compiler/testData/psi/EnumMissingName.kt @@ -0,0 +1,6 @@ +// Error: name should present +enum class(val rgb : Int) { + RED(0xFF000), + GREEN(0x00FF00), + BLUE(0x0000FF) +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumMissingName.txt b/compiler/testData/psi/EnumMissingName.txt new file mode 100644 index 00000000000..bdbd0128257 --- /dev/null +++ b/compiler/testData/psi/EnumMissingName.txt @@ -0,0 +1,85 @@ +JetFile: EnumMissingName.kt + PACKAGE_DIRECTIVE + + CLASS + PsiComment(EOL_COMMENT)('// Error: name should present') + PsiWhiteSpace('\n') + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiErrorElement:Name expected + + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('rgb') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('RED') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0xFF000') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('GREEN') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x00FF00') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('BLUE') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x0000FF') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortCommas.kt b/compiler/testData/psi/EnumShortCommas.kt new file mode 100644 index 00000000000..75ca0105ae5 --- /dev/null +++ b/compiler/testData/psi/EnumShortCommas.kt @@ -0,0 +1,6 @@ +enum class Color(val rgb : Int) { + RED(0xFF000), + GREEN(0x00FF00), + BLUE(0x0000FF), + ; +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortCommas.txt b/compiler/testData/psi/EnumShortCommas.txt new file mode 100644 index 00000000000..10a0891420a --- /dev/null +++ b/compiler/testData/psi/EnumShortCommas.txt @@ -0,0 +1,86 @@ +JetFile: EnumShortCommas.kt + PACKAGE_DIRECTIVE + + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Color') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('rgb') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('RED') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0xFF000') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('GREEN') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x00FF00') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('BLUE') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x0000FF') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortNoCommas.kt b/compiler/testData/psi/EnumShortNoCommas.kt new file mode 100644 index 00000000000..43ee645d9fc --- /dev/null +++ b/compiler/testData/psi/EnumShortNoCommas.kt @@ -0,0 +1,7 @@ +// NB: this test uses deprecated syntax +// Delete it when this syntax is no longer supported +enum class Color(val rgb : Int) { + RED(0xFF000) + GREEN(0x00FF00) + BLUE(0x0000FF) +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortNoCommas.txt b/compiler/testData/psi/EnumShortNoCommas.txt new file mode 100644 index 00000000000..e3d67f9d434 --- /dev/null +++ b/compiler/testData/psi/EnumShortNoCommas.txt @@ -0,0 +1,85 @@ +JetFile: EnumShortNoCommas.kt + PACKAGE_DIRECTIVE + + CLASS + PsiComment(EOL_COMMENT)('// NB: this test uses deprecated syntax') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('// Delete it when this syntax is no longer supported') + PsiWhiteSpace('\n') + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Color') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('rgb') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('RED') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0xFF000') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('GREEN') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x00FF00') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('BLUE') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x0000FF') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortWithOverload.kt b/compiler/testData/psi/EnumShortWithOverload.kt new file mode 100644 index 00000000000..b7957c762a4 --- /dev/null +++ b/compiler/testData/psi/EnumShortWithOverload.kt @@ -0,0 +1,13 @@ +enum class Color(val rgb : Int) { + RED(0xFF000) { + override fun foo(): Int { return 1 } + }, + GREEN(0x00FF00) { + override fun foo(): Int { return 2 } + }, + BLUE(0x0000FF) { + override fun foo(): Int { return 3 } + }; + + abstract fun foo(): Int +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortWithOverload.txt b/compiler/testData/psi/EnumShortWithOverload.txt new file mode 100644 index 00000000000..08bc961d5e3 --- /dev/null +++ b/compiler/testData/psi/EnumShortWithOverload.txt @@ -0,0 +1,200 @@ +JetFile: EnumShortWithOverload.kt + PACKAGE_DIRECTIVE + + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Color') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('rgb') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('RED') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0xFF000') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('GREEN') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x00FF00') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('BLUE') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x0000FF') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n \n ') + FUN + MODIFIER_LIST + PsiElement(abstract)('abstract') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortWithOverloadNoCommas.kt b/compiler/testData/psi/EnumShortWithOverloadNoCommas.kt new file mode 100644 index 00000000000..73772645593 --- /dev/null +++ b/compiler/testData/psi/EnumShortWithOverloadNoCommas.kt @@ -0,0 +1,13 @@ +enum class Color(val rgb : Int) { + RED(0xFF000) { + override fun foo(): Int { return 1 } + } + GREEN(0x00FF00) { + override fun foo(): Int { return 2 } + } + BLUE(0x0000FF) { + override fun foo(): Int { return 3 } + } + + abstract fun foo(): Int +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumShortWithOverloadNoCommas.txt b/compiler/testData/psi/EnumShortWithOverloadNoCommas.txt new file mode 100644 index 00000000000..6c0e5275ef6 --- /dev/null +++ b/compiler/testData/psi/EnumShortWithOverloadNoCommas.txt @@ -0,0 +1,197 @@ +JetFile: EnumShortWithOverloadNoCommas.kt + PACKAGE_DIRECTIVE + + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Color') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('rgb') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('RED') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0xFF000') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('GREEN') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x00FF00') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('BLUE') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0x0000FF') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n \n ') + FUN + MODIFIER_LIST + PsiElement(abstract)('abstract') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/at/enumEntries.txt b/compiler/testData/psi/annotation/at/enumEntries.txt index 742f25c1e1b..6546763f573 100644 --- a/compiler/testData/psi/annotation/at/enumEntries.txt +++ b/compiler/testData/psi/annotation/at/enumEntries.txt @@ -133,20 +133,23 @@ JetFile: enumEntries.kt ENUM_ENTRY OBJECT_DECLARATION_NAME PsiElement(IDENTIFIER)('Ann') - PsiErrorElement:Expecting member declaration - PsiElement(LPAR)('(') - PsiErrorElement:Expecting member declaration - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - FUN - MODIFIER_LIST - ANNOTATION_ENTRY + INITIALIZER_LIST + DELEGATOR_SUPER_CALL CONSTRUCTOR_CALLEE TYPE_REFERENCE USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('W') - PsiWhiteSpace('\n\n ') + ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION + + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('W') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST ANNOTATION_ENTRY PsiElement(AT)('@') CONSTRUCTOR_CALLEE diff --git a/compiler/testData/psi/examples/util/Comparison.kt b/compiler/testData/psi/examples/util/Comparison.kt index 114a061147a..d1dcb2e4ef6 100644 --- a/compiler/testData/psi/examples/util/Comparison.kt +++ b/compiler/testData/psi/examples/util/Comparison.kt @@ -5,7 +5,7 @@ fun naturalOrder>(a : T, b : T) : Int = a.compareTo(b) fun castingNaturalOrder(a : Object, b : Object) : Int = (a as Comparable).compareTo(b as Comparable) enum class ComparisonResult { - LS; EQ; GR + LS, EQ, GR; } typealias MatchableComparison = (T, T) -> ComparisonResult diff --git a/compiler/testData/psi/examples/util/Comparison.txt b/compiler/testData/psi/examples/util/Comparison.txt index 95dcd8417cd..3552ac72f64 100644 --- a/compiler/testData/psi/examples/util/Comparison.txt +++ b/compiler/testData/psi/examples/util/Comparison.txt @@ -217,16 +217,17 @@ JetFile: Comparison.kt ENUM_ENTRY OBJECT_DECLARATION_NAME PsiElement(IDENTIFIER)('LS') - PsiElement(SEMICOLON)(';') + PsiElement(COMMA)(',') PsiWhiteSpace(' ') ENUM_ENTRY OBJECT_DECLARATION_NAME PsiElement(IDENTIFIER)('EQ') - PsiElement(SEMICOLON)(';') + PsiElement(COMMA)(',') PsiWhiteSpace(' ') ENUM_ENTRY OBJECT_DECLARATION_NAME PsiElement(IDENTIFIER)('GR') + PsiElement(SEMICOLON)(';') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/recovery/EnumEntryInitList.txt b/compiler/testData/psi/recovery/EnumEntryInitList.txt index c02b0c99c40..59729e00e22 100644 --- a/compiler/testData/psi/recovery/EnumEntryInitList.txt +++ b/compiler/testData/psi/recovery/EnumEntryInitList.txt @@ -138,9 +138,7 @@ JetFile: EnumEntryInitList.kt VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') - PsiElement(COMMA)(',') - PsiErrorElement:Expecting constructor call ((...)) - + PsiElement(COMMA)(',') PsiWhiteSpace('\n\n ') CLASS PsiElement(class)('class') @@ -175,10 +173,8 @@ JetFile: EnumEntryInitList.kt VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') - PsiElement(COMMA)(',') - PsiErrorElement:Expecting constructor call ((...)) - - PsiElement(SEMICOLON)(';') + PsiElement(COMMA)(',') + PsiElement(SEMICOLON)(';') PsiWhiteSpace('\n\n ') CLASS PsiElement(class)('class') diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index af14e463083..e69083057dd 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -4206,6 +4206,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("enumMissingName.kt") + public void testEnumMissingName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumMissingName.kt"); + doTest(fileName); + } + @TestMetadata("enumModifier.kt") public void testEnumModifier() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumModifier.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/ClassGenTest.java index e6921b39d03..da8a57f0b16 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ClassGenTest.java @@ -112,7 +112,7 @@ public class ClassGenTest extends CodegenTestCase { } public void testEnumClass() throws Exception { - loadText("enum class Direction { NORTH; SOUTH; EAST; WEST }"); + loadText("enum class Direction { NORTH, SOUTH, EAST, WEST; }"); Class direction = generateClass("Direction"); Field north = direction.getField("NORTH"); assertEquals(direction, north.getType()); @@ -120,7 +120,7 @@ public class ClassGenTest extends CodegenTestCase { } public void testEnumConstantConstructors() throws Exception { - loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }"); + loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000), GREEN: Color(0x00FF00); }"); Class colorClass = generateClass("Color"); Field redField = colorClass.getField("RED"); Object redValue = redField.get(null); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/EnumGenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/EnumGenTest.java index 14d5d805e8e..96857d3cbf5 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/EnumGenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/EnumGenTest.java @@ -56,7 +56,7 @@ public class EnumGenTest extends CodegenTestCase { } public void testEnumConstantConstructors() throws Exception { - loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }"); + loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000), GREEN: Color(0x00FF00); }"); Class colorClass = generateClass("Color"); Field redField = colorClass.getField("RED"); Object redValue = redField.get(null); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 4537a3c61cd..c4e618092af 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -3136,6 +3136,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("enumShort.kt") + public void testEnumShort() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/enumShort.kt"); + doTest(fileName); + } + @TestMetadata("enumWithLambdaParameter.kt") public void testEnumWithLambdaParameter() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/enumWithLambdaParameter.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index 8014ab56fab..0a2f4f464f3 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -205,12 +205,48 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("EnumCommas.kt") + public void testEnumCommas() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumCommas.kt"); + doParsingTest(fileName); + } + + @TestMetadata("EnumMissingName.kt") + public void testEnumMissingName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumMissingName.kt"); + doParsingTest(fileName); + } + @TestMetadata("EnumNoAnnotations.kt") public void testEnumNoAnnotations() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumNoAnnotations.kt"); doParsingTest(fileName); } + @TestMetadata("EnumShortCommas.kt") + public void testEnumShortCommas() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumShortCommas.kt"); + doParsingTest(fileName); + } + + @TestMetadata("EnumShortNoCommas.kt") + public void testEnumShortNoCommas() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumShortNoCommas.kt"); + doParsingTest(fileName); + } + + @TestMetadata("EnumShortWithOverload.kt") + public void testEnumShortWithOverload() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumShortWithOverload.kt"); + doParsingTest(fileName); + } + + @TestMetadata("EnumShortWithOverloadNoCommas.kt") + public void testEnumShortWithOverloadNoCommas() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumShortWithOverloadNoCommas.kt"); + doParsingTest(fileName); + } + @TestMetadata("Enums.kt") public void testEnums() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/Enums.kt"); diff --git a/grammar/src/enum.grm b/grammar/src/enum.grm index 2aa25b2c426..ca872153b6b 100644 --- a/grammar/src/enum.grm +++ b/grammar/src/enum.grm @@ -12,6 +12,11 @@ enumEntries : enumEntry* ; -enumEntry - : modifiers SimpleName (":" initializer{","})? classBody? +enumEntries + : (enumEntry ","? )? + ; + + +enumEntry + : modifiers SimpleName ((":" initializer) | ("(" arguments ")"))? classBody? ; diff --git a/idea/testData/formatter/DelegationList.after.inv.kt b/idea/testData/formatter/DelegationList.after.inv.kt index dd2a3cfdb02..19bb53c588b 100644 --- a/idea/testData/formatter/DelegationList.after.inv.kt +++ b/idea/testData/formatter/DelegationList.after.inv.kt @@ -27,14 +27,9 @@ open class C1 open class C2 enum class Test : A1 { - FIRST_ITEM : Test(), C1(), - C2() + FIRST_ITEM : Test() SECOND_ITEM : Test() - - THIRD_ITEM : Test(), - C1() - FORTH_ITEM : Test() } // SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST \ No newline at end of file diff --git a/idea/testData/formatter/DelegationList.after.kt b/idea/testData/formatter/DelegationList.after.kt index 5fcaf7e7d08..2cbca576e4e 100644 --- a/idea/testData/formatter/DelegationList.after.kt +++ b/idea/testData/formatter/DelegationList.after.kt @@ -27,14 +27,9 @@ open class C1 open class C2 enum class Test : A1 { - FIRST_ITEM : Test(), C1(), - C2() + FIRST_ITEM : Test() SECOND_ITEM : Test() - - THIRD_ITEM : Test(), - C1() - FORTH_ITEM : Test() } // SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST \ No newline at end of file diff --git a/idea/testData/formatter/DelegationList.kt b/idea/testData/formatter/DelegationList.kt index 5b8839eba3c..986cedf0a93 100644 --- a/idea/testData/formatter/DelegationList.kt +++ b/idea/testData/formatter/DelegationList.kt @@ -27,13 +27,9 @@ open class C1 open class C2 enum class Test : A1 { - FIRST_ITEM : Test(), C1(), - C2() + FIRST_ITEM : Test() SECOND_ITEM : Test() - - THIRD_ITEM : Test(), - C1() FORTH_ITEM : Test() } // SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.inv.kt b/idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.inv.kt new file mode 100644 index 00000000000..9aa3f83d1bb --- /dev/null +++ b/idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.inv.kt @@ -0,0 +1,6 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +enum class EnumTest { + ENTRY: EnumTest(); + +} diff --git a/idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.kt b/idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.kt new file mode 100644 index 00000000000..9aa3f83d1bb --- /dev/null +++ b/idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.kt @@ -0,0 +1,6 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +enum class EnumTest { + ENTRY: EnumTest(); + +} diff --git a/idea/testData/indentationOnNewline/InEnumAfterSemicolon.kt b/idea/testData/indentationOnNewline/InEnumAfterSemicolon.kt new file mode 100644 index 00000000000..5b3f5794f0b --- /dev/null +++ b/idea/testData/indentationOnNewline/InEnumAfterSemicolon.kt @@ -0,0 +1,5 @@ +// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST + +enum class EnumTest { + ENTRY: EnumTest(); +} diff --git a/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.inv.kt b/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.inv.kt index cea8d3b0776..97646fad749 100644 --- a/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.inv.kt +++ b/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.inv.kt @@ -4,5 +4,5 @@ interface A1 enum class EnumTest { ENTRY: EnumTest(), - + } diff --git a/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.kt b/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.kt index 173df3340fc..97646fad749 100644 --- a/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.kt +++ b/idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.kt @@ -4,5 +4,5 @@ interface A1 enum class EnumTest { ENTRY: EnumTest(), - + } diff --git a/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.inv.kt b/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.inv.kt index 54c905e37a7..d3b6732d773 100644 --- a/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.inv.kt +++ b/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.inv.kt @@ -4,5 +4,5 @@ interface A1 enum class EnumTest { ENTRY: EnumTest(), - A1 + A1 } diff --git a/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.kt b/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.kt index 4161f8535fb..d3b6732d773 100644 --- a/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.kt +++ b/idea/testData/indentationOnNewline/InEnumInitializerListNotEmpty.after.kt @@ -4,5 +4,5 @@ interface A1 enum class EnumTest { ENTRY: EnumTest(), - A1 + A1 } diff --git a/idea/tests/org/jetbrains/kotlin/formatter/JetTypingIndentationTestBaseGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/JetTypingIndentationTestBaseGenerated.java index 2e30f8309fc..cc1537fdbb7 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/JetTypingIndentationTestBaseGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/JetTypingIndentationTestBaseGenerated.java @@ -169,6 +169,12 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde doNewlineTest(fileName); } + @TestMetadata("InEnumAfterSemicolon.after.kt") + public void testInEnumAfterSemicolon() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.kt"); + doNewlineTest(fileName); + } + @TestMetadata("InEnumInitializerListAfterColon.after.kt") public void testInEnumInitializerListAfterColon() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumInitializerListAfterColon.after.kt"); @@ -385,6 +391,12 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde doNewlineTestWithInvert(fileName); } + @TestMetadata("InEnumAfterSemicolon.after.inv.kt") + public void testInEnumAfterSemicolon() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumAfterSemicolon.after.inv.kt"); + doNewlineTestWithInvert(fileName); + } + @TestMetadata("InEnumInitializerListAfterColon.after.inv.kt") public void testInEnumInitializerListAfterColon() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumInitializerListAfterColon.after.inv.kt"); diff --git a/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt index d61f4ef9533..f8c46fbc09e 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/DocCommentConverter.kt @@ -93,7 +93,7 @@ object DocCommentConverter { getValueElement() ?: getDataElements().firstOrNull { it !is PsiWhiteSpace } private class HtmlToMarkdownConverter() : XmlRecursiveElementVisitor() { - private enum class ListType { Ordered; Unordered } + private enum class ListType { Ordered Unordered; } data class MarkdownSpan(val prefix: String, val suffix: String) { companion object { val Empty = MarkdownSpan("", "")