mirror of
https://github.com/apple/pkl.git
synced 2026-07-13 08:33:04 +02:00
codegen-kotlin: Don't generate equals/hashCode/toString/copy/:Serializable for abstract classes (#714)
* codegen-kotlin: Don't generate equals/hashCode/toString/copy/:Serializable for abstract classes * Polish KotlinCodeGeneratorTest - use `assertContains()` instead of `assertThat().contains()` - remove redundant `trimIndent()` and `trimMargin()` calls - rename `javaCode` to `kotlinCode` * Overhaul KotlinCodeGeneratorTest - introduce classes KotlinSourceCode and KotlinSourceCodeAssert - change assertions to use KotlinSourceCodeAssert via `assertThat(kotlinCode)` - use explicit trimIndent() and trimMargin() for multiline string literals - IntelliJ editor desperately wants to insert trimIndent() - can be used by kotlinc and ktfmt - format code in the exact way it falls out of the IntelliJ editor (successfully destroyed by ktfmt)
This commit is contained in:
@@ -485,12 +485,13 @@ class KotlinCodeGenerator(
|
|||||||
builder.addProperty(generateProperty(name, property))
|
builder.addProperty(generateProperty(name, property))
|
||||||
}
|
}
|
||||||
|
|
||||||
generateCopyMethods(builder)
|
if (!pClass.isAbstract) {
|
||||||
|
generateCopyMethods(builder)
|
||||||
builder
|
builder
|
||||||
.addFunction(generateEqualsMethod())
|
.addFunction(generateEqualsMethod())
|
||||||
.addFunction(generateHashCodeMethod())
|
.addFunction(generateHashCodeMethod())
|
||||||
.addFunction(generateToStringMethod())
|
.addFunction(generateToStringMethod())
|
||||||
|
}
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
}
|
}
|
||||||
@@ -530,7 +531,7 @@ class KotlinCodeGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun TypeSpec.Builder.ensureSerializable(): TypeSpec.Builder {
|
private fun TypeSpec.Builder.ensureSerializable(): TypeSpec.Builder {
|
||||||
if (!options.implementSerializable) {
|
if (!options.implementSerializable || modifiers.contains(KModifier.ABSTRACT)) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+845
-764
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user