Drop old enum syntax. Comma / semicolon are now a syntactic part of enum entry.

Comma must present now between enum entries, semicolon between last entry & first member, constructor calls must be without colons / specifiers.
A swarm of tests fixed accordingly.
This commit is contained in:
Mikhail Glukhikh
2015-08-05 18:22:21 +03:00
parent e5ab7de870
commit 3f14e74b08
190 changed files with 810 additions and 3201 deletions
@@ -82,8 +82,6 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
private val cleanupDiagnosticsFactories = setOf(
Errors.DEPRECATED_TRAIT_KEYWORD,
Errors.ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER,
Errors.ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR,
Errors.DEPRECATED_LAMBDA_SYNTAX,
Errors.MISSING_CONSTRUCTOR_KEYWORD,
Errors.FUNCTION_EXPRESSION_WITH_NAME,
@@ -1,105 +0,0 @@
/*
* 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.idea.quickfix
import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.*
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.quickfix.quickfixUtil.createIntentionFactory
import org.jetbrains.kotlin.idea.quickfix.quickfixUtil.createIntentionForFirstParentOfType
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
import org.jetbrains.kotlin.resolve.DeclarationsChecker
class DeprecatedEnumEntryDelimiterSyntaxFix(element: JetEnumEntry): JetIntentionAction<JetEnumEntry>(element), CleanupFix {
override fun getFamilyName(): String = getText()
override fun getText(): String = "Insert lacking comma(s) / semicolon(s)"
override fun invoke(project: Project, editor: Editor?, file: JetFile) = insertLackingCommaSemicolon(element)
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean
= super<JetIntentionAction>.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedOrNoDelimiter(element)
companion object : JetSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? =
diagnostic.createIntentionForFirstParentOfType(::DeprecatedEnumEntryDelimiterSyntaxFix)
public fun createWholeProjectFixFactory(): JetSingleIntentionActionFactory = createIntentionFactory {
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetEnumEntry>(
predicate = { DeclarationsChecker.enumEntryUsesDeprecatedOrNoDelimiter(it) },
taskProcessor = { insertLackingCommaSemicolon(it) },
name = "Insert lacking comma(s) / semicolon(s) in the whole project"
)
}
private fun insertLackingCommaSemicolon(enumEntry: JetEnumEntry) {
val body = enumEntry.getParent() as JetClassBody
val entries = body.getChildrenOfType<JetEnumEntry>()
val psiFactory = JetPsiFactory(body)
for ((entryIndex, entry) in entries.withIndex()) {
var next = entry.getNextSiblingIgnoringWhitespaceAndComments()
var nextType = next?.getNode()?.getElementType()
var added = false
if (entryIndex < entries.size() - 1) {
if (next is PsiErrorElement && next.getFirstChild()?.getNode()?.getElementType() == JetTokens.SEMICOLON) {
// Fix for syntax error like ENUM_ENTRY1; ENUM_ENTRY2; ENUM_ENTRY3
next.replace(psiFactory.createComma())
}
else if (nextType != JetTokens.COMMA) {
// Classic case like ENUM_ENTRY1 ENUM_ENTRY2
body.addAfter(psiFactory.createComma(), entry)
added = true
}
}
else {
if (nextType == JetTokens.COMMA) {
// ENUM_ENTRY_LAST, fun foo()
next!!.replace(psiFactory.createSemicolon())
}
else if (nextType != JetTokens.SEMICOLON && nextType != JetTokens.RBRACE) {
// ENUM_ENTRY_LAST fun foo()
body.addAfter(psiFactory.createSemicolon(), entry)
added = true
}
}
// Specific situation: ENTRY // comment ==> ENTRY, // comment, not ENTRY // comment,
if (added) {
val last = entry.getLastChild()
var curr = last
while (curr is PsiComment || curr is PsiWhiteSpace) {
// After comma / semicolon
val prev = curr.getPrevSibling()
body.addAfter(curr, entry.getNextSibling())
curr = prev
}
if (curr !== last) {
entry.deleteChildRange(curr.getNextSibling()!!, last)
}
}
}
}
}
}
@@ -1,75 +0,0 @@
/*
* 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.idea.quickfix
import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiWhiteSpace
import org.jetbrains.annotations.NotNull
import org.jetbrains.kotlin.JetNodeTypes
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.quickfix.quickfixUtil.createIntentionFactory
import org.jetbrains.kotlin.idea.quickfix.quickfixUtil.createIntentionForFirstParentOfType
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
import org.jetbrains.kotlin.resolve.DeclarationsChecker
class DeprecatedEnumEntrySuperConstructorSyntaxFix(element: JetEnumEntry): JetIntentionAction<JetEnumEntry>(element), CleanupFix {
override fun getFamilyName(): String = getText()
override fun getText(): String = "Change to short enum entry super constructor"
override fun invoke(project: Project, editor: Editor?, file: JetFile) = changeConstructorToShort(element)
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean
= super<JetIntentionAction>.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedSuperConstructor(element)
companion object: JetSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? =
diagnostic.createIntentionForFirstParentOfType(::DeprecatedEnumEntrySuperConstructorSyntaxFix)
public fun createWholeProjectFixFactory(): JetSingleIntentionActionFactory = createIntentionFactory {
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetEnumEntry>(
predicate = { DeclarationsChecker.enumEntryUsesDeprecatedSuperConstructor(it) },
taskProcessor = { changeConstructorToShort(it) },
name = "Change to short enum entry super constructor in the whole project"
)
}
private fun transformInitializerList(list: JetInitializerList) {
val psiFactory = JetPsiFactory(list)
val userType = list.getInitializers()[0].getTypeReference()!!.getTypeElement() as JetUserType
userType.getReferenceExpression()!!.replace(psiFactory.createEnumEntrySuperclassReferenceExpression())
}
private fun changeConstructorToShort(entry: JetEnumEntry) {
val list = entry.getInitializerList()!!
transformInitializerList(list)
// Delete everything between name identifier and initializer (colon with whitespaces)
val name = entry.getNameAsDeclaration()!!
entry.deleteChildRange(name.getNextSibling()!!, list.getPrevSibling()!!)
}
}
}
@@ -300,12 +300,6 @@ public class QuickFixRegistrar : QuickFixContributor {
DEPRECATED_ANNOTATION_METHOD_CALL.registerFactory(MigrateAnnotationMethodCallFix, MigrateAnnotationMethodCallInWholeFile)
ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR.registerFactory(DeprecatedEnumEntrySuperConstructorSyntaxFix,
DeprecatedEnumEntrySuperConstructorSyntaxFix.createWholeProjectFixFactory())
ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER.registerFactory(DeprecatedEnumEntryDelimiterSyntaxFix,
DeprecatedEnumEntryDelimiterSyntaxFix.createWholeProjectFixFactory())
MISSING_CONSTRUCTOR_KEYWORD.registerFactory(MissingConstructorKeywordFix,
MissingConstructorKeywordFix.createWholeProjectFixFactory())
+3 -3
View File
@@ -4,11 +4,11 @@
package testData.libraries
[[public final enum class Color private constructor(rgb: kotlin.Int) : kotlin.Enum<testData.libraries.Color> {
[[RED]],
[[RED,]]
[[GREEN]],
[[GREEN,]]
[[BLUE]];
[[BLUE;]]
[internal final val rgb: kotlin.Int /* compiled code */]
}]]
@@ -30,6 +30,7 @@ interface T1
enum class E1 {
ENTRY;
object O7
}
@@ -67,6 +68,7 @@ interface T2
enum class E2 {
ENTRY;
object O14 {}
}
@@ -109,6 +111,7 @@ interface T3
enum class E3 {
ENTRY;
object O21 {
}
}
@@ -23,5 +23,6 @@ enum class E6 {
enum class E7 {
F {
}, S, T
},
S, T
}
@@ -1,10 +0,0 @@
enum class Test: A {
FIRST: Test()
SECOND:
Test()
THIRD: Test() FORTH: Test()
}
// SET_TRUE: SPACE_BEFORE_EXTEND_COLON
// SET_FALSE: SPACE_AFTER_EXTEND_COLON
@@ -1,10 +0,0 @@
enum class Test :A {
FIRST :Test()
SECOND :
Test()
THIRD :Test() FORTH :Test()
}
// SET_TRUE: SPACE_BEFORE_EXTEND_COLON
// SET_FALSE: SPACE_AFTER_EXTEND_COLON
@@ -1,10 +0,0 @@
enum class Test : A {
FIRST : Test()
SECOND:
Test()
THIRD: Test() FORTH: Test()
}
// SET_TRUE: SPACE_BEFORE_EXTEND_COLON
// SET_FALSE: SPACE_AFTER_EXTEND_COLON
@@ -1,8 +0,0 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
interface A1
enum class EnumTest {
ENTRY:
<caret>
}
@@ -1,8 +0,0 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
interface A1
enum class EnumTest {
ENTRY:
<caret>
}
@@ -1,7 +0,0 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
interface A1
enum class EnumTest {
ENTRY: <caret>
}
-9
View File
@@ -1,15 +1,6 @@
trait Foo {
}
enum class E {
First Second
}
enum class F(val name: String) {
First: F("First")
Second: F("Second")
}
val f = { (a: Int, b: Int) -> a + b }
class A private()
-9
View File
@@ -1,15 +1,6 @@
interface Foo {
}
enum class E {
First, Second
}
enum class F(val name: String) {
First("First"),
Second("Second")
}
val f = { a: Int, b: Int -> a + b }
class A private constructor()
@@ -1,8 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class MyEnum(val z: Int) {
A: MyEnum(3)<caret>
B(7)
C(12)
fun foo() = z * 2
}
@@ -1,8 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class MyEnum(val z: Int) {
A(3)
B(7)
C(12)
fun foo() = z * 2
}
@@ -1,8 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class MyEnum(val z: Int) {
A(3)
B(7)
C: MyEnum(12)<caret>
fun foo() = z * 2
}
@@ -1,8 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class MyEnum(val z: Int) {
A(3)
B(7)
C(12)
fun foo() = z * 2
}
@@ -1,11 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
annotation class My
annotation class Your
annotation class His
enum class MyEnum(val i: Int) {
@My FIRST: MyEnum(1)<caret>,
@My @Your SECOND: MyEnum(2),
@Your @His THIRD: MyEnum(3)
}
@@ -1,11 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
annotation class My
annotation class Your
annotation class His
enum class MyEnum(val i: Int) {
@My FIRST(1),
@My @Your SECOND(2),
@Your @His THIRD(3)
}
@@ -1,10 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class MyEnum(val i: Int) {
// The first
FIRST: MyEnum(1)<caret>,
// The second
SECOND: MyEnum(2),
// The third
THIRD: MyEnum(3)
}
@@ -1,10 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class MyEnum(val i: Int) {
// The first
FIRST(1),
// The second
SECOND(2),
// The third
THIRD(3)
}
@@ -1,16 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class MyEnum(val i: Int) {
/**
* The first
*/
FIRST: MyEnum(1),
/**
* The second
*/
SECOND: MyEnum(2)<caret>,
/**
* The third
*/
THIRD: MyEnum(3)
}
@@ -1,16 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class MyEnum(val i: Int) {
/**
* The first
*/
FIRST(1),
/**
* The second
*/
SECOND(2),
/**
* The third
*/
THIRD(3)
}
@@ -1,13 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class MyEnum(val i: Int) {
// The
// first
FIRST: MyEnum(1),
// The
// second
SECOND: MyEnum(2),
// The
// third
THIRD: MyEnum(3)<caret>
}
@@ -1,13 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class MyEnum(val i: Int) {
// The
// first
FIRST(1),
// The
// second
SECOND(2),
// The
// third
THIRD(3)
}
@@ -1,5 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String) {
UNIQUE: SimpleEnum("42")<caret>
}
@@ -1,5 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String) {
UNIQUE("42")
}
@@ -1,24 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class First(val colorCode: Int) {
RED: First(0xff0000),
GREEN: First(0x00ff00)<caret>, BLUE: First(0x0000ff)
}
enum class Second(val dirCode: Int) {
NORTH: Second(1) {
override fun dir(): String = "N"
},
SOUTH: Second(2) {
override fun dir(): String = "S"
},
WEST : Second(3) {
override fun dir(): String = "W"
},
EAST: Second(4) {
override fun dir(): String = "E"
};
abstract fun dir(): String
}
@@ -1,24 +0,0 @@
// "Change to short enum entry super constructor in the whole project" "true"
enum class First(val colorCode: Int) {
RED(0xff0000),
GREEN(0x00ff00), BLUE(0x0000ff)
}
enum class Second(val dirCode: Int) {
NORTH(1) {
override fun dir(): String = "N"
},
SOUTH(2) {
override fun dir(): String = "S"
},
WEST(3) {
override fun dir(): String = "W"
},
EAST(4) {
override fun dir(): String = "E"
};
abstract fun dir(): String
}
@@ -1,9 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String = "xxx") {
FIRST(),
SECOND: SimpleEnum("42")<caret>,
LAST("13");
fun foo() = z
}
@@ -1,9 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String = "xxx") {
FIRST(),
SECOND("42"),
LAST("13");
fun foo() = z
}
@@ -1,9 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String = "xxx") {
FIRST(),
SECOND: SimpleEnum(z = "42")<caret>,
LAST("13");
fun foo() = z
}
@@ -1,9 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String = "xxx") {
FIRST(),
SECOND(z = "42")<caret>,
LAST("13");
fun foo() = z
}
@@ -1,13 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String = "xxx") {
FIRST: SimpleEnum()<caret> {
override fun foo(): String = "abc"
},
SECOND() {
override fun foo(): String = "xyz"
},
LAST("13");
open fun foo(): String = z
}
@@ -1,13 +0,0 @@
// "Change to short enum entry super constructor" "true"
enum class SimpleEnum(val z: String = "xxx") {
FIRST() {
override fun foo(): String = "abc"
},
SECOND() {
override fun foo(): String = "xyz"
},
LAST("13");
open fun foo(): String = z
}
@@ -1,7 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST,
SECOND<caret>,
val zzz = 42
}
@@ -1,7 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST,
SECOND;
val zzz = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A, B; C<caret> D,
fun foo() = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A, B, C<caret>, D;
fun foo() = 42
}
@@ -1,9 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST SECOND,
THIRD
FOURTH<caret> FIFTH SIXTH,
SEVENTH EIGHTH
}
@@ -1,9 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, SECOND,
THIRD,
FOURTH, FIFTH, SIXTH,
SEVENTH, EIGHTH
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST<caret> SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, SECOND
}
@@ -1,8 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST<caret>
/* The first one */
SECOND
/* The last one */
}
@@ -1,8 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST<caret>,
/* The first one */
SECOND
/* The last one */
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST<caret> /* The first one */
SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, /* The first one */
SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST<caret> // The first one
SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, // The first one
SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST<caret> /* The first one */ // It's really important
SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, /* The first one */ // It's really important
SECOND
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A B C D<caret> E F G H I J
fun foo() = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A, B, C, D, E, F, G, H, I, J;
fun foo() = 42
}
@@ -1,8 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum(val z: Int) {
A: MyEnum(3)
B<caret>: MyEnum(7)
C: MyEnum(12)
fun foo() = z * 2
}
@@ -1,8 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum(val z: Int) {
A: MyEnum(3),
B: MyEnum(7),
C: MyEnum(12);
fun foo() = z * 2
}
@@ -1,11 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A {
override fun foo(): Int = 13
}
B C<caret> {
override fun foo(): Int = 23
}
open fun foo(): Int = 42
}
@@ -1,11 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A {
override fun foo(): Int = 13
},
B, C<caret> {
override fun foo(): Int = 23
};
open fun foo(): Int = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum(val z: Int) {
A(3) B<caret>(7) C(12)
fun foo() = z * 2
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum(val z: Int) {
A(3), B(7), C(12);
fun foo() = z * 2
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, SECOND<caret>
val zzz = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, SECOND;
val zzz = 42
}
@@ -1,7 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, SECOND<caret>
/* The last one*/
fun foo() = 1
}
@@ -1,7 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
FIRST, SECOND<caret>;
/* The last one*/
fun foo() = 1
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A<caret>; B; C; D;
fun foo() = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A<caret>, B, C, D;
fun foo() = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A; B; C<caret>; D
fun foo() = 42
}
@@ -1,6 +0,0 @@
// "Insert lacking comma(s) / semicolon(s)" "true"
enum class MyEnum {
A, B, C<caret>, D;
fun foo() = 42
}
@@ -1,22 +0,0 @@
// "Insert lacking comma(s) / semicolon(s) in the whole project" "true"
enum class First {
RED GREEN,
BLUE
}
enum class Second(val code: Int) {
NORTH(2) SOUTH(4),
EAST(6) WEST(8)
}
enum class Third {
OK {
override fun diag(): String = "OK"
}
ERROR<caret> {
override fun diag(): String = "Failed"
}
open fun diag(): String = ""
}
@@ -1,22 +0,0 @@
// "Insert lacking comma(s) / semicolon(s) in the whole project" "true"
enum class First {
RED, GREEN,
BLUE
}
enum class Second(val code: Int) {
NORTH(2), SOUTH(4),
EAST(6), WEST(8)
}
enum class Third {
OK {
override fun diag(): String = "OK"
},
ERROR {
override fun diag(): String = "Failed"
};
open fun diag(): String = ""
}
@@ -451,12 +451,6 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest(fileName);
}
@TestMetadata("SpaceAroundExtendColonInEnums.after.kt")
public void testSpaceAroundExtendColonInEnums() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/SpaceAroundExtendColonInEnums.after.kt");
doTest(fileName);
}
@TestMetadata("SpaceAroundExtendColonInObjects.after.kt")
public void testSpaceAroundExtendColonInObjects() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/SpaceAroundExtendColonInObjects.after.kt");
@@ -868,12 +862,6 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTestInverted(fileName);
}
@TestMetadata("SpaceAroundExtendColonInEnums.after.inv.kt")
public void testSpaceAroundExtendColonInEnums() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/SpaceAroundExtendColonInEnums.after.inv.kt");
doTestInverted(fileName);
}
@TestMetadata("SpaceAroundExtendColonInObjects.after.inv.kt")
public void testSpaceAroundExtendColonInObjects() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/SpaceAroundExtendColonInObjects.after.inv.kt");
@@ -175,12 +175,6 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
doNewlineTest(fileName);
}
@TestMetadata("InEnumInitializerListAfterColon.after.kt")
public void testInEnumInitializerListAfterColon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumInitializerListAfterColon.after.kt");
doNewlineTest(fileName);
}
@TestMetadata("InEnumInitializerListAfterComma.after.kt")
public void testInEnumInitializerListAfterComma() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.kt");
@@ -397,12 +391,6 @@ public class JetTypingIndentationTestBaseGenerated extends AbstractJetTypingInde
doNewlineTestWithInvert(fileName);
}
@TestMetadata("InEnumInitializerListAfterColon.after.inv.kt")
public void testInEnumInitializerListAfterColon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumInitializerListAfterColon.after.inv.kt");
doNewlineTestWithInvert(fileName);
}
@TestMetadata("InEnumInitializerListAfterComma.after.inv.kt")
public void testInEnumInitializerListAfterComma() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/indentationOnNewline/InEnumInitializerListAfterComma.after.inv.kt");
@@ -3836,192 +3836,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("idea/testData/quickfix/migration/enumConstructor")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class EnumConstructor extends AbstractQuickFixTest {
public void testAllFilesPresentInEnumConstructor() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/enumConstructor"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("noDelimiterWithInitializerFirst.kt")
public void testNoDelimiterWithInitializerFirst() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/noDelimiterWithInitializerFirst.kt");
doTest(fileName);
}
@TestMetadata("noDelimiterWithInitializerLast.kt")
public void testNoDelimiterWithInitializerLast() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/noDelimiterWithInitializerLast.kt");
doTest(fileName);
}
@TestMetadata("precedingAnnotation.kt")
public void testPrecedingAnnotation() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/precedingAnnotation.kt");
doTest(fileName);
}
@TestMetadata("precedingComment.kt")
public void testPrecedingComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/precedingComment.kt");
doTest(fileName);
}
@TestMetadata("precedingDocComment.kt")
public void testPrecedingDocComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/precedingDocComment.kt");
doTest(fileName);
}
@TestMetadata("precedingMultilineComment.kt")
public void testPrecedingMultilineComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/precedingMultilineComment.kt");
doTest(fileName);
}
@TestMetadata("singleEntry.kt")
public void testSingleEntry() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/singleEntry.kt");
doTest(fileName);
}
@TestMetadata("wholeProject.kt")
public void testWholeProject() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/wholeProject.kt");
doTest(fileName);
}
@TestMetadata("withCommas.kt")
public void testWithCommas() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/withCommas.kt");
doTest(fileName);
}
@TestMetadata("withNamedArgument.kt")
public void testWithNamedArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/withNamedArgument.kt");
doTest(fileName);
}
@TestMetadata("withOverloads.kt")
public void testWithOverloads() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumConstructor/withOverloads.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/quickfix/migration/enumDelimiter")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class EnumDelimiter extends AbstractQuickFixTest {
public void testAllFilesPresentInEnumDelimiter() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/enumDelimiter"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("commaNoSemicolon.kt")
public void testCommaNoSemicolon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/commaNoSemicolon.kt");
doTest(fileName);
}
@TestMetadata("commaSemicolonDelimiter.kt")
public void testCommaSemicolonDelimiter() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/commaSemicolonDelimiter.kt");
doTest(fileName);
}
@TestMetadata("missedCommas.kt")
public void testMissedCommas() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/missedCommas.kt");
doTest(fileName);
}
@TestMetadata("noComma.kt")
public void testNoComma() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noComma.kt");
doTest(fileName);
}
@TestMetadata("noCommaComment.kt")
public void testNoCommaComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noCommaComment.kt");
doTest(fileName);
}
@TestMetadata("noCommaWithBracketComment.kt")
public void testNoCommaWithBracketComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noCommaWithBracketComment.kt");
doTest(fileName);
}
@TestMetadata("noCommaWithComment.kt")
public void testNoCommaWithComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noCommaWithComment.kt");
doTest(fileName);
}
@TestMetadata("noCommaWithTwoComments.kt")
public void testNoCommaWithTwoComments() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noCommaWithTwoComments.kt");
doTest(fileName);
}
@TestMetadata("noDelimiter.kt")
public void testNoDelimiter() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noDelimiter.kt");
doTest(fileName);
}
@TestMetadata("noDelimiterWithInitializer.kt")
public void testNoDelimiterWithInitializer() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noDelimiterWithInitializer.kt");
doTest(fileName);
}
@TestMetadata("noDelimiterWithOverload.kt")
public void testNoDelimiterWithOverload() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noDelimiterWithOverload.kt");
doTest(fileName);
}
@TestMetadata("noDelimiterWithShortConstructor.kt")
public void testNoDelimiterWithShortConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noDelimiterWithShortConstructor.kt");
doTest(fileName);
}
@TestMetadata("noSemicolon.kt")
public void testNoSemicolon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noSemicolon.kt");
doTest(fileName);
}
@TestMetadata("noSemicolonComment.kt")
public void testNoSemicolonComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/noSemicolonComment.kt");
doTest(fileName);
}
@TestMetadata("semicolonDelimiter.kt")
public void testSemicolonDelimiter() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/semicolonDelimiter.kt");
doTest(fileName);
}
@TestMetadata("semicolonDelimiterExceptLast.kt")
public void testSemicolonDelimiterExceptLast() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/semicolonDelimiterExceptLast.kt");
doTest(fileName);
}
@TestMetadata("wholeProject.kt")
public void testWholeProject() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/enumDelimiter/wholeProject.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/quickfix/migration/lambdaSyntax")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)