Minor: Refactor KotlinMethodStepTarget a bit
This commit is contained in:
+8
-10
@@ -18,10 +18,11 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
|||||||
import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy
|
import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy
|
||||||
import org.jetbrains.kotlin.renderer.PropertyAccessorRenderingPolicy
|
import org.jetbrains.kotlin.renderer.PropertyAccessorRenderingPolicy
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||||
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
|
|
||||||
class KotlinMethodSmartStepTarget(
|
class KotlinMethodSmartStepTarget(
|
||||||
descriptor: CallableMemberDescriptor,
|
private val descriptor: CallableMemberDescriptor,
|
||||||
declaration: KtDeclaration?,
|
declaration: KtDeclaration?,
|
||||||
label: String,
|
label: String,
|
||||||
highlightElement: PsiElement,
|
highlightElement: PsiElement,
|
||||||
@@ -29,13 +30,15 @@ class KotlinMethodSmartStepTarget(
|
|||||||
) : SmartStepTarget(label, highlightElement, false, lines) {
|
) : SmartStepTarget(label, highlightElement, false, lines) {
|
||||||
val declaration = declaration?.let(SourceNavigationHelper::getNavigationElement)
|
val declaration = declaration?.let(SourceNavigationHelper::getNavigationElement)
|
||||||
|
|
||||||
val isInvoke = descriptor is FunctionInvokeDescriptor
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
assert(declaration != null || isInvoke)
|
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) {
|
val targetMethodName: String = when (descriptor) {
|
||||||
is ClassDescriptor, is ConstructorDescriptor -> "<init>"
|
is ClassDescriptor, is ConstructorDescriptor -> "<init>"
|
||||||
@@ -43,12 +46,7 @@ class KotlinMethodSmartStepTarget(
|
|||||||
else -> descriptor.name.asString()
|
else -> descriptor.name.asString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIcon(): Icon? {
|
override fun getIcon(): Icon = if (isExtension) KotlinIcons.EXTENSION_FUNCTION else KotlinIcons.FUNCTION
|
||||||
return when {
|
|
||||||
isExtension -> KotlinIcons.EXTENSION_FUNCTION
|
|
||||||
else -> KotlinIcons.FUNCTION
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val renderer = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.withOptions {
|
private val renderer = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.withOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user