From ff7f1c62a98e329a0a6da7af49aed7c99351aceb Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Fri, 16 Aug 2019 17:31:20 +0900 Subject: [PATCH] Minor: Refactor KotlinMethodStepTarget a bit --- .../KotlinMethodSmartStepIntoTarget.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/smartStepInto/KotlinMethodSmartStepIntoTarget.kt b/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/smartStepInto/KotlinMethodSmartStepIntoTarget.kt index c7c3465e6af..595ee1c2e71 100644 --- a/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/smartStepInto/KotlinMethodSmartStepIntoTarget.kt +++ b/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/smartStepInto/KotlinMethodSmartStepIntoTarget.kt @@ -18,10 +18,11 @@ import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy import org.jetbrains.kotlin.renderer.PropertyAccessorRenderingPolicy import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension +import org.jetbrains.kotlin.resolve.inline.InlineUtil import javax.swing.Icon class KotlinMethodSmartStepTarget( - descriptor: CallableMemberDescriptor, + private val descriptor: CallableMemberDescriptor, declaration: KtDeclaration?, label: String, highlightElement: PsiElement, @@ -29,13 +30,15 @@ class KotlinMethodSmartStepTarget( ) : SmartStepTarget(label, highlightElement, false, lines) { val declaration = declaration?.let(SourceNavigationHelper::getNavigationElement) - val isInvoke = descriptor is FunctionInvokeDescriptor - init { assert(declaration != null || isInvoke) } - private val isExtension = descriptor.isExtension + val isInvoke: Boolean + get() = descriptor is FunctionInvokeDescriptor + + private val isExtension: Boolean + get() = descriptor.isExtension val targetMethodName: String = when (descriptor) { is ClassDescriptor, is ConstructorDescriptor -> "" @@ -43,12 +46,7 @@ class KotlinMethodSmartStepTarget( else -> descriptor.name.asString() } - override fun getIcon(): Icon? { - return when { - isExtension -> KotlinIcons.EXTENSION_FUNCTION - else -> KotlinIcons.FUNCTION - } - } + override fun getIcon(): Icon = if (isExtension) KotlinIcons.EXTENSION_FUNCTION else KotlinIcons.FUNCTION companion object { private val renderer = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.withOptions {