Fixed EA-75877
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.renderer
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
@@ -51,6 +52,10 @@ public fun FqNameUnsafe.render(): String {
|
||||
return renderFqName(pathSegments())
|
||||
}
|
||||
|
||||
public fun FqName.render(): String {
|
||||
return renderFqName(pathSegments())
|
||||
}
|
||||
|
||||
public fun renderFqName(pathSegments: List<Name>): String {
|
||||
return buildString {
|
||||
for (element in pathSegments) {
|
||||
|
||||
+3
-2
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElement
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
@@ -179,14 +180,14 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere
|
||||
private fun KtNameReferenceExpression.changeQualifiedName(fqName: FqName): KtElement {
|
||||
assert(!fqName.isRoot()) { "Can't set empty FqName for element $this" }
|
||||
|
||||
val shortName = fqName.shortName().asString()
|
||||
val shortName = fqName.shortName().render()
|
||||
val psiFactory = KtPsiFactory(this)
|
||||
val fqNameBase = (getParent() as? KtCallExpression)?.let { parent ->
|
||||
val callCopy = parent.copy() as KtCallExpression
|
||||
callCopy.getCalleeExpression()!!.replace(psiFactory.createSimpleName(shortName)).getParent()!!.getText()
|
||||
} ?: shortName
|
||||
|
||||
val text = if (!fqName.isOneSegmentFQN()) "${fqName.parent().asString()}.$fqNameBase" else fqNameBase
|
||||
val text = if (!fqName.isOneSegmentFQN()) "${fqName.parent().render()}.$fqNameBase" else fqNameBase
|
||||
|
||||
val elementToReplace = getQualifiedElement()
|
||||
return when (elementToReplace) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// ERROR: A 'return' expression required in a function with a block body ('{...}')
|
||||
package to
|
||||
|
||||
import d.`class`
|
||||
|
||||
fun foo(): `class` {}
|
||||
@@ -0,0 +1 @@
|
||||
d.class
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_LIBRARY: copyPaste/imports/KotlinLibrary
|
||||
package a
|
||||
|
||||
import d.*
|
||||
|
||||
<selection>fun foo(): `class` {}</selection>
|
||||
@@ -0,0 +1,3 @@
|
||||
package d
|
||||
|
||||
class `class`
|
||||
+12
@@ -259,6 +259,12 @@ public class InsertImportOnPasteTestGenerated extends AbstractInsertImportOnPast
|
||||
doTestCopy(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KeywordClassName.kt")
|
||||
public void testKeywordClassName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/imports/KeywordClassName.kt");
|
||||
doTestCopy(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Local.kt")
|
||||
public void testLocal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/imports/Local.kt");
|
||||
@@ -604,6 +610,12 @@ public class InsertImportOnPasteTestGenerated extends AbstractInsertImportOnPast
|
||||
doTestCut(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KeywordClassName.kt")
|
||||
public void testKeywordClassName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/imports/KeywordClassName.kt");
|
||||
doTestCut(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Local.kt")
|
||||
public void testLocal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/copyPaste/imports/Local.kt");
|
||||
|
||||
Reference in New Issue
Block a user