Convert to secondary constructor is not applicable to data classes (#1071)
#KT-15942 Fixed
This commit is contained in:
+1
-1
@@ -42,7 +42,7 @@ class ConvertPrimaryConstructorToSecondaryIntention : SelfTargetingIntention<KtP
|
||||
) {
|
||||
override fun isApplicableTo(element: KtPrimaryConstructor, caretOffset: Int): Boolean {
|
||||
val containingClass = element.containingClassOrObject as? KtClass ?: return false
|
||||
if (containingClass.isAnnotation()) return false;
|
||||
if (containingClass.isAnnotation() || containingClass.isData()) return false;
|
||||
return element.valueParameters.all { !it.hasValOrVar() || it.annotationEntries.isEmpty() }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
data class Data<caret>(val value: String)
|
||||
@@ -5030,6 +5030,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/dataClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueChain.kt")
|
||||
public void testDefaultValueChain() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertPrimaryConstructorToSecondary/defaultValueChain.kt");
|
||||
|
||||
Reference in New Issue
Block a user