Generate 'toString()': Permit for data classes
#KT-14122 Fixed
This commit is contained in:
@@ -197,6 +197,7 @@ These artifacts include extensions for the types available in the latter JDKs, s
|
|||||||
- [`KT-14096`](https://youtrack.jetbrains.com/issue/KT-14096) Rename: When renaming Kotlin file outside of source root do not rename its namesake in a source root
|
- [`KT-14096`](https://youtrack.jetbrains.com/issue/KT-14096) Rename: When renaming Kotlin file outside of source root do not rename its namesake in a source root
|
||||||
- [`KT-13928`](https://youtrack.jetbrains.com/issue/KT-13928) Move Inner Class to Upper Level: Fix replacement of outer class instances used in inner class constructor calls
|
- [`KT-13928`](https://youtrack.jetbrains.com/issue/KT-13928) Move Inner Class to Upper Level: Fix replacement of outer class instances used in inner class constructor calls
|
||||||
- [`KT-12556`](https://youtrack.jetbrains.com/issue/KT-12556) Allow using whitespaces and other symbols in "Generate -> Test Function" dialog
|
- [`KT-12556`](https://youtrack.jetbrains.com/issue/KT-12556) Allow using whitespaces and other symbols in "Generate -> Test Function" dialog
|
||||||
|
- [`KT-14122`](https://youtrack.jetbrains.com/issue/KT-14122) Generate 'toString()': Permit for data classes
|
||||||
|
|
||||||
#### Intention actions, inspections and quickfixes
|
#### Intention actions, inspections and quickfixes
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ class KotlinGenerateToStringAction : KotlinGenerateMemberActionBase<KotlinGenera
|
|||||||
return targetClass is KtClass
|
return targetClass is KtClass
|
||||||
&& !targetClass.isAnnotation()
|
&& !targetClass.isAnnotation()
|
||||||
&& !targetClass.isInterface()
|
&& !targetClass.isInterface()
|
||||||
&& !targetClass.hasModifier(KtTokens.DATA_KEYWORD)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun prepareMembersInfo(klass: KtClassOrObject, project: Project, editor: Editor?): Info? {
|
override fun prepareMembersInfo(klass: KtClassOrObject, project: Project, editor: Editor?): Info? {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
// NOT_APPLICABLE
|
|
||||||
data class A<caret>(val n: Int)
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// GENERATOR: MULTIPLE_TEMPLATES
|
||||||
|
data class A<caret>(val n: Int, val s: String?)
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// GENERATOR: MULTIPLE_TEMPLATES
|
||||||
|
data class A(val n: Int, val s: String?) {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "A(" +
|
||||||
|
"n=$n," +
|
||||||
|
"s=$s" +
|
||||||
|
")"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// GENERATOR: SINGLE_TEMPLATE
|
||||||
|
data class A<caret>(val n: Int, val s: String?)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// GENERATOR: SINGLE_TEMPLATE
|
||||||
|
data class A(val n: Int, val s: String?) {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "A(n=$n, s=$s)"
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
-6
@@ -49,12 +49,6 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("dataClass.kt")
|
|
||||||
public void testDataClass() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/common/dataClass.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("interface.kt")
|
@TestMetadata("interface.kt")
|
||||||
public void testInterface() throws Exception {
|
public void testInterface() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/common/interface.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/common/interface.kt");
|
||||||
@@ -88,6 +82,12 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dataClass.kt")
|
||||||
|
public void testDataClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/multipeTemplates/dataClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("multipleVars.kt")
|
@TestMetadata("multipleVars.kt")
|
||||||
public void testMultipleVars() throws Exception {
|
public void testMultipleVars() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/multipeTemplates/multipleVars.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/multipeTemplates/multipleVars.kt");
|
||||||
@@ -139,6 +139,12 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dataClass.kt")
|
||||||
|
public void testDataClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/singleTemplate/dataClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("explicitDefaultAccessors.kt")
|
@TestMetadata("explicitDefaultAccessors.kt")
|
||||||
public void testExplicitDefaultAccessors() throws Exception {
|
public void testExplicitDefaultAccessors() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/singleTemplate/explicitDefaultAccessors.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/singleTemplate/explicitDefaultAccessors.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user