From 59b74f10aa36d0b7ede770061121e85611886126 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 8 Feb 2024 14:38:49 +0100 Subject: [PATCH] KT-64808 [stubs] Small refactoring of `CallableClsStubBuilder` Rename `shouldSkip` to `mustNotBeWrittenToStubs`, so it looks more in line with `mustNotBeWrittenToDecompiledText` in the decompiler --- .../decompiler/psi/text/ByDescriptorIndexer.kt | 2 +- .../decompiler/stub/CallableClsStubBuilder.kt | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/analysis/decompiled/decompiler-to-psi/src/org/jetbrains/kotlin/analysis/decompiler/psi/text/ByDescriptorIndexer.kt b/analysis/decompiled/decompiler-to-psi/src/org/jetbrains/kotlin/analysis/decompiler/psi/text/ByDescriptorIndexer.kt index b19ed065536..e8e872708fa 100644 --- a/analysis/decompiled/decompiler-to-psi/src/org/jetbrains/kotlin/analysis/decompiler/psi/text/ByDescriptorIndexer.kt +++ b/analysis/decompiled/decompiler-to-psi/src/org/jetbrains/kotlin/analysis/decompiler/psi/text/ByDescriptorIndexer.kt @@ -52,7 +52,7 @@ object ByDescriptorIndexer { return classOrObject?.primaryConstructor ?: classOrObject } - if ((original as? CallableMemberDescriptor)?.mustNotBeWrittenToDecompiledText() == true && + if (original is CallableMemberDescriptor && original.mustNotBeWrittenToDecompiledText() && original.containingDeclaration is ClassDescriptor ) { return getDeclarationForDescriptor(original.containingDeclaration, file) diff --git a/analysis/decompiled/decompiler-to-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/CallableClsStubBuilder.kt b/analysis/decompiled/decompiler-to-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/CallableClsStubBuilder.kt index 0f57d34b2ed..830416b0258 100644 --- a/analysis/decompiled/decompiler-to-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/CallableClsStubBuilder.kt +++ b/analysis/decompiled/decompiler-to-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/CallableClsStubBuilder.kt @@ -55,14 +55,18 @@ fun createDeclarationsStubs( propertyProtos: List, ) { for (propertyProto in propertyProtos) { - if (!shouldSkip(propertyProto.flags, outerContext.nameResolver.getName(propertyProto.name))) { - PropertyClsStubBuilder(parentStub, outerContext, protoContainer, propertyProto).build() + if (mustNotBeWrittenToStubs(propertyProto.flags, outerContext.nameResolver.getName(propertyProto.name))) { + continue } + + PropertyClsStubBuilder(parentStub, outerContext, protoContainer, propertyProto).build() } for (functionProto in functionProtos) { - if (!shouldSkip(functionProto.flags, outerContext.nameResolver.getName(functionProto.name))) { - FunctionClsStubBuilder(parentStub, outerContext, protoContainer, functionProto).build() + if (mustNotBeWrittenToStubs(functionProto.flags, outerContext.nameResolver.getName(functionProto.name))) { + continue } + + FunctionClsStubBuilder(parentStub, outerContext, protoContainer, functionProto).build() } } @@ -86,7 +90,7 @@ fun createConstructorStub( ConstructorClsStubBuilder(parentStub, outerContext, protoContainer, constructorProto).build() } -private fun shouldSkip(flags: Int, name: Name): Boolean { +private fun mustNotBeWrittenToStubs(flags: Int, name: Name): Boolean { return when (Flags.MEMBER_KIND.get(flags)) { MemberKind.FAKE_OVERRIDE -> true //TODO: fix decompiler to use sane criteria