diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt index 5b74df0c892..0aa47ba209e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -137,24 +137,28 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor - KotlinReferenceData.Kind.CLASS - - is PackageViewDescriptor -> - KotlinReferenceData.Kind.PACKAGE - - is CallableDescriptor -> - if (descriptor.isExtension) KotlinReferenceData.Kind.EXTENSION_CALLABLE else KotlinReferenceData.Kind.NON_EXTENSION_CALLABLE - - else -> - continue - } + val kind = referenceDataKind(descriptor) ?: continue collectedData.add(KotlinReferenceData(element.range.start - startOffset, element.range.end - startOffset, fqName.asString(), kind)) } return collectedData } + private fun referenceDataKind(descriptor: DeclarationDescriptor): KotlinReferenceData.Kind? { + return when (descriptor.getImportableDescriptor()) { + is ClassDescriptor -> + KotlinReferenceData.Kind.CLASS + + is PackageViewDescriptor -> + KotlinReferenceData.Kind.PACKAGE + + is CallableDescriptor -> + if (descriptor.isExtension) KotlinReferenceData.Kind.EXTENSION_CALLABLE else KotlinReferenceData.Kind.NON_EXTENSION_CALLABLE + + else -> + null + } + } + private data class ReferenceToRestoreData( val reference: JetReference, val refData: KotlinReferenceData @@ -232,10 +236,13 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor