diff --git a/idea/resources/messages/KotlinRefactoringBundle.properties b/idea/resources/messages/KotlinRefactoringBundle.properties index b7691865a61..3677f0a4c44 100644 --- a/idea/resources/messages/KotlinRefactoringBundle.properties +++ b/idea/resources/messages/KotlinRefactoringBundle.properties @@ -1,4 +1,6 @@ +0.1.is.never.used={0} ''{1}'' is never used 0.has.detected.1.code.fragments.in.2.that.can.be.replaced.with.3={0} has detected {1} code {1,choice,1#fragment|2#fragments} in {2} that can be replaced with {3}. Would you like to review and replace {1,choice,1#it|2#them}? +0.usages.are.not.supported.by.the.inline.refactoring.they.won.t.be.processed={0} usages are not supported by the Inline refactoring. They won''t be processed. 0.will.become.invisible.after.extraction={0} will become invisible after extraction 0.will.no.longer.be.accessible.after.extraction={0} will no longer be accessible after extraction action.text.append=Append @@ -6,6 +8,7 @@ action.text.cancel=Cancel action.text.overwrite=Overwrite cannot.extract.method=Cannot find statements to extract cannot.extract.super.call=Cannot extract super-call +cannot.inline.property.with.accessor.s.and.backing.field=Cannot inline property with accessor(s) and backing field cannot.introduce.parameter.of.0.type=Cannot introduce parameter of type ''{0}'' cannot.refactor.expression.has.unit.type=Cannot introduce expression of unit type cannot.refactor.no.container=Cannot refactor in this place @@ -16,20 +19,42 @@ cannot.refactor.not.expression=Cannot find an expression to introduce cannot.refactor.package.expression=Cannot introduce package reference cannot.refactor.syntax.errors=Cannot refactor due to erroneous code cannot.refactor.synthesized.function=Cannot refactor synthesized function ''{0}'' +checkbox.text.declare.with.var=Declare with &var checkbox.text.extension.property=E&xtension property:\u0020 +checkbox.text.introduce.default.value=Introduce &default value +checkbox.text.replace.all.occurrences.0=&Replace all occurrences ({0}) +checkbox.text.specify.type.explicitly=Specify &type explicitly column.name.receiver=Receiver: column.name.val.var=Val/Var declarations.are.used.outside.of.selected.code.fragment=Following declarations are used outside of selected code fragment: declarations.will.move.out.of.scope=Following declarations won't be available outside of extracted function body: +description.a.reference.to.extracted.type.parameter=a reference to extracted type parameter error.cant.refactor.vararg.functions=Can't refactor the function with variable arguments +error.hint.text.cannot.inline.0.from.a.decompiled.file=Cannot inline ''{0}'' from a decompiled file error.text.can.t.change.signature.of.method=Can''t change signature of {0} method error.text.can.t.copy.class.to.the.containing.file=Can''t copy class to the containing file +error.text.can.t.generate.0.1=Can''t generate {0}: {1} +error.text.can.t.introduce.lambda.parameter.for.this.expression=Can''t introduce lambda parameter for this expression +error.text.can.t.introduce.property.for.this.expression=Can''t introduce property for this expression +error.text.different.name.expected=Different name expected +error.text.expression.has.no.type=Expression has no type +error.text.extraction.from.expect.class.is.not.yet.supported=Extraction from expect class is not yet supported +error.text.extraction.from.non.jvm.class.is.not.yet.supported=Extraction from non-JVM class is not yet supported error.text.inline.function.is.not.supported.for.functions.with.multiple.return.statements=Inline Function is not supported for functions with multiple return statements. error.text.inline.function.is.not.supported.for.functions.with.return.statements.not.at.the.end.of.the.body=Inline Function is not supported for functions with return statements not at the end of the body. +error.text.interface.cannot.be.extracted.from.an.annotation.class=Interface cannot be extracted from an annotation class +error.text.introduce.parameter.is.not.available.for.default.value=Introduce Parameter is not available for default value +error.text.introduce.parameter.is.not.available.inside.of.annotation.entries=Introduce Parameter is not available inside of annotation entries error.text.invalid.default.receiver.value=Invalid default receiver value error.text.invalid.name=Invalid name +error.text.invalid.parameter.name=Invalid parameter name +error.text.invalid.parameter.type=Invalid parameter type error.text.invalid.receiver.type=Invalid receiver type error.text.invalid.return.type=Invalid return type +error.text.no.type.to.refactor=No type to refactor +error.text.refactoring.is.not.applicable.in.the.current.context=Refactoring is not applicable in the current context +error.text.superclass.cannot.be.extracted.from.an.annotation.class=Superclass cannot be extracted from an annotation class +error.text.type.reference.is.expected=Type reference is expected error.types.in.generated.function=Cannot generate function with erroneous return type error.wrong.caret.position.function.or.constructor.name=The caret should be positioned at the name of the function or constructor to be refactored. extract.function=Extract Function @@ -38,71 +63,112 @@ file.does.not.exist=File {0} does not exist.\nDo you want to create it? function.name.is.invalid=Function name is invalid introduce.parameter=Introduce Parameter introduce.property=Introduce Property +introduce.type.parameter.to.declaration=Introduce type parameter to declaration +introduce.type.parameter=Introduce Type Parameter introduce.variable=Introduce Variable label.text.default.receiver.value=&Default receiver value:\u0020 +label.text.introduce.as=&Introduce as:\u0020 label.text.name=&Name:\u0020 label.text.receiver.type=Receiver &type:\u0020 +label.text.target.file.name=Target file name: label.text.type=&Type:\u0020 label.text.visibility=&Visibility:\u0020 message.change.signature.is.not.applicable.to.dynamically.invoked.functions=Change signature is not applicable to dynamically invoked functions +message.do.not.show.for.local.variables.in.future=Do not show for local variables in future message.text.return.type.cannot.be.resolved=Return type ''{0}'' cannot be resolved.\nContinue? +message.text.type.alias.0.is.never.used=Type alias ''{0}'' is never used message.type.for.cannot.be.resolved=Type ''{0}'' for {1} cannot be resolved.\nContinue? +name.extract.interface=Extract Interface +name.inline.type.alias=Inline Type Alias +name.introduce.import.alias=Introduce Import Alias +name.introduce.lambda.parameter=Introduce Lambda Parameter +name.introduce.parameter1=Introduce Parameter +name.introduce.type.alias=Introduce Type Alias +name.kdoc.for.abstracts=KDoc for abstracts naming.convention.will.be.violated.after.rename=Naming conventions will be violated after rename +non.kotlin.usage.0=Non-Kotlin usage: {0} parameter.name.is.invalid=Parameter name ''{0}'' is invalid parameter.type.is.invalid=Parameter type ''{0}'' is invalid parameter.types.are.not.denotable=Cannot extract method since following types are not denotable in the target scope: refactoring.move.non.kotlin.file=Target must be a Kotlin file return.type.is.invalid=Return type is invalid +searching.usages.of.0.parameter=Searching usages of ''{0}''parameter selected.code.fragment.has.multiple.exit.points=Selected code fragment has multiple exit points selected.code.fragment.has.multiple.output.values=Selected code fragment has more than 3 output values: 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.is.not.allowed.in.the.target.context=''{0}'' is not allowed in the target context +text.0.to.inline={0} to inline text.0.will.no.longer.be.accessible.after.signature.change={0} will no longer be accessible after signature change +text.all=All text.anonymous=[Anonymous] text.callee.text.would.be.shown.here=Callee text would be shown here text.caller.text.with.highlighted.callee.call.would.be.shown.here=Caller text\nwith highlighted callee call would be shown here text.cannot.inline.0.1.usages=Cannot inline {0}/{1} usages +text.class.0.already.exists.in.the.target.scope=Class {0} already exists in the target scope text.constructor=constructor +text.create.destructuring.declaration=Create destructuring declaration +text.create.single.variable=Create single variable text.declaration=declaration text.default.value=\ // default value = {0} text.duplicating.local.variable=Duplicating local variable ''{0}'' text.duplicating.parameter=Duplicating parameter ''{0}'' text.duplicating.property=Duplicating property ''{0}'' text.explicit.receiver.is.already.present.in.call.element.0=Explicit receiver is already present in call element: {0} +text.extract.superclass=Extract Superclass text.file.0.already.exists.in.1=File {0} already exists in {1} text.function.already.exists=Function already exists: ''{0}'' text.function=function text.inline.0.1.2=Inline {0} ''{1}''? {2} text.inline.0=Inline {0} text.inline.all.references.and.0.the.1=Inline all references and {0} the kind {1} +text.inline.recursive.function.is.supported.only.on.references=Inline recursive function is supported only on references text.inline.this.reference.and.keep.the.0=Inline this reference and keep the {0} text.inlining.0.1=Inlining {0} {1} +text.introduce.default.value=Intro&duce default value text.keep=keep +text.lambda.parameter=lambda parameter +text.lambda.parameters=Lambda ¶meters:\u0020 +text.lambda.return.type=Lambda return &type +text.lazy.property=lazy property text.local.property=property text.local.variable=local variable +text.name=Name +text.no.name.provided.for.type.alias=No name provided for type alias +text.parameter.0=parameter ''{0}'' +text.parameter.name=Parameter &name:\u0020 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.parameter.type=Parameter &type:\u0020 text.parameter=parameter ''{0}'' +text.parameters=&Parameters +text.proceed.with.extraction=Proceed with extraction +text.process.duplicates=Process Duplicates +text.property.with.getter=property with getter +text.property.with.initializer=property with initializer +text.property=property text.receiver.can.t.be.safely.transformed.to.value.argument=Receiver can''t be safely transformed to value argument: {0} text.receiver=receiver +text.refactoring.can.t.be.performed.on.the.selected.code.element=Refactoring can''t be performed on the selected code element +text.refactoring.is.not.applicable.to.this.code.fragment=Refactoring is not applicable to this code fragment +text.remove.0.no.longer.used=Remove {0} no longer used text.remove=remove +text.select.target.code.block.file=Select target code block / file +text.select.target.code.block=Select target code block +text.select.target.file=Select target file +text.the.following=The following text.there.is.already.a.parameter=There is already a parameter ''{0}'' in {1}. It will conflict with the new parameter. 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.type.alias.cannot.refer.to.types.which.aren.t.accessible.in.the.scope.where.it.s.defined=Type alias cannot refer to types which aren''t accessible in the scope where it''s defined +text.type.alias.name.must.be.a.valid.identifier.0=Type alias name must be a valid identifier: {0} text.type.alias=type alias +text.type.already.exists.in.the.target.scope=Type {0} already exists in the target scope +text.type.parameter.names.must.be.distinct=Type parameter names must be distinct +text.type.parameters=Type &Parameters +text.type=Type text.update.usages.to.reflect.declaration.0.move=Update usages to reflect {0, choice, 0#declaration|1#declarations} move +text.variable=variable title.inline.function=Inline Function -text.0.to.inline={0} to inline -text.inline.recursive.function.is.supported.only.on.references=Inline recursive function is supported only on references -name.inline.type.alias=Inline Type Alias -message.text.type.alias.0.is.never.used=Type alias ''{0}'' is never used -message.do.not.show.for.local.variables.in.future=Do not show for local variables in future -error.hint.text.cannot.inline.0.from.a.decompiled.file=Cannot inline ''{0}'' from a decompiled file -cannot.inline.property.with.accessor.s.and.backing.field=Cannot inline property with accessor(s) and backing field -property=Property -variable=Variable -0.1.is.never.used={0} ''{1}'' is never used -0.usages.are.not.supported.by.the.inline.refactoring.they.won.t.be.processed={0} usages are not supported by the Inline refactoring. They won''t be processed. -the.following=The following -all=All -unsupported.usage.0=Unsupported usage: {0} -non.kotlin.usage.0=Non-Kotlin usage: {0} \ No newline at end of file +title.introduce.parameter.to.declaration=Introduce parameter to declaration +title.select.target.code.block=Select target code block +unsupported.usage.0=Unsupported usage: {0} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt index b020e77b19f..71f85688549 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt @@ -84,10 +84,10 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand if (referenceExpressions.isEmpty() && conflicts.isEmpty) { val kind = if (declaration.isLocal) - KotlinRefactoringBundle.message("variable") + KotlinRefactoringBundle.message("text.variable") else - KotlinRefactoringBundle.message("property") - return showErrorHint(project, editor, KotlinRefactoringBundle.message("0.1.is.never.used", kind, name)) + KotlinRefactoringBundle.message("text.property") + return showErrorHint(project, editor, KotlinRefactoringBundle.message("0.1.is.never.used", kind.capitalize(), name)) } val referencesInOriginalFile = referenceExpressions.filter { it.containingFile == file } @@ -117,9 +117,9 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand if (!conflicts.isEmpty) { val conflictsCopy = conflicts.copy() val allOrSome = if (referenceExpressions.isEmpty()) - KotlinRefactoringBundle.message("all") + KotlinRefactoringBundle.message("text.all") else - KotlinRefactoringBundle.message("the.following") + KotlinRefactoringBundle.message("text.the.following") conflictsCopy.putValue( null, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ExtractSuperRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ExtractSuperRefactoring.kt index d638f98b80d..a23ac1e6241 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ExtractSuperRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ExtractSuperRefactoring.kt @@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.codeInsight.shorten.performDelayedRefactoringRequests import org.jetbrains.kotlin.idea.core.* import org.jetbrains.kotlin.idea.core.util.runSynchronouslyWithProgress +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.insertDeclaration import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo import org.jetbrains.kotlin.idea.refactoring.memberInfo.getChildrenToAnalyze @@ -133,7 +134,15 @@ class ExtractSuperRefactoring( targetSibling.getResolutionScope() .findClassifier(Name.identifier(newClassName), NoLookupLocation.FROM_IDE) ?.let { DescriptorToSourceUtilsIde.getAnyDeclaration(project, it) } - ?.let { conflicts.putValue(it, "Class $newClassName already exists in the target scope") } + ?.let { + conflicts.putValue( + it, + KotlinRefactoringBundle.message( + "text.class.0.already.exists.in.the.target.scope", + newClassName + ) + ) + } } val elementsToMove = getElementsToMove(memberInfos, originalClass, isExtractInterface).keys diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractInterfaceHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractInterfaceHandler.kt index 45ae5e87c91..55e0a682abc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractInterfaceHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractInterfaceHandler.kt @@ -17,17 +17,18 @@ package org.jetbrains.kotlin.idea.refactoring.introduce.extractClass import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ui.KotlinExtractInterfaceDialog import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject object KotlinExtractInterfaceHandler : KotlinExtractSuperHandlerBase(true) { - const val REFACTORING_NAME = "Extract Interface" + val REFACTORING_NAME = KotlinRefactoringBundle.message("name.extract.interface") override fun getErrorMessage(klass: KtClassOrObject): String? { val superMessage = super.getErrorMessage(klass) if (superMessage != null) return superMessage - if (klass is KtClass && klass.isAnnotation()) return "Interface cannot be extracted from an annotation class" + if (klass is KtClass && klass.isAnnotation()) return KotlinRefactoringBundle.message("error.text.interface.cannot.be.extracted.from.an.annotation.class") return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperHandlerBase.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperHandlerBase.kt index e6cd09d5679..ba7ddee49c9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperHandlerBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperHandlerBase.kt @@ -31,11 +31,8 @@ import com.intellij.refactoring.extractSuperclass.ExtractSuperClassUtil import com.intellij.refactoring.lang.ElementsHandler import com.intellij.refactoring.util.CommonRefactoringUtil import org.jetbrains.kotlin.asJava.toLightClass -import org.jetbrains.kotlin.idea.refactoring.SeparateFileWrapper -import org.jetbrains.kotlin.idea.refactoring.chooseContainerElementIfNecessary -import org.jetbrains.kotlin.idea.refactoring.getExtractionContainers +import org.jetbrains.kotlin.idea.refactoring.* import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ui.KotlinExtractSuperDialogBase -import org.jetbrains.kotlin.idea.refactoring.showWithTransaction import org.jetbrains.kotlin.idea.util.isExpectDeclaration import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile @@ -92,7 +89,10 @@ abstract class KotlinExtractSuperHandlerBase(private val isExtractInterface: Boo chooseContainerElementIfNecessary( containers, editor, - if (containers.first() is KtFile) "Select target file" else "Select target code block / file", + if (containers.first() is KtFile) + KotlinRefactoringBundle.message("text.select.target.file") + else + KotlinRefactoringBundle.message("text.select.target.code.block.file"), true, { it }, { doInvoke(klass, if (it is SeparateFileWrapper) klass.containingFile.parent!! else it) } @@ -111,8 +111,8 @@ abstract class KotlinExtractSuperHandlerBase(private val isExtractInterface: Boo } internal open fun getErrorMessage(klass: KtClassOrObject): String? = when { - klass.isExpectDeclaration() -> "Extraction from expect class is not yet supported" - klass.toLightClass() == null -> "Extraction from non-JVM class is not yet supported" + klass.isExpectDeclaration() -> KotlinRefactoringBundle.message("error.text.extraction.from.expect.class.is.not.yet.supported") + klass.toLightClass() == null -> KotlinRefactoringBundle.message("error.text.extraction.from.non.jvm.class.is.not.yet.supported") else -> null } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperclassHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperclassHandler.kt index 7671333f0d2..0e7c28b9471 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperclassHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/KotlinExtractSuperclassHandler.kt @@ -18,12 +18,13 @@ package org.jetbrains.kotlin.idea.refactoring.introduce.extractClass import com.intellij.psi.PsiElement import com.intellij.refactoring.RefactoringBundle +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ui.KotlinExtractSuperclassDialog import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject object KotlinExtractSuperclassHandler : KotlinExtractSuperHandlerBase(false) { - const val REFACTORING_NAME = "Extract Superclass" + val REFACTORING_NAME = KotlinRefactoringBundle.message("text.extract.superclass") override fun getErrorMessage(klass: KtClassOrObject): String? { val superMessage = super.getErrorMessage(klass) @@ -31,7 +32,7 @@ object KotlinExtractSuperclassHandler : KotlinExtractSuperHandlerBase(false) { if (klass is KtClass) { if (klass.isInterface()) return RefactoringBundle.message("superclass.cannot.be.extracted.from.an.interface") if (klass.isEnum()) return RefactoringBundle.message("superclass.cannot.be.extracted.from.an.enum") - if (klass.isAnnotation()) return "Superclass cannot be extracted from an annotation class" + if (klass.isAnnotation()) return KotlinRefactoringBundle.message("error.text.superclass.cannot.be.extracted.from.an.annotation.class") } return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ui/KotlinExtractSuperDialogBase.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ui/KotlinExtractSuperDialogBase.kt index 29e2a4d79d5..7fbfb2e33a5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ui/KotlinExtractSuperDialogBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractClass/ui/KotlinExtractSuperDialogBase.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.core.unquote import org.jetbrains.kotlin.idea.core.util.onTextChange +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.extractClass.ExtractSuperInfo import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPanel @@ -98,7 +99,7 @@ abstract class KotlinExtractSuperDialogBase( protected abstract fun createMemberInfoModel(): MemberInfoModelBase - override fun getDocCommentPanelName() = "KDoc for abstracts" + override fun getDocCommentPanelName() = KotlinRefactoringBundle.message("name.kdoc.for.abstracts") override fun checkConflicts() = conflictChecker(this) @@ -116,7 +117,7 @@ abstract class KotlinExtractSuperDialogBase( val targetDirectoryPanel = super.createDestinationRootPanel() val targetFileNamePanel = JPanel(BorderLayout()).apply { border = BorderFactory.createEmptyBorder(10, 0, 0, 0) - val label = JBLabel("Target file name:") + val label = JBLabel(KotlinRefactoringBundle.message("label.text.target.file.name")) add(label, BorderLayout.NORTH) label.labelFor = fileNameField add(fileNameField, BorderLayout.CENTER) @@ -174,7 +175,7 @@ abstract class KotlinExtractSuperDialogBase( override fun validateName(name: String): String? { return when { !name.quoteIfNeeded().isIdentifier() -> RefactoringMessageUtil.getIncorrectIdentifierMessage(name) - name.unquote() == mySourceClass.name -> "Different name expected" + name.unquote() == mySourceClass.name -> KotlinRefactoringBundle.message("error.text.different.name.expected") else -> null } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt index c4546bd0fa9..0f69ba6b347 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ExtractKotlinFunctionHandler.kt @@ -69,7 +69,7 @@ class ExtractKotlinFunctionHandler( EXTRACT_FUNCTION, editor, file, - "Select target code block", + KotlinRefactoringBundle.message("title.select.target.code.block"), listOf(CodeInsightUtils.ElementKind.EXPRESSION), ::validateExpressionElements, { elements, parent -> parent.getExtractionContainers(elements.size == 1, allContainersEnabled) }, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/ExtractFunctionParameterTablePanel.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/ExtractFunctionParameterTablePanel.kt index d54e5e09a39..6a680f3fe63 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/ExtractFunctionParameterTablePanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/ExtractFunctionParameterTablePanel.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui import com.intellij.ui.components.JBComboBoxLabel import com.intellij.ui.components.editors.JBComboBoxTableCellEditorComponent import com.intellij.util.ui.AbstractTableCellEditor +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.Parameter import org.jetbrains.kotlin.idea.refactoring.introduce.ui.AbstractParameterTablePanel import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers @@ -28,7 +29,7 @@ open class ExtractFunctionParameterTablePanel : AbstractParameterTablePanel" else originalParameter.name + name = if (isReceiver) KotlinRefactoringBundle.message("text.receiver") else originalParameter.name } override fun toParameter() = originalParameter.copy(name, type) @@ -38,7 +39,7 @@ open class ExtractFunctionParameterTablePanel : AbstractParameterTablePanel
Proceed with extraction", + "$message

${KotlinRefactoringBundle.message("text.proceed.with.extraction")}", MessageType.WARNING ) { event -> if (event?.eventType == HyperlinkEvent.EventType.ACTIVATED) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt index 98ba37250a2..d851d42c223 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/duplicateUtil.kt @@ -91,7 +91,7 @@ fun processDuplicates( scopeDescription, usageDescription ), - "Process Duplicates", + KotlinRefactoringBundle.message("text.process.duplicates"), Messages.getQuestionIcon() ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt index 5e947ce237b..313ef62ea1f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.inspections.UseExpressionBodyInspection import org.jetbrains.kotlin.idea.intentions.InfixCallToOrdinaryIntention import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.* import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValue.* import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputValueBoxer.AsTuple @@ -47,7 +48,11 @@ import java.util.* private fun buildSignature(config: ExtractionGeneratorConfiguration, renderer: DescriptorRenderer): CallableBuilder { val extractionTarget = config.generatorOptions.target if (!extractionTarget.isAvailable(config.descriptor)) { - val message = "Can't generate ${extractionTarget.targetName}: ${config.descriptor.extractionData.codeFragmentText}" + val message = KotlinRefactoringBundle.message( + "error.text.can.t.generate.0.1", + extractionTarget.targetName, + config.descriptor.extractionData.codeFragmentText + ) throw BaseRefactoringProcessor.ConflictsInTestsException(listOf(message)) } @@ -126,7 +131,11 @@ fun ExtractionGeneratorConfiguration.getDeclarationPattern( if (!extractionTarget.isAvailable(descriptor)) { throw BaseRefactoringProcessor.ConflictsInTestsException( listOf( - "Can't generate ${extractionTarget.targetName}: ${descriptor.extractionData.codeFragmentText}" + KotlinRefactoringBundle.message( + "error.text.can.t.generate.0.1", + extractionTarget.targetName, + descriptor.extractionData.codeFragmentText + ) ) ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceImportAlias/KotlinIntroduceImportAliasHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceImportAlias/KotlinIntroduceImportAliasHandler.kt index b52a40adea1..310eba5e6ad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceImportAlias/KotlinIntroduceImportAliasHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceImportAlias/KotlinIntroduceImportAliasHandler.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.core.KotlinNameSuggester import org.jetbrains.kotlin.idea.core.moveCaret import org.jetbrains.kotlin.idea.core.util.CodeInsightUtils import org.jetbrains.kotlin.idea.imports.importableFqName +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.selectElement import org.jetbrains.kotlin.idea.references.KtReference import org.jetbrains.kotlin.idea.references.findPsiDeclarations @@ -43,7 +44,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.checkWithAttachment object KotlinIntroduceImportAliasHandler : RefactoringActionHandler { - const val REFACTORING_NAME = "Introduce Import Alias" + val REFACTORING_NAME = KotlinRefactoringBundle.message("name.introduce.import.alias") @get:TestOnly var suggestedImportAliasNames: Collection = emptyList() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt index 0d8086ffba3..0c5a4c1086d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt @@ -19,6 +19,7 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.ui.JBColor import com.intellij.ui.NonFocusableCheckBox +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractKotlinInplaceIntroducer import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinInplaceVariableIntroducer @@ -160,9 +161,8 @@ class KotlinInplaceParameterIntroducer( initFormComponents { addComponent(previewComponent) - val defaultValueCheckBox = NonFocusableCheckBox("Introduce default value") + val defaultValueCheckBox = NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.introduce.default.value")) defaultValueCheckBox.isSelected = descriptor.withDefaultValue - defaultValueCheckBox.setMnemonic('d') defaultValueCheckBox.addActionListener { descriptor = descriptor.copy(withDefaultValue = defaultValueCheckBox.isSelected) updateTitle(variable) @@ -171,9 +171,8 @@ class KotlinInplaceParameterIntroducer( val occurrenceCount = descriptor.occurrencesToReplace.size if (occurrenceCount > 1) { - val replaceAllCheckBox = NonFocusableCheckBox("Replace all occurrences ($occurrenceCount)") + val replaceAllCheckBox = NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.replace.all.occurrences.0", occurrenceCount)) replaceAllCheckBox.isSelected = true - replaceAllCheckBox.setMnemonic('R') addComponent(replaceAllCheckBox) this@KotlinInplaceParameterIntroducer.replaceAllCheckBox = replaceAllCheckBox } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt index 1110c1cc556..78044cf2c32 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt @@ -15,6 +15,7 @@ import com.intellij.refactoring.ui.RefactoringDialog import com.intellij.ui.NonFocusableCheckBox import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.core.util.isMultiLine +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.ExtractFunctionParameterTablePanel import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.KotlinExtractFunctionDialog import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.* @@ -112,8 +113,7 @@ class KotlinIntroduceParameterDialog private constructor( gbConstraints.weightx = 0.0 gbConstraints.weighty = 0.0 gbConstraints.gridy = 0 - val nameLabel = JLabel("Parameter name: ") - nameLabel.setDisplayedMnemonic('n') + val nameLabel = JLabel(KotlinRefactoringBundle.message("text.parameter.name")) nameLabel.labelFor = nameField panel.add(nameLabel, gbConstraints) @@ -129,8 +129,12 @@ class KotlinIntroduceParameterDialog private constructor( gbConstraints.gridx = 0 gbConstraints.gridy++ gbConstraints.fill = GridBagConstraints.NONE - val typeLabel = JLabel(if (lambdaExtractionDescriptor != null) "Lambda return type" else "Parameter type: ") - typeLabel.setDisplayedMnemonic('t') + val typeLabel = JLabel( + if (lambdaExtractionDescriptor != null) + KotlinRefactoringBundle.message("text.lambda.return.type") + else + KotlinRefactoringBundle.message("text.parameter.type") + ) typeLabel.labelFor = typeField panel.add(typeLabel, gbConstraints) @@ -160,8 +164,7 @@ class KotlinIntroduceParameterDialog private constructor( gbConstraints.gridx = 0 gbConstraints.gridy++ gbConstraints.fill = GridBagConstraints.NONE - val parametersLabel = JLabel("Lambda parameters: ") - parametersLabel.setDisplayedMnemonic('p') + val parametersLabel = JLabel(KotlinRefactoringBundle.message("text.lambda.parameters")) parametersLabel.labelFor = parameterTablePanel panel.add(parametersLabel, gbConstraints) @@ -180,9 +183,8 @@ class KotlinIntroduceParameterDialog private constructor( gbConstraints.gridwidth = 2 gbConstraints.gridy++ - val defaultValueCheckBox = NonFocusableCheckBox("Introduce default value") + val defaultValueCheckBox = NonFocusableCheckBox(KotlinRefactoringBundle.message("text.introduce.default.value")) defaultValueCheckBox.isSelected = descriptor.withDefaultValue - defaultValueCheckBox.setMnemonic('d') defaultValueCheckBox.addActionListener { updateRemoveParamCheckBoxes() } panel.add(defaultValueCheckBox, gbConstraints) @@ -192,9 +194,8 @@ class KotlinIntroduceParameterDialog private constructor( if (occurrenceCount > 1) { gbConstraints.gridy++ - val replaceAllCheckBox = NonFocusableCheckBox("Replace all occurrences ($occurrenceCount)") + val replaceAllCheckBox = NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.replace.all.occurrences.0", occurrenceCount)) replaceAllCheckBox.isSelected = true - replaceAllCheckBox.setMnemonic('R') replaceAllCheckBox.addActionListener { updateRemoveParamCheckBoxes() } panel.add(replaceAllCheckBox, gbConstraints) this.replaceAllCheckBox = replaceAllCheckBox @@ -205,8 +206,11 @@ class KotlinIntroduceParameterDialog private constructor( } for (parameter in descriptor.parametersToRemove) { - val removeWhat = if (parameter is KtParameter) "parameter '${parameter.name}'" else "receiver" - val cb = NonFocusableCheckBox("Remove $removeWhat no longer used") + val removeWhat = if (parameter is KtParameter) + KotlinRefactoringBundle.message("text.parameter.0", parameter.name) + else + KotlinRefactoringBundle.message("text.receiver") + val cb = NonFocusableCheckBox(KotlinRefactoringBundle.message("text.remove.0.no.longer.used", removeWhat)) removeParamsCheckBoxes[cb] = parameter cb.isSelected = true @@ -221,8 +225,8 @@ class KotlinIntroduceParameterDialog private constructor( override fun canRun() { val psiFactory = KtPsiFactory(myProject) - psiFactory.createExpressionIfPossible(nameField.enteredName.quoteIfNeeded()).validateElement("Invalid parameter name") - psiFactory.createTypeIfPossible(typeField.enteredName).validateElement("Invalid parameter type") + psiFactory.createExpressionIfPossible(nameField.enteredName.quoteIfNeeded()).validateElement(KotlinRefactoringBundle.message("error.text.invalid.parameter.name")) + psiFactory.createTypeIfPossible(typeField.enteredName).validateElement(KotlinRefactoringBundle.message("error.text.invalid.parameter.type")) } override fun doAction() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index bbf915ee41f..62b0ecb4413 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -177,7 +177,7 @@ fun selectNewParameterContext( operationName = INTRODUCE_PARAMETER, editor = editor, file = file, - title = "Introduce parameter to declaration", + title = KotlinRefactoringBundle.message("title.introduce.parameter.to.declaration"), elementKinds = listOf(CodeInsightUtils.ElementKind.EXPRESSION), elementValidator = ::validateExpressionElements, getContainers = { _, parent -> @@ -222,7 +222,7 @@ open class KotlinIntroduceParameterHandler( } if (expressionType == null) { - showErrorHint(project, editor, "Expression has no type", INTRODUCE_PARAMETER) + showErrorHint(project, editor, KotlinRefactoringBundle.message("error.text.expression.has.no.type"), INTRODUCE_PARAMETER) return } @@ -378,11 +378,21 @@ open class KotlinIntroduceParameterHandler( val elementAtCaret = file.findElementAt(editor.caretModel.offset) ?: return if (elementAtCaret.getNonStrictParentOfType() != null) { - showErrorHint(project, editor, "Introduce Parameter is not available inside of annotation entries", INTRODUCE_PARAMETER) + showErrorHint( + project, + editor, + KotlinRefactoringBundle.message("error.text.introduce.parameter.is.not.available.inside.of.annotation.entries"), + INTRODUCE_PARAMETER + ) return } if (elementAtCaret.getNonStrictParentOfType() != null) { - showErrorHint(project, editor, "Introduce Parameter is not available for default value", INTRODUCE_PARAMETER) + showErrorHint( + project, + editor, + KotlinRefactoringBundle.message("error.text.introduce.parameter.is.not.available.for.default.value"), + INTRODUCE_PARAMETER + ) return } @@ -416,7 +426,10 @@ private fun findInternalUsagesOfParametersAndReceiver( targetDescriptor: FunctionDescriptor ): MultiMap? { val usages = MultiMap() - val searchComplete = targetParent.project.runSynchronouslyWithProgress("Searching usages of '${targetParent.name}' parameter", true) { + val searchComplete = targetParent.project.runSynchronouslyWithProgress( + KotlinRefactoringBundle.message("searching.usages.of.0.parameter", targetParent.name), + true + ) { runReadAction { targetParent.getValueParameters() .filter { !it.hasValOrVar() } @@ -502,7 +515,12 @@ open class KotlinIntroduceLambdaParameterHandler( ) { val lambdaExtractionDescriptor = helper.configureExtractLambda(descriptorWithConflicts.descriptor) if (!ExtractionTarget.FAKE_LAMBDALIKE_FUNCTION.isAvailable(lambdaExtractionDescriptor)) { - showErrorHint(project, editor, "Can't introduce lambda parameter for this expression", INTRODUCE_LAMBDA_PARAMETER) + showErrorHint( + project, + editor, + KotlinRefactoringBundle.message("error.text.can.t.introduce.lambda.parameter.for.this.expression"), + INTRODUCE_LAMBDA_PARAMETER + ) return } @@ -533,7 +551,5 @@ open class KotlinIntroduceLambdaParameterHandler( } } -const val INTRODUCE_PARAMETER_REFACTORING_ID: String = "kotlin.refactoring.introduceParameter" - -const val INTRODUCE_PARAMETER: String = "Introduce Parameter" -const val INTRODUCE_LAMBDA_PARAMETER: String = "Introduce Lambda Parameter" +val INTRODUCE_PARAMETER: String = KotlinRefactoringBundle.message("name.introduce.parameter1") +val INTRODUCE_LAMBDA_PARAMETER: String = KotlinRefactoringBundle.message("name.introduce.lambda.parameter") diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt index 2e8f60c2159..70c882fd7dd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt @@ -13,6 +13,7 @@ import com.intellij.openapi.util.Pass import com.intellij.psi.PsiElement import com.intellij.ui.NonFocusableCheckBox import com.intellij.ui.PopupMenuListenerAdapter +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.ExtractionResult import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.ExtractionTarget import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.generateDeclaration @@ -89,8 +90,7 @@ class KotlinInplacePropertyIntroducer( this } - val propertyKindLabel = JLabel("Introduce as: ") - propertyKindLabel.setDisplayedMnemonic('I') + val propertyKindLabel = JLabel(KotlinRefactoringBundle.message("label.text.introduce.as")) propertyKindLabel.labelFor = propertyKindComboBox val panel = JPanel() @@ -127,9 +127,8 @@ class KotlinInplacePropertyIntroducer( if (occurrenceCount > 1) { addPanelControl( ControlWrapper { - val replaceAllCheckBox = NonFocusableCheckBox("Replace all occurrences ($occurrenceCount)") + val replaceAllCheckBox = NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.replace.all.occurrences.0", occurrenceCount)) replaceAllCheckBox.isSelected = replaceAll - replaceAllCheckBox.setMnemonic('R') replaceAllCheckBox.addActionListener { replaceAll = replaceAllCheckBox.isSelected } replaceAllCheckBox } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt index 8ce28eb62bf..124d6345602 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinIntroducePropertyHandler.kt @@ -61,7 +61,12 @@ class KotlinIntroducePropertyHandler( val options = ExtractionGeneratorOptions.DEFAULT.copy(target = target, delayInitialOccurrenceReplacement = true) doRefactor(ExtractionGeneratorConfiguration(descriptor, options), onFinish) } else { - showErrorHint(project, editor, "Can't introduce property for this expression", INTRODUCE_PROPERTY) + showErrorHint( + project, + editor, + KotlinRefactoringBundle.message("error.text.can.t.introduce.property.for.this.expression"), + INTRODUCE_PROPERTY + ) } } } @@ -71,7 +76,7 @@ class KotlinIntroducePropertyHandler( INTRODUCE_PROPERTY, editor, file, - "Select target code block", + KotlinRefactoringBundle.message("title.select.target.code.block"), listOf(CodeInsightUtils.ElementKind.EXPRESSION), ::validateExpressionElements, { _, parent -> diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/IntroduceTypeAliasHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/IntroduceTypeAliasHandler.kt index ebfc9122e30..7dccac06743 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/IntroduceTypeAliasHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/IntroduceTypeAliasHandler.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.idea.core.util.CodeInsightUtils.ElementKind.TYPE_CONSTRUCTOR import org.jetbrains.kotlin.idea.core.util.CodeInsightUtils.ElementKind.TYPE_ELEMENT import org.jetbrains.kotlin.idea.project.languageVersionSettings +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSupportProvider import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractIntroduceAction @@ -32,7 +33,7 @@ import org.jetbrains.kotlin.psi.psiUtil.* open class KotlinIntroduceTypeAliasHandler : RefactoringActionHandler { companion object { @JvmField - val REFACTORING_NAME = "Introduce Type Alias" + val REFACTORING_NAME = KotlinRefactoringBundle.message("name.introduce.type.alias") val INSTANCE = KotlinIntroduceTypeAliasHandler() } @@ -46,7 +47,7 @@ open class KotlinIntroduceTypeAliasHandler : RefactoringActionHandler { REFACTORING_NAME, editor, file, - "Select target code block", + KotlinRefactoringBundle.message("title.select.target.code.block"), listOf(TYPE_ELEMENT, TYPE_CONSTRUCTOR), { null }, { _, parent -> listOf(parent.containingFile) }, @@ -74,9 +75,11 @@ open class KotlinIntroduceTypeAliasHandler : RefactoringActionHandler { val errorMessage = when (elementToExtract) { is KtSimpleNameExpression -> { - if (!(isTypeConstructorReference(elementToExtract) || isDoubleColonReceiver(elementToExtract))) "Type reference is expected" else null + if (!(isTypeConstructorReference(elementToExtract) || isDoubleColonReceiver(elementToExtract))) KotlinRefactoringBundle.message( + "error.text.type.reference.is.expected" + ) else null } - !is KtTypeElement -> "No type to refactor" + !is KtTypeElement -> KotlinRefactoringBundle.message("error.text.no.type.to.refactor") else -> null } if (errorMessage != null) return showErrorHint(project, editor, errorMessage, REFACTORING_NAME) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/introduceTypeAliasImpl.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/introduceTypeAliasImpl.kt index f1e085a74b0..22dd816967c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/introduceTypeAliasImpl.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/introduceTypeAliasImpl.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.idea.core.CollectingNameValidator import org.jetbrains.kotlin.idea.core.KotlinNameSuggester import org.jetbrains.kotlin.idea.core.compareDescriptors import org.jetbrains.kotlin.idea.core.replaced +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.insertDeclaration import org.jetbrains.kotlin.idea.util.getResolutionScope import org.jetbrains.kotlin.idea.util.psi.patternMatching.KotlinPsiRange @@ -110,7 +111,7 @@ fun IntroduceTypeAliasData.analyze(): IntroduceTypeAliasAnalysisResult { val typeParameters = (typeParameterNames zip brokenReferences).map { TypeParameter(it.first, groupedReferencesToExtract[it.second]) } if (typeParameters.any { it.typeReferenceInfos.any { info -> info.reference.typeElement == originalTypeElement } }) { - return IntroduceTypeAliasAnalysisResult.Error("Type alias cannot refer to types which aren't accessible in the scope where it's defined") + return IntroduceTypeAliasAnalysisResult.Error(KotlinRefactoringBundle.message("text.type.alias.cannot.refer.to.types.which.aren.t.accessible.in.the.scope.where.it.s.defined")) } val descriptor = IntroduceTypeAliasDescriptor(this, "Dummy", null, typeParameters) @@ -134,19 +135,19 @@ fun IntroduceTypeAliasDescriptor.validate(): IntroduceTypeAliasDescriptorWithCon val originalType = originalData.originalTypeElement when { name.isEmpty() -> - conflicts.putValue(originalType, "No name provided for type alias") + conflicts.putValue(originalType, KotlinRefactoringBundle.message("text.no.name.provided.for.type.alias")) !name.isIdentifier() -> - conflicts.putValue(originalType, "Type alias name must be a valid identifier: $name") + conflicts.putValue(originalType, KotlinRefactoringBundle.message("text.type.alias.name.must.be.a.valid.identifier.0", name)) originalData.getTargetScope().findClassifier(Name.identifier(name), NoLookupLocation.FROM_IDE) != null -> - conflicts.putValue(originalType, "Type $name already exists in the target scope") + conflicts.putValue(originalType, KotlinRefactoringBundle.message("text.type.already.exists.in.the.target.scope", name)) } if (typeParameters.distinctBy { it.name }.size != typeParameters.size) { - conflicts.putValue(originalType, "Type parameter names must be distinct") + conflicts.putValue(originalType, KotlinRefactoringBundle.message("text.type.parameter.names.must.be.distinct")) } if (visibility != null && visibility !in originalData.getApplicableVisibilities()) { - conflicts.putValue(originalType, "'$visibility' is not allowed in the target context") + conflicts.putValue(originalType, KotlinRefactoringBundle.message("text.0.is.not.allowed.in.the.target.context", visibility)) } return IntroduceTypeAliasDescriptorWithConflicts(this, conflicts) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java index eb96ed04240..bca5d35d3dd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeAlias/ui/KotlinIntroduceTypeAliasDialog.java @@ -28,6 +28,7 @@ import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.idea.KotlinFileType; +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle; import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringUtilKt; import org.jetbrains.kotlin.idea.refactoring.introduce.introduceTypeAlias.IntroduceTypeAliasDescriptor; import org.jetbrains.kotlin.idea.refactoring.introduce.introduceTypeAlias.IntroduceTypeAliasImplKt; @@ -191,7 +192,7 @@ public class KotlinIntroduceTypeAliasDialog extends DialogWrapper { }; parameterTablePanel.init(originalDescriptor.getTypeParameters()); - inputParametersPanel.setText("Type &Parameters"); + inputParametersPanel.setText(KotlinRefactoringBundle.message("text.type.parameters")); inputParametersPanel.setLabelFor(parameterTablePanel.getTable()); inputParametersPanel.add(parameterTablePanel); } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeParameter/KotlinIntroduceTypeParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeParameter/KotlinIntroduceTypeParameterHandler.kt index b57db15ad14..2f14b18dee8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeParameter/KotlinIntroduceTypeParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceTypeParameter/KotlinIntroduceTypeParameterHandler.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.core.util.CodeInsightUtils import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createTypeParameter.CreateTypeParameterByUnresolvedRefActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createTypeParameter.CreateTypeParameterFromUsageFix import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createTypeParameter.getPossibleTypeParameterContainers +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractIntroduceAction import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.processDuplicates import org.jetbrains.kotlin.idea.refactoring.introduce.introduceTypeAlias.KotlinIntroduceTypeAliasHandler @@ -53,14 +54,14 @@ import org.jetbrains.kotlin.utils.keysToMap object KotlinIntroduceTypeParameterHandler : RefactoringActionHandler { @JvmField - val REFACTORING_NAME = "Introduce Type Parameter" + val REFACTORING_NAME = KotlinRefactoringBundle.message("introduce.type.parameter") fun selectElements(editor: Editor, file: KtFile, continuation: (elements: List, targetParent: PsiElement) -> Unit) { selectElementsWithTargetParent( REFACTORING_NAME, editor, file, - "Introduce type parameter to declaration", + KotlinRefactoringBundle.message("introduce.type.parameter.to.declaration"), listOf(CodeInsightUtils.ElementKind.TYPE_ELEMENT), { null }, { _, parent -> getPossibleTypeParameterContainers(parent) }, @@ -71,7 +72,12 @@ object KotlinIntroduceTypeParameterHandler : RefactoringActionHandler { fun doInvoke(project: Project, editor: Editor, elements: List, targetParent: PsiElement) { val targetOwner = targetParent as KtTypeParameterListOwner val typeElementToExtract = - elements.singleOrNull() as? KtTypeElement ?: return showErrorHint(project, editor, "No type to refactor", REFACTORING_NAME) + elements.singleOrNull() as? KtTypeElement ?: return showErrorHint( + project, + editor, + KotlinRefactoringBundle.message("error.text.no.type.to.refactor"), + REFACTORING_NAME + ) val typeElementToExtractPointer = typeElementToExtract.createSmartPointer() @@ -90,7 +96,12 @@ object KotlinIntroduceTypeParameterHandler : RefactoringActionHandler { val createTypeParameterData = CreateTypeParameterByUnresolvedRefActionFactory.extractFixData(typeElementToExtract, defaultName)?.let { it.copy(typeParameters = listOf(it.typeParameters.single().copy(upperBoundType = originalType)), declaration = targetOwner) - } ?: return showErrorHint(project, editor, "Refactoring is not applicable in the current context", REFACTORING_NAME) + } ?: return showErrorHint( + project, + editor, + KotlinRefactoringBundle.message("error.text.refactoring.is.not.applicable.in.the.current.context"), + REFACTORING_NAME + ) project.executeCommand(REFACTORING_NAME) { val newTypeParameter = @@ -134,7 +145,7 @@ object KotlinIntroduceTypeParameterHandler : RefactoringActionHandler { restoredOwner, UsageViewTypeLocation.INSTANCE ) + " '${restoredOwner.name}'", - "a reference to extracted type parameter" + KotlinRefactoringBundle.message("description.a.reference.to.extracted.type.parameter") ) restoredTypeParameter.extendsBound?.let { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt index c582ef0ca76..257412aeea4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceUtil.kt @@ -122,7 +122,12 @@ fun selectElementsWithTargetParent( return when (elementKinds.singleOrNull()) { CodeInsightUtils.ElementKind.EXPRESSION -> showErrorHintByKey("cannot.refactor.no.expression") CodeInsightUtils.ElementKind.TYPE_ELEMENT -> showErrorHintByKey("cannot.refactor.no.type") - else -> showErrorHint(file.project, editor, "Refactoring can't be performed on the selected code element", title) + else -> showErrorHint( + file.project, + editor, + KotlinRefactoringBundle.message("text.refactoring.can.t.be.performed.on.the.selected.code.element"), + title + ) } } @@ -246,7 +251,7 @@ fun insertDeclaration(declaration: T, targetSibling: PsiElem internal fun validateExpressionElements(elements: List): String? { if (elements.any { it is KtConstructor<*> || it is KtParameter || it is KtTypeAlias || it is KtPropertyAccessor }) { - return "Refactoring is not applicable to this code fragment" + return KotlinRefactoringBundle.message("text.refactoring.is.not.applicable.to.this.code.fragment") } return null } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java index 199cf97dc95..ac2c1522c4f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java @@ -30,6 +30,7 @@ import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention; +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle; import org.jetbrains.kotlin.idea.references.ReferenceUtilKt; import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.lexer.KtTokens; @@ -201,9 +202,9 @@ public class KotlinInplaceVariableIntroducer ex return new Function0() { @Override public JComponent invoke() { - final JCheckBox exprTypeCheckbox = new NonFocusableCheckBox("Specify type explicitly"); + final JCheckBox exprTypeCheckbox = new NonFocusableCheckBox( + KotlinRefactoringBundle.message("checkbox.text.specify.type.explicitly")); exprTypeCheckbox.setSelected(false); - exprTypeCheckbox.setMnemonic('t'); exprTypeCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { @@ -237,9 +238,8 @@ public class KotlinInplaceVariableIntroducer ex return new Function0() { @Override public JComponent invoke() { - final JCheckBox varCheckbox = new NonFocusableCheckBox("Declare with var"); + final JCheckBox varCheckbox = new NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.declare.with.var")); varCheckbox.setSelected(isVar); - varCheckbox.setMnemonic('v'); varCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(@NotNull ActionEvent e) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt index 296cbe0a7ec..f6c70f93e49 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt @@ -747,7 +747,8 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler { return candidateContainers.last().let { runWithChosenContainers(it.first, it.second) } } - chooseContainerElementIfNecessary(candidateContainers, editor, "Select target code block", true, { it.first }) { + chooseContainerElementIfNecessary(candidateContainers, editor, + KotlinRefactoringBundle.message("text.select.target.code.block"), true, { it.first }) { runWithChosenContainers(it.first, it.second) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt index 671ee420fa4..aa631d7fcb9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt @@ -17,6 +17,7 @@ import com.intellij.psi.PsiFile import com.intellij.psi.PsiReference import com.intellij.ui.NonFocusableCheckBox import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractKotlinInplaceIntroducer import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.util.application.executeWriteCommand @@ -61,9 +62,8 @@ class KotlinVariableInplaceIntroducer( init { initFormComponents { if (!doNotChangeVar) { - val varCheckBox = NonFocusableCheckBox("Declare with var") + val varCheckBox = NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.declare.with.var")) varCheckBox.isSelected = isVar - varCheckBox.setMnemonic('v') varCheckBox.addActionListener { myProject.executeWriteCommand(commandName, commandName) { PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.document) @@ -78,22 +78,22 @@ class KotlinVariableInplaceIntroducer( if (expressionType != null && !noTypeInference) { val renderedType = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(expressionType) - expressionTypeCheckBox = NonFocusableCheckBox("Specify type explicitly").apply { - isSelected = false - setMnemonic('t') - addActionListener { - runWriteCommandAndRestart { - updateVariableName() - if (isSelected) { - addedVariable.typeReference = KtPsiFactory(myProject).createType(renderedType) - } else { - addedVariable.typeReference = null + expressionTypeCheckBox = + NonFocusableCheckBox(KotlinRefactoringBundle.message("checkbox.text.specify.type.explicitly")).apply { + isSelected = false + addActionListener { + runWriteCommandAndRestart { + updateVariableName() + if (isSelected) { + addedVariable.typeReference = KtPsiFactory(myProject).createType(renderedType) + } else { + addedVariable.typeReference = null + } } } - } - addComponent(this) - } + addComponent(this) + } } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt index 5d8d867a588..a4af9e8d342 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.core.KotlinNameSuggester import org.jetbrains.kotlin.idea.imports.importableFqName +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.idea.util.getResolutionScope import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtPsiFactory @@ -76,7 +77,10 @@ internal fun chooseApplicableComponentFunctions( if (editor == null) return callback(emptyList()) - val list = JBList("Create single variable", "Create destructuring declaration") + val list = JBList( + KotlinRefactoringBundle.message("text.create.single.variable"), + KotlinRefactoringBundle.message("text.create.destructuring.declaration") + ) JBPopupFactory.getInstance() .createListPopupBuilder(list) .setMovable(true) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt index 85c94acc422..339bf6ea87d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt @@ -11,6 +11,7 @@ import com.intellij.ui.ToolbarDecorator import com.intellij.ui.table.JBTable import com.intellij.util.ui.EditableModel import org.jetbrains.annotations.NonNls +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle import org.jetbrains.kotlin.psi.psiUtil.isIdentifier import java.awt.BorderLayout import java.awt.Component @@ -75,7 +76,7 @@ abstract class AbstractParameterTablePanel