DescriptorRenderer to skip @ExtensionFunctionType and @ParameterName only when it's redundant
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ a: (kotlin.String) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ a: A): kotlin.Unit
|
||||
public fun foo(/*0*/ a: @kotlin.ExtensionFunctionType A): kotlin.Unit
|
||||
|
||||
public interface A : (kotlin.String) -> kotlin.Unit {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
public val annClassRef: kotlin.reflect.KClass<Ann>
|
||||
public val annCtorRef: kotlin.reflect.KFunction1<kotlin.String, Ann>
|
||||
public val annCtorRef: kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "prop") kotlin.String, Ann>
|
||||
public val annPropRef: kotlin.reflect.KProperty1<Ann, kotlin.String>
|
||||
|
||||
public final annotation class Ann : kotlin.Annotation {
|
||||
|
||||
@@ -5,14 +5,14 @@ public fun f2(): kotlin.reflect.KFunction1<java.lang.Runnable, kotlin.Unit>
|
||||
public fun f3(): kotlin.reflect.KClass<java.lang.Runnable>
|
||||
public fun f4(): kotlin.reflect.KFunction1<java.lang.Runnable, kotlin.Unit>
|
||||
public fun f5(): kotlin.reflect.KClass<test.GenericSam<*>>
|
||||
public fun f6(): kotlin.reflect.KFunction2<test.GenericSam<*>, kotlin.Nothing!, kotlin.Unit>
|
||||
public fun f6(): kotlin.reflect.KFunction2<test.GenericSam<*>, @kotlin.ParameterName(name = "t") kotlin.Nothing!, kotlin.Unit>
|
||||
public fun f7(): kotlin.reflect.KClass<test.GenericSam<*>>
|
||||
public fun f8(): kotlin.reflect.KFunction2<test.GenericSam<kotlin.String>, kotlin.String!, kotlin.Unit>
|
||||
public fun f8(): kotlin.reflect.KFunction2<test.GenericSam<kotlin.String>, @kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit>
|
||||
public fun g1(): kotlin.reflect.KClass<java.lang.Runnable>
|
||||
public fun g2(): kotlin.reflect.KFunction0<kotlin.Unit>
|
||||
public fun g3(): kotlin.reflect.KClass<java.lang.Runnable>
|
||||
public fun g4(): kotlin.reflect.KFunction0<kotlin.Unit>
|
||||
public fun g5(): kotlin.reflect.KClass<test.GenericSam<kotlin.String>>
|
||||
public fun g6(): kotlin.reflect.KFunction1<kotlin.String!, kotlin.Unit>
|
||||
public fun g6(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit>
|
||||
public fun g7(): kotlin.reflect.KClass<test.GenericSam<kotlin.String>>
|
||||
public fun g8(): kotlin.reflect.KFunction1<kotlin.String!, kotlin.Unit>
|
||||
public fun g8(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit>
|
||||
|
||||
@@ -4,7 +4,7 @@ package
|
||||
public fun block(): kotlin.Unit
|
||||
public fun expression(): UsefulClass
|
||||
public fun invoker(): kotlin.Unit
|
||||
public fun reflection(): kotlin.reflect.KFunction1<kotlin.Int, UsefulClass>
|
||||
public fun reflection(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "param") kotlin.Int, UsefulClass>
|
||||
public fun reflection2(): kotlin.reflect.KFunction1<UsefulClass, kotlin.Unit>
|
||||
@kotlin.Deprecated(message = "does nothing good") public fun kotlin.Any.doNothing(): kotlin.String
|
||||
|
||||
|
||||
@@ -223,9 +223,7 @@ object ExcludedTypeAnnotations {
|
||||
|
||||
val internalAnnotationsForResolve = setOf(
|
||||
FqName("kotlin.internal.NoInfer"),
|
||||
FqName("kotlin.internal.Exact"),
|
||||
KotlinBuiltIns.FQ_NAMES.extensionFunctionType,
|
||||
KotlinBuiltIns.FQ_NAMES.parameterName
|
||||
FqName("kotlin.internal.Exact")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,13 @@ internal class DescriptorRendererImpl(
|
||||
assert(options.isLocked)
|
||||
}
|
||||
|
||||
private val functionTypeAnnotationsRenderer: DescriptorRendererImpl by lazy {
|
||||
this.withOptions { excludedTypeAnnotationClasses += listOf(KotlinBuiltIns.FQ_NAMES.extensionFunctionType) } as DescriptorRendererImpl
|
||||
}
|
||||
private val functionTypeParameterTypesRenderer: DescriptorRenderer by lazy {
|
||||
this.withOptions { excludedTypeAnnotationClasses += listOf(KotlinBuiltIns.FQ_NAMES.parameterName) }
|
||||
}
|
||||
|
||||
/* FORMATTING */
|
||||
private fun renderKeyword(keyword: String): String {
|
||||
when (textFormat) {
|
||||
@@ -294,7 +301,10 @@ internal class DescriptorRendererImpl(
|
||||
|
||||
private fun StringBuilder.renderFunctionType(type: KotlinType) {
|
||||
val lengthBefore = length
|
||||
renderAnnotations(type)
|
||||
// we need special renderer to skip @ExtensionFunctionType
|
||||
with(functionTypeAnnotationsRenderer) {
|
||||
renderAnnotations(type)
|
||||
}
|
||||
val hasAnnotations = length != lengthBefore
|
||||
|
||||
val isNullable = type.isMarkedNullable
|
||||
@@ -335,7 +345,8 @@ internal class DescriptorRendererImpl(
|
||||
append(renderName(name))
|
||||
append(": ")
|
||||
}
|
||||
append(renderTypeProjection(typeProjection))
|
||||
|
||||
append(functionTypeParameterTypesRenderer.renderTypeProjection(typeProjection))
|
||||
}
|
||||
|
||||
append(") ").append(arrow()).append(" ")
|
||||
|
||||
+1
-4
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.idea.decompiler.textBuilder
|
||||
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.ByDescriptorIndexer
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -39,9 +38,7 @@ fun DescriptorRendererOptions.defaultDecompilerRendererOptions() {
|
||||
classWithPrimaryConstructor = true
|
||||
secondaryConstructorsAsPrimary = false
|
||||
modifiers = DescriptorRendererModifier.ALL
|
||||
excludedTypeAnnotationClasses = (ExcludedTypeAnnotations.annotationsForNullabilityAndMutability +
|
||||
KotlinBuiltIns.FQ_NAMES.extensionFunctionType +
|
||||
KotlinBuiltIns.FQ_NAMES.parameterName).toSet()
|
||||
excludedTypeAnnotationClasses = ExcludedTypeAnnotations.annotationsForNullabilityAndMutability
|
||||
alwaysRenderModifiers = true
|
||||
parameterNamesInFunctionalTypes = false // to support parameters names in decompiled text we need to load annotation arguments
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user