i18n: add bundle for idea/refactoring/pushDown

This commit is contained in:
Roman Golyshev
2020-02-26 20:58:04 +03:00
committed by Dmitry Gridin
parent 37e1333fe1
commit 4fc76e25a8
4 changed files with 50 additions and 20 deletions
@@ -854,10 +854,16 @@ selected.code.fragment.has.multiple.output.values=Selected code fragment has mor
selected.code.fragment.has.output.values.and.exit.points=Selected code fragment has output values as well as alternative exit points
setter.of.0.will.become.invisible.after.extraction = Setter of {0} will become invisible after extraction
text.0.1.must.be.moved.with.sealed.parent.class.and.all.its.subclasses={0} ''{1}'' must be moved with sealed parent class and all its subclasses
text.0.already.contains.1={0} already contains {1}
text.0.already.contains.nested.class.1={0} already contains nested class named {1}
text.0.have.no.inheritors.warning={0} doesn''t have inheritors\nPushing members down will result in them being deleted. Would you like to proceed?
text.0.in.1.will.override.corresponding.member.of.2.after.refactoring={0} in {1} will override corresponding member of {2} after refactoring
text.0.inherits.from.1.it.will.not.be.affected.by.refactoring={0} inherits from {1}.\nIt won''t be affected by the refactoring
text.0.is.invalid.destination.package=''{0}'' is invalid destination package name
text.0.is.not.allowed.in.the.target.context=''{0}'' is not allowed in the target context
text.0.is.not.valid.package.name={0} is not a valid package name
text.0.to.inline={0} to inline
text.0.uses.1.which.is.not.accessible.from.2={0} uses {1}, which is not accessible from the {2}
text.0.uses.1.which.will.be.inaccessible.after.move={0} uses {1} which will be inaccessible after move
text.0.uses.1.which.will.not.be.accessible.from.subclass={0} uses {1} which won''t be accessible from the subclass.
text.0.uses.internal.1.which.will.be.inaccessible.after.move={0} uses internal {1} which will be inaccessible after move
@@ -881,6 +887,7 @@ text.choose.containing.file=Choose Containing File
text.class.0.already.contains.member.1={0} already contains {1}
text.class.0.already.exists.in.package.1=Class {0} already exists in package {1}
text.class.0.already.exists.in.the.target.scope=Class {0} already exists in the target scope
text.class.0.is.final={0} is final
text.constructor=constructor
text.create.destructuring.declaration=Create destructuring declaration
text.create.single.variable=Create single variable
@@ -934,6 +941,7 @@ text.no.elements.to.move.are.selected=No elements to move are selected
text.no.files.to.move=There is no given files to move
text.no.name.provided.for.type.alias=No name provided for type alias
text.no.package.corresponds.to.directory=No package corresponds to this directory
text.non.kotlin.0.will.not.be.affected.by.refactoring=Non-Kotlin {0} won''t be affected by the refactoring
text.package.directive.dont.match.file.location=Package directive doesn't match file location
text.parameter.0=parameter ''{0}''
text.parameter.name=Parameter &name:\u0020
@@ -949,6 +957,7 @@ text.property.in.ticks.0=property ''{0}''
text.property.with.getter=property with getter
text.property.with.initializer=property with initializer
text.property=property
text.pushed.member.will.not.be.available.in.0=Pushed member won''t be available in ''{0}''
text.qualified.call.will.not.be.processed.0=Qualified call won''t be processed: {0}
text.receiver.can.t.be.safely.transformed.to.value.argument=Receiver can''t be safely transformed to value argument: {0}
text.receiver=receiver
@@ -15,6 +15,8 @@ import com.intellij.refactoring.HelpID
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.util.CommonRefactoringUtil
import com.intellij.refactoring.util.RefactoringUIUtil
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.isInheritable
import org.jetbrains.kotlin.idea.refactoring.AbstractPullPushMembersHandler
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
@@ -27,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.KtParameter
const val PUSH_MEMBERS_DOWN = "Push Members Down"
val PUSH_MEMBERS_DOWN: String get() = RefactoringBundle.message("push.members.down.title")
class KotlinPushDownHandler : AbstractPullPushMembersHandler(
refactoringName = PUSH_MEMBERS_DOWN,
@@ -35,6 +37,7 @@ class KotlinPushDownHandler : AbstractPullPushMembersHandler(
wrongPositionMessage = RefactoringBundle.message("the.caret.should.be.positioned.inside.a.class.to.push.members.from")
) {
companion object {
@NonNls
const val PUSH_DOWN_TEST_HELPER_KEY = "PUSH_DOWN_TEST_HELPER_KEY"
}
@@ -44,7 +47,7 @@ class KotlinPushDownHandler : AbstractPullPushMembersHandler(
private fun reportFinalClassOrObject(project: Project, editor: Editor?, classOrObject: KtClassOrObject) {
val message = RefactoringBundle.getCannotRefactorMessage(
"${RefactoringUIUtil.getDescription(classOrObject, false)} is final".capitalize()
KotlinBundle.message("text.class.0.is.final", RefactoringUIUtil.getDescription(classOrObject, false)).capitalize()
)
CommonRefactoringUtil.showErrorHint(project, editor, message, PULL_MEMBERS_UP, HelpID.MEMBERS_PULL_UP)
}
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
@@ -98,8 +99,7 @@ class KotlinPushDownProcessor(
override fun preprocessUsages(refUsages: Ref<Array<UsageInfo>>): Boolean {
val usages = refUsages.get() ?: UsageInfo.EMPTY_ARRAY
if (usages.isEmpty()) {
val message = "${context.sourceClassDescriptor
.renderForConflicts()} doesn't have inheritors\nPushing members down will result in them being deleted. Would you like to proceed?"
val message = KotlinBundle.message("text.0.have.no.inheritors.warning", context.sourceClassDescriptor.renderForConflicts())
val answer = Messages.showYesNoDialog(message.capitalize(), PUSH_MEMBERS_DOWN, Messages.getWarningIcon())
if (answer == Messages.NO) return false
}
@@ -13,6 +13,7 @@ import com.intellij.usageView.UsageInfo
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper
import org.jetbrains.kotlin.idea.refactoring.pullUp.renderForConflicts
import org.jetbrains.kotlin.idea.references.KtReference
@@ -68,7 +69,10 @@ private fun checkConflicts(
if (targetClass !is KtClassOrObject) {
conflicts.putValue(
targetClass,
"Non-Kotlin ${RefactoringUIUtil.getDescription(targetClass, false)} won't be affected by the refactoring"
KotlinBundle.message(
"text.non.kotlin.0.will.not.be.affected.by.refactoring",
RefactoringUIUtil.getDescription(targetClass, false)
)
)
return
}
@@ -78,9 +82,11 @@ private fun checkConflicts(
?: TypeSubstitutor.EMPTY
if (!context.sourceClass.isInterface() && targetClass is KtClass && targetClass.isInterface()) {
val message = "${targetClassDescriptor.renderForConflicts()} " +
"inherits from ${context.sourceClassDescriptor.renderForConflicts()}.\n" +
"It won't be affected by the refactoring"
val message = KotlinBundle.message(
"text.0.inherits.from.1.it.will.not.be.affected.by.refactoring",
targetClassDescriptor.renderForConflicts(),
context.sourceClassDescriptor.renderForConflicts()
)
conflicts.putValue(targetClass, message.capitalize())
}
@@ -109,14 +115,20 @@ private fun checkMemberClashing(
val clashingDeclaration = clashingDescriptor?.source?.getPsi() as? KtNamedDeclaration
if (clashingDescriptor != null && clashingDeclaration != null) {
if (memberDescriptor.modality != Modality.ABSTRACT && member !in membersToKeepAbstract) {
val message =
"${targetClassDescriptor.renderForConflicts()} already contains ${clashingDescriptor.renderForConflicts()}"
val message = KotlinBundle.message(
"text.0.already.contains.1",
targetClassDescriptor.renderForConflicts(),
clashingDescriptor.renderForConflicts()
)
conflicts.putValue(clashingDeclaration, CommonRefactoringUtil.capitalize(message))
}
if (!clashingDeclaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
val message = "${clashingDescriptor.renderForConflicts()} in ${targetClassDescriptor.renderForConflicts()} " +
"will override corresponding member of ${context.sourceClassDescriptor.renderForConflicts()} " +
"after refactoring"
val message = KotlinBundle.message(
"text.0.in.1.will.override.corresponding.member.of.2.after.refactoring",
clashingDescriptor.renderForConflicts(),
targetClassDescriptor.renderForConflicts(),
context.sourceClassDescriptor.renderForConflicts()
)
conflicts.putValue(clashingDeclaration, CommonRefactoringUtil.capitalize(message))
}
}
@@ -128,8 +140,11 @@ private fun checkMemberClashing(
.filterIsInstance<KtClassOrObject>()
.firstOrNull() { it.name == member.name }
?.let {
val message = "${targetClassDescriptor.renderForConflicts()} " +
"already contains nested class named ${CommonRefactoringUtil.htmlEmphasize(member.name ?: "")}"
val message = KotlinBundle.message(
"text.0.already.contains.nested.class.1",
targetClassDescriptor.renderForConflicts(),
CommonRefactoringUtil.htmlEmphasize(member.name ?: "")
)
conflicts.putValue(it, message.capitalize())
}
}
@@ -156,7 +171,7 @@ private fun checkSuperCalls(
if (memberInSource !in membersToPush) {
conflicts.putValue(
qualifiedExpression,
"Pushed member won't be available in '${qualifiedExpression.text}'"
KotlinBundle.message("text.pushed.member.will.not.be.available.in.0", qualifiedExpression.text)
)
}
}
@@ -179,7 +194,7 @@ internal fun checkExternalUsages(
if (dispatchReceiver == null || dispatchReceiver is Qualifier) continue
val receiverClassDescriptor = dispatchReceiver.type.constructor.declarationDescriptor as? ClassDescriptor ?: continue
if (!DescriptorUtils.isSubclass(receiverClassDescriptor, targetClassDescriptor)) {
conflicts.putValue(callElement, "Pushed member won't be available in '${callElement.text}'")
conflicts.putValue(callElement, KotlinBundle.message("text.pushed.member.will.not.be.available.in.0", callElement.text))
}
}
}
@@ -195,9 +210,12 @@ private fun checkVisibility(
if (targetDescriptor is DeclarationDescriptorWithVisibility
&& !Visibilities.isVisibleIgnoringReceiver(targetDescriptor, targetClassDescriptor)
) {
val message = "${context.memberDescriptors.getValue(member).renderForConflicts()} " +
"uses ${targetDescriptor.renderForConflicts()}, " +
"which is not accessible from the ${targetClassDescriptor.renderForConflicts()}"
val message = KotlinBundle.message(
"text.0.uses.1.which.is.not.accessible.from.2",
context.memberDescriptors.getValue(member).renderForConflicts(),
targetDescriptor.renderForConflicts(),
targetClassDescriptor.renderForConflicts()
)
conflicts.putValue(target, message.capitalize())
}
}