i18n: add bundle for idea/refactoring/inline
This commit is contained in:
@@ -24,6 +24,8 @@ declarations.will.move.out.of.scope=Following declarations won't be available ou
|
||||
error.cant.refactor.vararg.functions=Can't refactor the function with variable arguments
|
||||
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.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.invalid.default.receiver.value=Invalid default receiver value
|
||||
error.text.invalid.name=Invalid name
|
||||
error.text.invalid.receiver.type=Invalid receiver type
|
||||
@@ -31,6 +33,7 @@ error.text.invalid.return.type=Invalid return type
|
||||
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
|
||||
family.name.update.usages.on.declarations.cut.paste=Update usages on declarations cut/paste
|
||||
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
|
||||
@@ -58,7 +61,9 @@ text.0.will.no.longer.be.accessible.after.signature.change={0} will no longer be
|
||||
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.constructor=constructor
|
||||
text.declaration=declaration
|
||||
text.default.value=\ // default value = {0}
|
||||
text.duplicating.local.variable=Duplicating local variable ''{0}''
|
||||
text.duplicating.parameter=Duplicating parameter ''{0}''
|
||||
@@ -67,12 +72,37 @@ text.explicit.receiver.is.already.present.in.call.element.0=Explicit receiver is
|
||||
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.this.reference.and.keep.the.0=Inline this reference and keep the {0}
|
||||
text.inlining.0.1=Inlining {0} {1}
|
||||
text.keep=keep
|
||||
text.local.property=property
|
||||
text.local.variable=local variable
|
||||
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=parameter ''{0}''
|
||||
text.receiver.can.t.be.safely.transformed.to.value.argument=Receiver can''t be safely transformed to value argument: {0}
|
||||
text.receiver=receiver
|
||||
text.remove=remove
|
||||
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=type alias
|
||||
text.update.usages.to.reflect.declaration.0.move=Update usages to reflect {0, choice, 0#declaration|1#declarations} move
|
||||
family.name.update.usages.on.declarations.cut.paste=Update usages on declarations cut/paste
|
||||
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}
|
||||
+10
-5
@@ -10,6 +10,7 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.ElementDescriptionUtil
|
||||
import com.intellij.refactoring.inline.InlineOptionsDialog
|
||||
import com.intellij.usageView.UsageViewTypeLocation
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
|
||||
@@ -29,7 +30,7 @@ abstract class AbstractKotlinInlineDialog(
|
||||
|
||||
private val kind: String = ElementDescriptionUtil.getElementDescription(callable, UsageViewTypeLocation.INSTANCE)
|
||||
|
||||
private val refactoringName get() = "Inline ${StringUtil.capitalizeWords(kind, true)}"
|
||||
private val refactoringName get() = KotlinRefactoringBundle.message("text.inline.0", StringUtil.capitalizeWords(kind, true))
|
||||
|
||||
init {
|
||||
myInvokedOnReference = reference != null
|
||||
@@ -54,17 +55,21 @@ abstract class AbstractKotlinInlineDialog(
|
||||
return "${kind.capitalize()} ${callable.nameAsSafeName} $occurrencesString"
|
||||
}
|
||||
|
||||
private fun getInlineText(verb: String) = "Inline all references and $verb the $kind " + (occurrencesString?.let { "($it)" } ?: "")
|
||||
private fun getInlineText(verb: String) = KotlinRefactoringBundle.message(
|
||||
"text.inline.all.references.and.0.the.1",
|
||||
verb,
|
||||
(occurrencesString?.let { "($it)" } ?: "")
|
||||
)
|
||||
|
||||
override fun getInlineAllText() = getInlineText("remove")
|
||||
override fun getInlineAllText() = getInlineText(KotlinRefactoringBundle.message("text.remove"))
|
||||
|
||||
override fun getKeepTheDeclarationText(): String? =
|
||||
// With non-writable callable refactoring does not work anyway (for both property or function)
|
||||
if (callable.isWritable && (occurrencesNumber > 1 || !myInvokedOnReference)) {
|
||||
getInlineText("keep")
|
||||
getInlineText(KotlinRefactoringBundle.message("text.keep"))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
override fun getInlineThisText() = "Inline this reference and keep the $kind"
|
||||
override fun getInlineThisText() = KotlinRefactoringBundle.message("text.inline.this.reference.and.keep.the.0", kind)
|
||||
}
|
||||
+19
-7
@@ -28,6 +28,7 @@ import com.intellij.usageView.UsageViewDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInliner.UsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.codeInliner.replaceUsages
|
||||
import org.jetbrains.kotlin.idea.findUsages.ReferencesSearchScopeHelper
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.idea.refactoring.pullUp.deleteWithCompanion
|
||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
@@ -45,12 +46,19 @@ class KotlinInlineCallableProcessor(
|
||||
) : BaseRefactoringProcessor(project) {
|
||||
|
||||
private val kind = when (declaration) {
|
||||
is KtNamedFunction -> "function"
|
||||
is KtProperty -> if (declaration.isLocal) "local variable" else "property"
|
||||
else -> "declaration"
|
||||
is KtNamedFunction -> KotlinRefactoringBundle.message("text.function")
|
||||
is KtProperty -> if (declaration.isLocal)
|
||||
KotlinRefactoringBundle.message("text.local.variable")
|
||||
else
|
||||
KotlinRefactoringBundle.message("text.local.property")
|
||||
else -> KotlinRefactoringBundle.message("text.declaration")
|
||||
}
|
||||
|
||||
private val commandName = "Inlining $kind ${DescriptiveNameUtil.getDescriptiveName(declaration)}"
|
||||
private val commandName = KotlinRefactoringBundle.message(
|
||||
"text.inlining.0.1",
|
||||
kind,
|
||||
DescriptiveNameUtil.getDescriptiveName(declaration)
|
||||
)
|
||||
|
||||
override fun findUsages(): Array<UsageInfo> {
|
||||
if (inlineThisOnly && reference != null) return arrayOf(UsageInfo(reference))
|
||||
@@ -77,8 +85,12 @@ class KotlinInlineCallableProcessor(
|
||||
CommonRefactoringUtil.showErrorHint(
|
||||
declaration.project,
|
||||
null,
|
||||
"Cannot inline ${usages.size - simpleNameUsages.size}/${usages.size} usages",
|
||||
"Inline $kind",
|
||||
KotlinRefactoringBundle.message(
|
||||
"text.cannot.inline.0.1.usages",
|
||||
usages.size - simpleNameUsages.size,
|
||||
usages.size
|
||||
),
|
||||
KotlinRefactoringBundle.message("text.inline.0", kind),
|
||||
null
|
||||
)
|
||||
}
|
||||
@@ -100,7 +112,7 @@ class KotlinInlineCallableProcessor(
|
||||
|
||||
override fun getElements() = arrayOf(declaration)
|
||||
|
||||
override fun getProcessedElementsHeader() = "${kind.capitalize()} to inline"
|
||||
override fun getProcessedElementsHeader() = KotlinRefactoringBundle.message("text.0.to.inline", kind.capitalize())
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInliner.CallableUsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
|
||||
@@ -37,8 +38,11 @@ class KotlinInlineFunctionHandler : InlineActionHandler() {
|
||||
|
||||
val recursive = element.isRecursive()
|
||||
if (recursive && nameReference == null) {
|
||||
val message = RefactoringBundle.getCannotRefactorMessage("Inline recursive function is supported only on references")
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, "Inline Function", null)
|
||||
val message = RefactoringBundle.getCannotRefactorMessage(
|
||||
KotlinRefactoringBundle.message("text.inline.recursive.function.is.supported.only.on.references")
|
||||
)
|
||||
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, KotlinRefactoringBundle.message("title.inline.function"), null)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
@@ -39,7 +40,7 @@ import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
class KotlinInlineTypeAliasHandler : InlineActionHandler() {
|
||||
companion object {
|
||||
val REFACTORING_NAME = "Inline Type Alias"
|
||||
val REFACTORING_NAME = KotlinRefactoringBundle.message("name.inline.type.alias")
|
||||
}
|
||||
|
||||
private fun showErrorHint(project: Project, editor: Editor?, message: String) {
|
||||
@@ -66,7 +67,11 @@ class KotlinInlineTypeAliasHandler : InlineActionHandler() {
|
||||
?: refElement.getNonStrictParentOfType<KtSimpleNameExpression>()
|
||||
}
|
||||
|
||||
if (usages.isEmpty()) return showErrorHint(project, editor, "Type alias '$name' is never used")
|
||||
if (usages.isEmpty()) return showErrorHint(
|
||||
project,
|
||||
editor,
|
||||
KotlinRefactoringBundle.message("message.text.type.alias.0.is.never.used", name)
|
||||
)
|
||||
|
||||
val usagesInOriginalFile = usages.filter { it.containingFile == file }
|
||||
val isHighlighting = usagesInOriginalFile.isNotEmpty()
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.openapi.help.HelpManager
|
||||
import com.intellij.refactoring.HelpID
|
||||
import org.jetbrains.kotlin.idea.codeInliner.UsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSettings
|
||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
import org.jetbrains.kotlin.psi.KtBinaryExpression
|
||||
@@ -52,7 +53,7 @@ class KotlinInlineValDialog(
|
||||
|
||||
override fun shouldSaveOptionsOnCancel() = false
|
||||
|
||||
override fun getDoNotShowMessage() = "Do not show for local variables in future"
|
||||
override fun getDoNotShowMessage() = KotlinRefactoringBundle.message("message.do.not.show.for.local.variables.in.future")
|
||||
})
|
||||
}
|
||||
init()
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.idea.codeInliner.CodeToInline
|
||||
import org.jetbrains.kotlin.idea.codeInliner.PropertyUsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.findUsages.ReferencesSearchScopeHelper
|
||||
import org.jetbrains.kotlin.idea.project.builtIns
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively
|
||||
import org.jetbrains.kotlin.idea.references.ReferenceAccess
|
||||
import org.jetbrains.kotlin.idea.references.readWriteAccess
|
||||
@@ -61,21 +62,32 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand
|
||||
|
||||
val file = declaration.containingKtFile
|
||||
if (file.isCompiled) {
|
||||
return showErrorHint(project, editor, "Cannot inline '$name' from a decompiled file")
|
||||
return showErrorHint(
|
||||
project,
|
||||
editor,
|
||||
KotlinRefactoringBundle.message("error.hint.text.cannot.inline.0.from.a.decompiled.file", name)
|
||||
)
|
||||
}
|
||||
|
||||
val getter = declaration.getter?.takeIf { it.hasBody() }
|
||||
val setter = declaration.setter?.takeIf { it.hasBody() }
|
||||
|
||||
if ((getter != null || setter != null) && declaration.initializer != null) {
|
||||
return showErrorHint(project, editor, "Cannot inline property with accessor(s) and backing field")
|
||||
return showErrorHint(
|
||||
project,
|
||||
editor,
|
||||
KotlinRefactoringBundle.message("cannot.inline.property.with.accessor.s.and.backing.field")
|
||||
)
|
||||
}
|
||||
|
||||
val (referenceExpressions, conflicts) = findUsages(declaration)
|
||||
|
||||
if (referenceExpressions.isEmpty() && conflicts.isEmpty) {
|
||||
val kind = if (declaration.isLocal) "Variable" else "Property"
|
||||
return showErrorHint(project, editor, "$kind '$name' is never used")
|
||||
val kind = if (declaration.isLocal)
|
||||
KotlinRefactoringBundle.message("variable")
|
||||
else
|
||||
KotlinRefactoringBundle.message("property")
|
||||
return showErrorHint(project, editor, KotlinRefactoringBundle.message("0.1.is.never.used", kind, name))
|
||||
}
|
||||
|
||||
val referencesInOriginalFile = referenceExpressions.filter { it.containingFile == file }
|
||||
@@ -104,8 +116,18 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand
|
||||
|
||||
if (!conflicts.isEmpty) {
|
||||
val conflictsCopy = conflicts.copy()
|
||||
val allOrSome = if (referenceExpressions.isEmpty()) "All" else "The following"
|
||||
conflictsCopy.putValue(null, "$allOrSome usages are not supported by the Inline refactoring. They won't be processed.")
|
||||
val allOrSome = if (referenceExpressions.isEmpty())
|
||||
KotlinRefactoringBundle.message("all")
|
||||
else
|
||||
KotlinRefactoringBundle.message("the.following")
|
||||
|
||||
conflictsCopy.putValue(
|
||||
null,
|
||||
KotlinRefactoringBundle.message(
|
||||
"0.usages.are.not.supported.by.the.inline.refactoring.they.won.t.be.processed",
|
||||
allOrSome
|
||||
)
|
||||
)
|
||||
|
||||
project.checkConflictsInteractively(conflictsCopy) {
|
||||
performRefactoring(declaration, readReplacement, writeReplacement, assignmentToDelete, editor, hasHighlightings)
|
||||
@@ -124,7 +146,7 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand
|
||||
for (ref in references) {
|
||||
val refElement = ref.element
|
||||
if (refElement !is KtElement) {
|
||||
conflictUsages.putValue(refElement, "Non-Kotlin usage: ${refElement.text}")
|
||||
conflictUsages.putValue(refElement, KotlinRefactoringBundle.message("non.kotlin.usage.0", refElement.text))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -132,7 +154,7 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand
|
||||
//TODO: what if null?
|
||||
if (expression != null) {
|
||||
if (expression.readWriteAccess(useResolveForReadWrite = true) == ReferenceAccess.READ_WRITE) {
|
||||
conflictUsages.putValue(expression, "Unsupported usage: ${expression.parent.text}")
|
||||
conflictUsages.putValue(expression, KotlinRefactoringBundle.message("unsupported.usage.0", expression.parent.text))
|
||||
}
|
||||
referenceExpressions.add(expression)
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInliner.CodeToInline
|
||||
import org.jetbrains.kotlin.idea.codeInliner.CodeToInlineBuilder
|
||||
import org.jetbrains.kotlin.idea.core.copied
|
||||
import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringBundle
|
||||
import org.jetbrains.kotlin.idea.refactoring.move.ContainerChangeInfo
|
||||
import org.jetbrains.kotlin.idea.refactoring.move.ContainerInfo
|
||||
import org.jetbrains.kotlin.idea.refactoring.move.postProcessMoveUsages
|
||||
@@ -63,13 +64,16 @@ fun showDialog(
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) return true
|
||||
|
||||
val kind = when (declaration) {
|
||||
is KtProperty -> if (declaration.isLocal) "local variable" else "property"
|
||||
is KtTypeAlias -> "type alias"
|
||||
is KtProperty -> if (declaration.isLocal)
|
||||
KotlinRefactoringBundle.message("text.local.variable")
|
||||
else
|
||||
KotlinRefactoringBundle.message("text.local.property")
|
||||
is KtTypeAlias -> KotlinRefactoringBundle.message("text.type.alias")
|
||||
else -> return false
|
||||
}
|
||||
val dialog = RefactoringMessageDialog(
|
||||
title,
|
||||
"Inline " + kind + " '" + name + "'? " + RefactoringBundle.message("occurences.string", usages.size),
|
||||
KotlinRefactoringBundle.message("text.inline.0.1.2", kind, name, RefactoringBundle.message("occurences.string", usages.size)),
|
||||
helpTopic,
|
||||
"OptionPane.questionIcon",
|
||||
true,
|
||||
@@ -144,11 +148,19 @@ internal fun buildCodeToInline(
|
||||
if (returnStatements.any { it != lastReturn }) {
|
||||
val message = RefactoringBundle.getCannotRefactorMessage(
|
||||
if (returnStatements.size > 1)
|
||||
"Inline Function is not supported for functions with multiple return statements."
|
||||
KotlinRefactoringBundle.message("error.text.inline.function.is.not.supported.for.functions.with.multiple.return.statements")
|
||||
else
|
||||
"Inline Function is not supported for functions with return statements not at the end of the body."
|
||||
KotlinRefactoringBundle.message("error.text.inline.function.is.not.supported.for.functions.with.return.statements.not.at.the.end.of.the.body")
|
||||
)
|
||||
CommonRefactoringUtil.showErrorHint(declaration.project, editor, message, "Inline Function", null)
|
||||
|
||||
CommonRefactoringUtil.showErrorHint(
|
||||
declaration.project,
|
||||
editor,
|
||||
message,
|
||||
KotlinRefactoringBundle.message("title.inline.function"),
|
||||
null
|
||||
)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user