From 623cf222ca2ac5e8b9628af5927956ecb6d44d1e Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Tue, 31 May 2022 15:34:37 +0200 Subject: Fix gathering inherited properties (#2481) * Fix gathering inherited properties in PSI * Refacotr KaJ transformer. Change wrapping TagWrapper for getters and setters. * Add logic to merge inherited properties in kotlin from java sources. * Remove getters and setters from JvmField properties for DObject, DEnum, DInterface in KaJ. * Unify InheritedMember DRI logic. * Fix gathering docs obtained from inheriting java sources in descriptors * Apply requested changes. * Resolve rebase conflicts * Use 221 for qodana analysis * Move accessors generation into DefaultDescriptorToDocumentableTranslator * Fix special "is" case for accessors and refactor logic in general * Remove ambiguous import after rebasing * Remove unused imports and format code * Apply review comment suggestions * Preserve previously lost accessor lookalikes * Extract a variable and correct a typo Co-authored-by: Andrzej Ratajczak --- .../src/main/kotlin/converters/KotlinToJavaConverter.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins/kotlin-as-java/src/main') diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index 1e3bd800..8ff35781 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -87,7 +87,7 @@ internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: Stri visibility = visibility.mapValues { if (isTopLevel && isConst) { JavaVisibility.Public - } else if (jvmField() != null) { + } else if (jvmField() != null || (getter == null && setter == null)) { it.value.asJava() } else { it.value.propertyVisibilityAsJava() @@ -275,7 +275,7 @@ internal fun DClass.functionsInJava(): List = .flatMap { property -> listOfNotNull(property.getter, property.setter) } .plus(functions) .filterNot { it.hasJvmSynthetic() } - .flatMap { it.asJava(dri.classNames ?: name) } + .flatMap { it.asJava(it.dri.classNames ?: it.name) } private fun DTypeParameter.asJava(): DTypeParameter = copy( variantTypeParameter = variantTypeParameter.withDri(dri.possiblyAsJava()), @@ -317,7 +317,7 @@ internal fun DEnum.asJava(): DEnum = copy( functions = functions .plus( properties - .filterNot { it.hasJvmSynthetic() } + .filter { it.jvmField() == null && !it.hasJvmSynthetic() } .flatMap { listOf(it.getter, it.setter) } ) .filterNotNull() @@ -335,7 +335,7 @@ internal fun DObject.asJava(): DObject = copy( functions = functions .plus( properties - .filterNot { it.hasJvmSynthetic() } + .filter { it.jvmField() == null && !it.hasJvmSynthetic() } .flatMap { listOf(it.getter, it.setter) } ) .filterNotNull() @@ -373,7 +373,7 @@ internal fun DInterface.asJava(): DInterface = copy( functions = functions .plus( properties - .filterNot { it.hasJvmSynthetic() } + .filter { it.jvmField() == null && !it.hasJvmSynthetic() } .flatMap { listOf(it.getter, it.setter) } ) .filterNotNull() -- cgit