Do not suggest "add inner" quick fix for interfaces etc. #KT-18396 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
84a6ef6ac4
commit
184651d366
@@ -115,6 +115,16 @@ open class AddModifierFix(
|
||||
if (parentClassOrObject is KtEnumEntry) return null
|
||||
}
|
||||
}
|
||||
if (modifier == INNER_KEYWORD) {
|
||||
if (modifierListOwner is KtObjectDeclaration) return null
|
||||
if (modifierListOwner is KtClass) {
|
||||
if (modifierListOwner.isInterface() ||
|
||||
modifierListOwner.isSealed() ||
|
||||
modifierListOwner.isEnum() ||
|
||||
modifierListOwner.isData() ||
|
||||
modifierListOwner.isAnnotation()) return null
|
||||
}
|
||||
}
|
||||
return AddModifierFix(modifierListOwner, modifier)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Add 'inner' modifier" "true"
|
||||
class A() {
|
||||
inner class B() {
|
||||
abstract class <caret>C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Add 'inner' modifier" "true"
|
||||
class A() {
|
||||
inner class B() {
|
||||
abstract inner class C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Add 'inner' modifier" "false"
|
||||
// ERROR: Annotation class is not allowed here
|
||||
class A() {
|
||||
inner class B() {
|
||||
annotation class <caret>C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add 'inner' modifier" "false"
|
||||
// ACTION: Create test
|
||||
// ERROR: Class is not allowed here
|
||||
// ERROR: Data class must have at least one primary constructor parameter
|
||||
class A() {
|
||||
inner class B() {
|
||||
data class <caret>C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add 'inner' modifier" "false"
|
||||
// ACTION: Convert to sealed class
|
||||
// ACTION: Create test
|
||||
// ERROR: Enum class is not allowed here
|
||||
class A() {
|
||||
inner class B() {
|
||||
enum class <caret>C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Add 'inner' modifier" "false"
|
||||
// ACTION: Implement interface
|
||||
// ERROR: Interface is not allowed here
|
||||
class A() {
|
||||
inner class B() {
|
||||
interface <caret>C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Add 'inner' modifier" "false"
|
||||
// ACTION: Create test
|
||||
// ERROR: Object is not allowed here
|
||||
class A() {
|
||||
inner class B() {
|
||||
object <caret>C
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Add 'inner' modifier" "false"
|
||||
// ACTION: Convert to enum class
|
||||
// ACTION: Create test
|
||||
// ACTION: Implement sealed class
|
||||
// ERROR: Class is not allowed here
|
||||
class A() {
|
||||
inner class B() {
|
||||
sealed class <caret>C
|
||||
}
|
||||
}
|
||||
@@ -7640,12 +7640,54 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAbstractClass.kt")
|
||||
public void testNestedAbstractClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedAbstractClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotationClass.kt")
|
||||
public void testNestedAnnotationClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedAnnotationClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassNotAllowed.kt")
|
||||
public void testNestedClassNotAllowed() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedClassNotAllowed.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedDataClass.kt")
|
||||
public void testNestedDataClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedDataClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedEnumClass.kt")
|
||||
public void testNestedEnumClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedEnumClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedInterface.kt")
|
||||
public void testNestedInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedObject.kt")
|
||||
public void testNestedObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedSealedClass.kt")
|
||||
public void testNestedSealedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/nestedSealedClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noAbstractForAnonymousObject.kt")
|
||||
public void testNoAbstractForAnonymousObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/noAbstractForAnonymousObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user