Generate 'toString()': Permit for data classes

#KT-14122 Fixed
This commit is contained in:
Alexey Sedunov
2016-09-30 16:49:00 +03:00
parent 0616e869aa
commit 5bb035282f
8 changed files with 32 additions and 9 deletions
+1
View File
@@ -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-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-14122`](https://youtrack.jetbrains.com/issue/KT-14122) Generate 'toString()': Permit for data classes
#### Intention actions, inspections and quickfixes
@@ -126,7 +126,6 @@ class KotlinGenerateToStringAction : KotlinGenerateMemberActionBase<KotlinGenera
return targetClass is KtClass
&& !targetClass.isAnnotation()
&& !targetClass.isInterface()
&& !targetClass.hasModifier(KtTokens.DATA_KEYWORD)
}
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?)
@@ -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)"
}
}
@@ -49,12 +49,6 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
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")
public void testInterface() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/common/interface.kt");
@@ -88,6 +82,12 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
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")
public void testMultipleVars() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/multipeTemplates/multipleVars.kt");
@@ -139,6 +139,12 @@ public class GenerateToStringActionTestGenerated extends AbstractGenerateToStrin
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")
public void testExplicitDefaultAccessors() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/generate/toString/singleTemplate/explicitDefaultAccessors.kt");