Move: Show more accurate message when moving subclass of a sealed class

#KT-23065 Fixed
This commit is contained in:
Alexey Sedunov
2018-03-01 19:21:28 +03:00
parent 5f43bd56b4
commit 12d5a72697
2 changed files with 10 additions and 2 deletions
@@ -34,6 +34,7 @@ import com.intellij.refactoring.util.MoveRenameUsageInfo
import com.intellij.refactoring.util.NonCodeUsageInfo
import com.intellij.refactoring.util.RefactoringUIUtil
import com.intellij.usageView.UsageInfo
import com.intellij.usageView.UsageViewTypeLocation
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.asJava.namedUnwrappedElement
import org.jetbrains.kotlin.asJava.toLightMethods
@@ -491,7 +492,14 @@ class MoveConflictChecker(
if (isToBeMoved(rootClass) && subclasses.all { isToBeMoved(it) }) continue
conflicts.putValue(rootClass, "Sealed class '${rootClass.name}' must be moved with all its subclasses")
val message = if (elementToMove == rootClass) {
"Sealed class '${rootClass.name}' must be moved with all its subclasses"
}
else {
val type = ElementDescriptionUtil.getElementDescription(elementToMove, UsageViewTypeLocation.INSTANCE).capitalize()
"$type '${rootClass.name}' must be moved with sealed parent class and all its subclasses"
}
conflicts.putValue(elementToMove, message)
}
}
@@ -1 +1 @@
Sealed class 'Expr' must be moved with all its subclasses
Class 'Expr' must be moved with sealed parent class and all its subclasses