Move: Specify conflict containing declaration more precisely
Also do not render class fqname for member declarations #KT-17547 Fixed
This commit is contained in:
@@ -34,7 +34,9 @@ import org.jetbrains.kotlin.idea.refactoring.rename.RenameJavaSyntheticPropertyH
|
||||
import org.jetbrains.kotlin.idea.refactoring.rename.RenameKotlinPropertyProcessor
|
||||
import org.jetbrains.kotlin.idea.util.string.collapseSpaces
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class KotlinElementDescriptionProvider : ElementDescriptionProvider {
|
||||
@@ -44,7 +46,16 @@ class KotlinElementDescriptionProvider : ElementDescriptionProvider {
|
||||
return parent
|
||||
}
|
||||
|
||||
private fun KtNamedDeclaration.name() = nameAsName ?: Name.special("<no name provided>")
|
||||
|
||||
private fun KtNamedDeclaration.fqName(): FqNameUnsafe {
|
||||
containingClassOrObject?.let {
|
||||
if (it is KtObjectDeclaration && it.isCompanion()) {
|
||||
return it.fqName().child(name())
|
||||
}
|
||||
return FqNameUnsafe("${it.name()}.${name()}")
|
||||
}
|
||||
|
||||
val internalSegments = generateSequence(this) { it.parentForFqName() }
|
||||
.filterIsInstance<KtNamedDeclaration>()
|
||||
.map { it.name ?: "<no name provided>" }
|
||||
|
||||
@@ -142,7 +142,13 @@ fun VirtualFile.toPsiFileOrDirectory(project: Project): PsiFileSystemItem? = if
|
||||
|
||||
fun PsiElement.getUsageContext(): PsiElement {
|
||||
return when (this) {
|
||||
is KtElement -> PsiTreeUtil.getParentOfType(this, KtPropertyAccessor::class.java, KtNamedDeclaration::class.java, KtFile::class.java)!!
|
||||
is KtElement -> PsiTreeUtil.getParentOfType(
|
||||
this,
|
||||
KtPropertyAccessor::class.java,
|
||||
KtProperty::class.java,
|
||||
KtFunction::class.java,
|
||||
KtClassOrObject::class.java
|
||||
) ?: containingFile
|
||||
else -> ConflictsUtil.getContainer(this)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -170,8 +170,7 @@ class MoveConflictChecker(
|
||||
val usageFile = element.containingFile
|
||||
val usageVFile = usageFile.virtualFile ?: continue
|
||||
val usageModule = ModuleUtilCore.findModuleForFile(usageVFile, project) ?: continue
|
||||
val container = if (usageFile is PsiJavaFile) ConflictsUtil.getContainer(element) else usageFile
|
||||
val scopeDescription = RefactoringUIUtil.getDescription(container, true)
|
||||
val scopeDescription = RefactoringUIUtil.getDescription(element.getUsageContext(), true)
|
||||
val referencedElement = (if (usage is MoveRenameUsageInfo) usage.referencedElement else usage.element) ?: error(usage)
|
||||
val message = if (usageModule == targetModule && isInTestSources) {
|
||||
RefactoringBundle.message("0.referenced.in.1.will.not.be.accessible.from.production.of.module.2",
|
||||
|
||||
@@ -11,10 +11,10 @@ Crumbs:
|
||||
Tooltips:
|
||||
property <b><code>v</code></b>
|
||||
object : java.lang.Runnable
|
||||
property <b><code>v.<no name provided>.v2</code></b>
|
||||
property <b><code><no name provided>.v2</code></b>
|
||||
object : A, B
|
||||
function <b><code>v.<no name provided>.v2.<no name provided>.f()</code></b>
|
||||
function <b><code><no name provided>.f()</code></b>
|
||||
object : java.io.Serializable, XXX
|
||||
property <b><code>v.<no name provided>.v2.<no name provided>.f.<no name provided>.o</code></b>
|
||||
property <b><code><no name provided>.o</code></b>
|
||||
object
|
||||
function <b><code>v.<no name provided>.v2.<no name provided>.f.<no name provided>.o.<no name provided>.equals(Any?)</code></b>
|
||||
function <b><code><no name provided>.equals(Any?)</code></b>
|
||||
+3
-3
@@ -11,8 +11,8 @@ Tooltips:
|
||||
class <b><code>Outer</code></b>
|
||||
companion object <b><code>Outer.Companion</code></b>
|
||||
class <b><code>Outer.Companion.SomeClass</code></b>
|
||||
companion object <b><code>Outer.Companion.SomeClass.CompanionName</code></b>
|
||||
object <b><code>Outer.Companion.SomeClass.CompanionName.SomeObject</code></b>
|
||||
function <b><code>Outer.Companion.SomeClass.CompanionName.SomeObject.someFun(Int, Boolean) on String</code></b>
|
||||
companion object <b><code>SomeClass.CompanionName</code></b>
|
||||
object <b><code>SomeClass.CompanionName.SomeObject</code></b>
|
||||
function <b><code>SomeObject.someFun(Int, Boolean) on String</code></b>
|
||||
function <b><code>Outer.Companion.SomeClass.CompanionName.SomeObject.someFun.localFun()</code></b>
|
||||
fun(x: Int, y: Char)
|
||||
Vendored
+2
-2
@@ -1,3 +1,3 @@
|
||||
Class test2.J, referenced in property test2.pack.Bar.j, will not be accessible in module A
|
||||
Class test2.J, referenced in property test2.pack.Foo.j, will not be accessible in module A
|
||||
Class test2.J, referenced in property Bar.j, will not be accessible in module A
|
||||
Class test2.J, referenced in property Foo.j, will not be accessible in module A
|
||||
Class test2.pack.Foo, referenced in field J.foo, will not be accessible from module B
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
Property a1.internalTargetVal, referenced in file internalSource.kt, will not be accessible from module A
|
||||
Property a1.internalTargetVal, referenced in file internalSource.kt, will not be accessible from module A
|
||||
Property a1.internalTargetVal, referenced in property a2.sourceVal, will not be accessible from module A
|
||||
+1
-1
@@ -1 +1 @@
|
||||
Constructor JsName(String), referenced in function packJs.ClassUsageJs.foo(), will not be accessible in module A
|
||||
Constructor JsName(String), referenced in function ClassUsageJs.foo(), will not be accessible in module A
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
Constructor JvmStatic(), referenced in function packJvm.ClassUsageJvm.Companion.foo(), will not be accessible in module B
|
||||
Constructor JvmStatic(), referenced in function ClassUsageJvm.Companion.foo(), will not be accessible in module B
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
Class InternalContent uses function internalFun() which will be inaccessible after move
|
||||
Class packA1.InternalContent, referenced in file InternalSource.kt, will not be accessible from module A
|
||||
Class packA2.InternalContentUser, referenced in function packA1.InternalContent.useInternal(), will not be accessible in module B
|
||||
Function packA2.InternalContentUser.internalFun(), referenced in function packA1.InternalContent.useInternal(), will not be accessible in module B
|
||||
Class packA1.InternalContent, referenced in function InternalContentUser.useInternal(InternalContent), will not be accessible from module A
|
||||
Class packA2.InternalContentUser, referenced in function InternalContent.useInternal(), will not be accessible in module B
|
||||
Function InternalContentUser.internalFun(), referenced in function InternalContent.useInternal(), will not be accessible in module B
|
||||
Function useInternal(InternalContent) uses internal function internalFun() which will be inaccessible after move
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
Class test.Bar, referenced in field J.bar, will not be accessible from module A
|
||||
Class test.Foo, referenced in field J.foo, will not be accessible from module A
|
||||
Class test.J, referenced in property test.Bar.j, will not be accessible in module B
|
||||
Class test.J, referenced in property test.Foo.j, will not be accessible in module B
|
||||
Class test.J, referenced in property Bar.j, will not be accessible in module B
|
||||
Class test.J, referenced in property Foo.j, will not be accessible in module B
|
||||
Vendored
+2
-2
@@ -1,3 +1,3 @@
|
||||
Class test2.J, referenced in property test2.pack.Bar.j, will not be accessible in module A
|
||||
Class test2.J, referenced in property test2.pack.Foo.j, will not be accessible in module A
|
||||
Class test2.J, referenced in property Bar.j, will not be accessible in module A
|
||||
Class test2.J, referenced in property Foo.j, will not be accessible in module A
|
||||
Class test2.pack.Foo, referenced in field J.foo, will not be accessible from module B
|
||||
+1
-1
@@ -1 +1 @@
|
||||
Property a.val1, referenced in file test.kt, will not be accessible from module A
|
||||
Property a.val1, referenced in property a.val2, will not be accessible from module A
|
||||
+1
-1
@@ -1 +1 @@
|
||||
class test.A.C has 1 usage that is not safe to delete.
|
||||
class A.C has 1 usage that is not safe to delete.
|
||||
+1
-1
@@ -1 +1 @@
|
||||
object test.A.O has 1 usage that is not safe to delete.
|
||||
object A.O has 1 usage that is not safe to delete.
|
||||
idea/testData/refactoring/safeDelete/deleteProperty/kotlinProperty/propertyInLocalObject.kt.messages
Vendored
+1
-1
@@ -1 +1 @@
|
||||
property context.<no name provided>.addition has 1 usage that is not safe to delete.
|
||||
property <no name provided>.addition has 1 usage that is not safe to delete.
|
||||
Reference in New Issue
Block a user