diff --git a/idea/resources/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.properties b/idea/resources/messages/KotlinRefactoringBundle.properties similarity index 53% rename from idea/resources/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.properties rename to idea/resources/messages/KotlinRefactoringBundle.properties index 366dfa9e668..0eb8635d457 100644 --- a/idea/resources/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.properties +++ b/idea/resources/messages/KotlinRefactoringBundle.properties @@ -11,7 +11,6 @@ cannot.refactor.expression.has.unit.type=Cannot introduce expression of unit typ cannot.refactor.package.expression=Cannot introduce package reference extract.function=Extract Function cannot.extract.method=Cannot find statements to extract -cannot.find.class.to.extract=Cannot find class to extract method selected.code.fragment.has.multiple.output.values=Selected code fragment has more than 3 output values: declarations.are.used.outside.of.selected.code.fragment=Following declarations are used outside of selected code fragment: selected.code.fragment.has.multiple.exit.points=Selected code fragment has multiple exit points @@ -19,7 +18,6 @@ selected.code.fragment.has.output.values.and.exit.points=Selected code fragment parameter.types.are.not.denotable=Cannot extract method since following types are not denotable in the target scope: declarations.will.move.out.of.scope=Following declarations won't be available outside of extracted function body: cannot.extract.super.call=Cannot extract super-call -cannot.refactor.expression.should.have.inferred.type=Expression should have inferred type cannot.refactor.synthesized.function=Cannot refactor synthesized function ''{0}'' error.types.in.generated.function=Cannot generate function with erroneous return type cannot.introduce.parameter.of.0.type=Cannot introduce parameter of type ''{0}'' @@ -34,16 +32,46 @@ parameter.name.is.invalid=Parameter name ''{0}'' is invalid parameter.type.is.invalid=Parameter type ''{0}'' is invalid column.name.val.var=Val/Var -refactoring.move.specifc.element=Move {0} {1} -refactoring.move.selected.elements=Move selected elements refactoring.move.non.kotlin.file=Target must be a Kotlin file -package.private.0.will.no.longer.be.accessible.from.1=Package-private {0} will no longer be accessible from {1} -0.uses.package.private.1={0} uses package-private {1} 0.will.no.longer.be.accessible.after.extraction={0} will no longer be accessible after extraction 0.will.become.invisible.after.extraction={0} will become invisible after extraction setter.of.0.will.become.invisible.after.extraction = Setter of {0} will become invisible after extraction naming.convention.will.be.violated.after.rename=Naming conventions will be violated after rename -file.does.not.exist=File {0} does not exist.\nDo you want to create it? \ No newline at end of file +file.does.not.exist=File {0} does not exist.\nDo you want to create it? +text.caller.text.with.highlighted.callee.call.would.be.shown.here=Caller text\nwith highlighted callee call would be shown here +text.callee.text.would.be.shown.here=Callee text would be shown here +text.anonymous=[Anonymous] +label.text.visibility=&Visibility:\u0020 +label.text.type=&Type:\u0020 +label.text.name=&Name:\u0020 +error.text.invalid.default.receiver.value=Invalid default receiver value +error.text.invalid.receiver.type=Invalid receiver type +error.text.invalid.return.type=Invalid return type +error.text.invalid.name=Invalid name +label.text.receiver.type=Receiver &type:\u0020 +checkbox.text.extension.property=E&xtension property:\u0020 +label.text.default.receiver.value=&Default receiver value:\u0020 +error.text.can.t.change.signature.of.method=Can''t change signature of {0} method +text.default.value=\ // default value = {0} +message.text.return.type.cannot.be.resolved=Return type ''{0}'' cannot be resolved.\nContinue? +text.parameter=parameter ''{0}'' +text.receiver=receiver +message.type.for.cannot.be.resolved=Type ''{0}'' for {1} cannot be resolved.\nContinue? +message.change.signature.is.not.applicable.to.dynamically.invoked.functions=Change signature is not applicable to dynamically invoked functions +text.function=function +text.constructor=constructor +text.there.is.already.a.variable.0.in.1.it.will.conflict.with.the.new.parameter=There is already a variable ''{0}'' in {1}. It will conflict with the new parameter. +text.function.already.exists=Function already exists: ''{0}'' +text.there.is.already.a.parameter=There is already a parameter ''{0}'' in {1}. It will conflict with the new parameter. +text.duplicating.local.variable=Duplicating local variable ''{0}'' +text.duplicating.property=Duplicating property ''{0}'' +text.duplicating.parameter=Duplicating parameter ''{0}'' +text.parameter.reference.can.t.be.safely.replaced.with.0.since.1.is.ambiguous.in.this.context=Parameter reference can''t be safely replaced with {0} since {1} is ambiguous in this context +text.parameter.reference.can.t.be.safely.replaced.with.0.since.target.function.can.t.be.referenced.in.this.context=Parameter reference can''t be safely replaced with {0} since target function can''t be referenced in this context +text.explicit.receiver.is.already.present.in.call.element.0=Explicit receiver is already present in call element: {0} +text.receiver.can.t.be.safely.transformed.to.value.argument=Receiver can''t be safely transformed to value argument: {0} +text.0.will.no.longer.be.accessible.after.signature.change={0} will no longer be accessible after signature change +column.name.receiver=Receiver: \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.kt index 8b1949b6bf1..d72884e0d73 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringBundle.kt @@ -1,34 +1,18 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ + package org.jetbrains.kotlin.idea.refactoring -import com.intellij.CommonBundle import org.jetbrains.annotations.NonNls import org.jetbrains.annotations.PropertyKey -import org.jetbrains.kotlin.idea.core.util.KotlinBundleBase -import java.util.* +import org.jetbrains.kotlin.util.AbstractKotlinBundle -object KotlinRefactoringBundle : KotlinBundleBase() { - @NonNls - private const val BUNDLE = "org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle" - - override fun createBundle(): ResourceBundle = ResourceBundle.getBundle(BUNDLE) +@NonNls +private const val BUNDLE = "messages.KotlinRefactoringBundle" +object KotlinRefactoringBundle : AbstractKotlinBundle(BUNDLE) { @JvmStatic - fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): String { - return CommonBundle.message(bundle, key, *params) - } + fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): String = getMessage(key, params) } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt index 6461d908cea..579beb8b073 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignature.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.core.getDeepestSuperDeclarations import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.broadcastRefactoringExit import org.jetbrains.kotlin.idea.refactoring.changeSignature.ui.KotlinChangePropertySignatureDialog import org.jetbrains.kotlin.idea.refactoring.changeSignature.ui.KotlinChangeSignatureDialog @@ -90,7 +91,13 @@ class KotlinChangeSignature( ) is PsiMethod -> { if (baseDeclaration.language != JavaLanguage.INSTANCE) { - Messages.showErrorDialog("Can't change signature of ${baseDeclaration.language.displayName} method", commandName) + Messages.showErrorDialog( + KotlinRefactoringBundle.message( + "error.text.can.t.change.signature.of.method", + baseDeclaration.language.displayName + ), + commandName + ) return } @@ -113,7 +120,12 @@ class KotlinChangeSignature( } if (baseDeclaration.language != JavaLanguage.INSTANCE) { - Messages.showErrorDialog("Can't change signature of ${baseDeclaration.language.displayName} method", commandName) + Messages.showErrorDialog( + KotlinRefactoringBundle.message( + "error.text.can.t.change.signature.of.method", + baseDeclaration.language.displayName + ), commandName + ) return } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt index 495495d1d43..1f3049001d8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureHandler.kt @@ -141,8 +141,8 @@ class KotlinChangeSignatureHandler : ChangeSignatureHandler { CodeInsightUtils.showErrorHint( project, editor, - "Change signature is not applicable to dynamically invoked functions", - "Change Signature", + KotlinRefactoringBundle.message("message.change.signature.is.not.applicable.to.dynamically.invoked.functions"), + RefactoringBundle.message("changeSignature.refactoring.name"), null ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt index 2e00223e056..2d77e78a36a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureProcessor.kt @@ -29,6 +29,7 @@ import com.intellij.refactoring.rename.UnresolvableCollisionUsageInfo import com.intellij.usageView.UsageInfo import com.intellij.usageView.UsageViewDescriptor import com.intellij.util.containers.MultiMap +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.broadcastRefactoringExit import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinFunctionCallUsage import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinImplicitReceiverUsage @@ -55,7 +56,10 @@ class KotlinChangeSignatureProcessor( } override fun createUsageViewDescriptor(usages: Array): UsageViewDescriptor { - val subject = if (ktChangeInfo.kind.isConstructor) "constructor" else "function" + val subject = if (ktChangeInfo.kind.isConstructor) + KotlinRefactoringBundle.message("text.constructor") + else + KotlinRefactoringBundle.message("text.function") return KotlinUsagesViewDescriptor(myChangeInfo.method, RefactoringBundle.message("0.to.change.signature", subject)) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt index cfd96594ff7..1d9b5a67f51 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt @@ -185,7 +185,11 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { object : UnresolvableCollisionUsageInfo(callElement, null) { override fun getDescription(): String { val signature = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.render(callerDescriptor) - return "There is already a variable '$currentName' in $signature. It will conflict with the new parameter." + return KotlinRefactoringBundle.message( + "text.there.is.already.a.variable.0.in.1.it.will.conflict.with.the.new.parameter", + currentName, + signature + ) } } ) @@ -562,7 +566,10 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { if (candidateTypes == newTypes) { result.putValue( conflictElement, - "Function already exists: '" + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + "'" + KotlinRefactoringBundle.message( + "text.function.already.exists", + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + ) ) break } @@ -574,7 +581,7 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { val parameterName = parameter.name if (!parameterNames.add(parameterName)) { - result.putValue(function, "Duplicating parameter '$parameterName'") + result.putValue(function, KotlinRefactoringBundle.message("text.duplicating.parameter", parameterName)) } if (parametersScope != null) { @@ -582,7 +589,10 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { for (property in parametersScope.getVariablesFromImplicitReceivers(Name.identifier(parameterName))) { val propertyDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(property) ?: continue if (propertyDeclaration.parent !is KtParameterList) { - result.putValue(propertyDeclaration, "Duplicating property '$parameterName'") + result.putValue( + propertyDeclaration, + KotlinRefactoringBundle.message("text.duplicating.property", parameterName) + ) break } } @@ -590,7 +600,7 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { for (variable in parametersScope.getContributedVariables(Name.identifier(parameterName), NoLookupLocation.FROM_IDE)) { if (variable is ValueParameterDescriptor) continue val conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(variable) - result.putValue(conflictElement, "Duplicating local variable '$parameterName'") + result.putValue(conflictElement, KotlinRefactoringBundle.message("text.duplicating.local.variable", parameterName)) } } } @@ -629,7 +639,7 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { val name = parameterInfo.name val parameter = existingParameters[name] ?: continue - result.putValue(parameter, "There is already a parameter '$name' in $signature. It will conflict with the new parameter.") + result.putValue(parameter, KotlinRefactoringBundle.message("text.there.is.already.a.parameter", name, signature)) } } @@ -660,7 +670,11 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { if (labelExpr != null && newContext.get(BindingContext.AMBIGUOUS_LABEL_TARGET, labelExpr) != null) { result.putValue( originalExpr, - "Parameter reference can't be safely replaced with " + newExprText + " since " + labelExpr.text + " is ambiguous in this context" + KotlinRefactoringBundle.message( + "text.parameter.reference.can.t.be.safely.replaced.with.0.since.1.is.ambiguous.in.this.context", + newExprText, + labelExpr.text + ) ) continue } @@ -670,7 +684,10 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { if (thisTargetPsi != null && callable.isAncestor(thisTargetPsi, true)) { result.putValue( originalExpr, - "Parameter reference can't be safely replaced with $newExprText since target function can't be referenced in this context" + KotlinRefactoringBundle.message( + "text.parameter.reference.can.t.be.safely.replaced.with.0.since.target.function.can.t.be.referenced.in.this.context", + newExprText + ) ) } } @@ -695,8 +712,10 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { else -> continue@loop } - val message = - "Explicit receiver is already present in call element: " + CommonRefactoringUtil.htmlEmphasize(elementToReport.text) + val message = KotlinRefactoringBundle.message( + "text.explicit.receiver.is.already.present.in.call.element.0", + CommonRefactoringUtil.htmlEmphasize(elementToReport.text) + ) result.putValue(callElement, message) } } @@ -717,7 +736,10 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { if (qualifiedExpression is KtSafeQualifiedExpression) { result.putValue( callElement, - "Receiver can't be safely transformed to value argument: ${CommonRefactoringUtil.htmlEmphasize(qualifiedExpression.text)}" + KotlinRefactoringBundle.message( + "text.receiver.can.t.be.safely.transformed.to.value.argument", + CommonRefactoringUtil.htmlEmphasize(qualifiedExpression.text) + ) ) } } @@ -756,7 +778,10 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { val descriptor = originalRef.getResolvedCall(originalContext)!!.candidateDescriptor val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(callable.project, descriptor) val prefix = if (declaration != null) RefactoringUIUtil.getDescription(declaration, true) else originalRef.text - result.putValue(originalRef, prefix.capitalize() + " will no longer be accessible after signature change") + result.putValue( + originalRef, + KotlinRefactoringBundle.message("text.0.will.no.longer.be.accessible.after.signature.change", prefix.capitalize()) + ) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt index a2028682dfb..d3d76c73357 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMethodDescriptor import org.jetbrains.kotlin.idea.hierarchy.calls.CalleeReferenceProcessor import org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallHierarchyNodeDescriptor +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext @@ -48,9 +49,9 @@ class KotlinCallerChooser( override fun findDeepestSuperMethods(method: PsiElement) = method.toLightMethods().singleOrNull()?.findDeepestSuperMethods() - override fun getEmptyCallerText() = "Caller text \nwith highlighted callee call would be shown here" + override fun getEmptyCallerText() = KotlinRefactoringBundle.message("text.caller.text.with.highlighted.callee.call.would.be.shown.here") - override fun getEmptyCalleeText() = "Callee text would be shown here" + override fun getEmptyCalleeText() = KotlinRefactoringBundle.message("text.callee.text.would.be.shown.here") } class KotlinMethodNode( @@ -74,7 +75,7 @@ class KotlinMethodNode( val renderedFunction = KotlinCallHierarchyNodeDescriptor.renderNamedFunction(descriptor) val renderedFunctionWithContainer = containerName?.let { - "${if (it.isSpecial) "[Anonymous]" else it.asString()}.$renderedFunction" + "${if (it.isSpecial) KotlinRefactoringBundle.message("text.anonymous") else it.asString()}.$renderedFunction" } ?: renderedFunction val attributes = if (isEnabled) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt index f33d216433a..2b8ff0f67cf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangePropertySignatureDialog.kt @@ -14,6 +14,7 @@ import com.intellij.util.ui.FormBuilder import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.changeSignature.* import org.jetbrains.kotlin.idea.refactoring.validateElement import org.jetbrains.kotlin.psi.KtExpression @@ -42,7 +43,7 @@ class KotlinChangePropertySignatureDialog( private var receiverDefaultValueField: EditorTextField? = null init { - title = "Change Signature" + title = KotlinRefactoringBundle.message("title.change.signature") init() } @@ -62,25 +63,24 @@ class KotlinChangePropertySignatureDialog( return with(FormBuilder.createFormBuilder()) { val baseDeclaration = methodDescriptor.baseDeclaration - if (!((baseDeclaration as? KtProperty)?.isLocal ?: false)) { + if ((baseDeclaration as? KtProperty)?.isLocal != true) { visibilityCombo.selectedItem = methodDescriptor.visibility - addLabeledComponent("&Visibility: ", visibilityCombo) + addLabeledComponent(KotlinRefactoringBundle.message("label.text.visibility"), visibilityCombo) } - addLabeledComponent("&Name: ", nameField) + addLabeledComponent(KotlinRefactoringBundle.message("label.text.name"), nameField) val returnTypeCodeFragment = psiFactory.createTypeCodeFragment( methodDescriptor.returnTypeInfo.render(), baseDeclaration ) returnTypeField = EditorTextField(documentManager.getDocument(returnTypeCodeFragment), myProject, KotlinFileType.INSTANCE) - addLabeledComponent("&Type: ", returnTypeField) + addLabeledComponent(KotlinRefactoringBundle.message("label.text.type"), returnTypeField) if (baseDeclaration is KtProperty) { addSeparator() - val receiverTypeCheckBox = JCheckBox("Extension property: ") - receiverTypeCheckBox.setMnemonic('x') + val receiverTypeCheckBox = JCheckBox(KotlinRefactoringBundle.message("checkbox.text.extension.property")) receiverTypeCheckBox.addActionListener { updateReceiverUI() } receiverTypeCheckBox.isSelected = methodDescriptor.receiver != null addComponent(receiverTypeCheckBox) @@ -92,8 +92,7 @@ class KotlinChangePropertySignatureDialog( ) receiverTypeField = EditorTextField(documentManager.getDocument(receiverTypeCodeFragment), myProject, KotlinFileType.INSTANCE) - receiverTypeLabel = JLabel("Receiver type: ") - receiverTypeLabel.setDisplayedMnemonic('t') + receiverTypeLabel = JLabel(KotlinRefactoringBundle.message("label.text.receiver.type")) addLabeledComponent(receiverTypeLabel, receiverTypeField) if (methodDescriptor.receiver == null) { @@ -103,8 +102,7 @@ class KotlinChangePropertySignatureDialog( myProject, KotlinFileType.INSTANCE ) - receiverDefaultValueLabel = JLabel("Default receiver value: ") - receiverDefaultValueLabel!!.setDisplayedMnemonic('D') + receiverDefaultValueLabel = JLabel(KotlinRefactoringBundle.message("label.text.default.receiver.value")) addLabeledComponent(receiverDefaultValueLabel, receiverDefaultValueField!!) } @@ -123,12 +121,12 @@ class KotlinChangePropertySignatureDialog( override fun canRun() { val psiFactory = KtPsiFactory(myProject) - psiFactory.createSimpleName(nameField.text).validateElement("Invalid name") - psiFactory.createType(returnTypeField.text).validateElement("Invalid return type") + psiFactory.createSimpleName(nameField.text).validateElement(KotlinRefactoringBundle.message("error.text.invalid.name")) + psiFactory.createType(returnTypeField.text).validateElement(KotlinRefactoringBundle.message("error.text.invalid.return.type")) if (receiverTypeCheckBox?.isSelected == true) { - psiFactory.createType(receiverTypeField.text).validateElement("Invalid receiver type") + psiFactory.createType(receiverTypeField.text).validateElement(KotlinRefactoringBundle.message("error.text.invalid.receiver.type")) } - getDefaultReceiverValue()?.validateElement("Invalid default receiver value") + getDefaultReceiverValue()?.validateElement(KotlinRefactoringBundle.message("error.text.invalid.default.receiver.value")) } override fun doAction() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt index ee40b2bd17e..5f07ab46845 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt @@ -39,7 +39,6 @@ import com.intellij.ui.EditorTextField import com.intellij.ui.components.JBLabel import com.intellij.ui.treeStructure.Tree import com.intellij.util.Consumer -import com.intellij.util.IJSwingUtilities import com.intellij.util.ui.UIUtil import com.intellij.util.ui.table.JBTableRow import com.intellij.util.ui.table.JBTableRowEditor @@ -106,10 +105,10 @@ class KotlinChangeSignatureDialog( val typeText = item.typeCodeFragment.text val defaultValue = item.defaultValueCodeFragment.text val separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length + 1) - var text = "$valOrVar$parameterName:$separator$typeText" - - if (StringUtil.isNotEmpty(defaultValue)) { - text += " // default value = $defaultValue" + val text = "$valOrVar$parameterName:$separator$typeText" + if (StringUtil.isNotEmpty(defaultValue)) { + KotlinRefactoringBundle.message("text.default.value", defaultValue) + } else { + "" } val field = object : EditorTextField(" $text", project, fileType) { @@ -335,7 +334,10 @@ class KotlinChangeSignatureDialog( ) { if (Messages.showOkCancelDialog( myProject, - "Return type '${myReturnTypeCodeFragment!!.text}' cannot be resolved.\nContinue?", + KotlinRefactoringBundle.message( + "message.text.return.type.cannot.be.resolved", + myReturnTypeCodeFragment?.text.toString() + ), RefactoringBundle.message("changeSignature.refactoring.name"), Messages.getWarningIcon() ) != Messages.OK @@ -346,10 +348,17 @@ class KotlinChangeSignatureDialog( for (item in parametersTableModel.items) { if (item.typeCodeFragment.getTypeInfo(isCovariant = true, forPreview = false, reanalyse = true).type == null) { - val paramText = if (item.parameter != parametersTableModel.receiver) "parameter '${item.parameter.name}'" else "receiver" + val paramText = if (item.parameter != parametersTableModel.receiver) + KotlinRefactoringBundle.message("text.parameter", item.parameter.name) + else + KotlinRefactoringBundle.message("text.receiver") if (Messages.showOkCancelDialog( myProject, - "Type '${item.typeCodeFragment.text}' for $paramText cannot be resolved.\nContinue?", + KotlinRefactoringBundle.message( + "message.type.for.cannot.be.resolved", + item.typeCodeFragment.text, + paramText + ), RefactoringBundle.message("changeSignature.refactoring.name"), Messages.getWarningIcon() ) != Messages.OK diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 index 772a0856469..6991486c862 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 @@ -106,10 +106,10 @@ class KotlinChangeSignatureDialog( val typeText = item.typeCodeFragment.text val defaultValue = item.defaultValueCodeFragment.text val separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length + 1) - var text = "$valOrVar$parameterName:$separator$typeText" - - if (StringUtil.isNotEmpty(defaultValue)) { - text += " // default value = $defaultValue" + val text = "$valOrVar$parameterName:$separator$typeText" + if (StringUtil.isNotEmpty(defaultValue)) { + KotlinRefactoringBundle.message("text.default.value", defaultValue) + } else { + "" } val field = object : EditorTextField(" $text", project, fileType) { @@ -336,7 +336,10 @@ class KotlinChangeSignatureDialog( ) { if (Messages.showOkCancelDialog( myProject, - "Return type '${myReturnTypeCodeFragment!!.text}' cannot be resolved.\nContinue?", + KotlinRefactoringBundle.message( + "message.text.return.type.cannot.be.resolved", + myReturnTypeCodeFragment?.text.toString() + ), RefactoringBundle.message("changeSignature.refactoring.name"), Messages.getWarningIcon() ) != Messages.OK @@ -347,10 +350,17 @@ class KotlinChangeSignatureDialog( for (item in parametersTableModel.items) { if (item.typeCodeFragment.getTypeInfo(isCovariant = true, forPreview = false).type == null) { - val paramText = if (item.parameter != parametersTableModel.receiver) "parameter '${item.parameter.name}'" else "receiver" + val paramText = if (item.parameter != parametersTableModel.receiver) + KotlinRefactoringBundle.message("text.parameter", item.parameter.name) + else + KotlinRefactoringBundle.message("text.receiver") if (Messages.showOkCancelDialog( myProject, - "Type '${item.typeCodeFragment.text}' for $paramText cannot be resolved.\nContinue?", + KotlinRefactoringBundle.message( + "message.type.for.cannot.be.resolved", + item.typeCodeFragment.text, + paramText + ), RefactoringBundle.message("changeSignature.refactoring.name"), Messages.getWarningIcon() ) != Messages.OK diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinFunctionParameterTableModel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinFunctionParameterTableModel.java index 5b007f4e0ff..ce1eb5addfe 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinFunctionParameterTableModel.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinFunctionParameterTableModel.java @@ -24,6 +24,7 @@ import com.intellij.ui.BooleanTableCellRenderer; import com.intellij.util.ui.ColumnInfo; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.idea.KotlinFileType; +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle; import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor; import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinParameterInfo; @@ -71,7 +72,7 @@ public class KotlinFunctionParameterTableModel extends KotlinCallableParameterTa private KotlinParameterInfo receiver; public ReceiverColumn(Project project, @Nullable KotlinMethodDescriptor methodDescriptor) { - super("Receiver:"); + super(KotlinRefactoringBundle.message("column.name.receiver")); this.project = project; this.receiver = methodDescriptor != null ? methodDescriptor.getReceiver() : null; }