i18n: add bundle for idea/quickfix/*
This commit is contained in:
@@ -1016,4 +1016,61 @@ delete.with.usage.search=delete (with usage search)
|
||||
destination.not.found.for.package.0=Destination not found for package ''{0}''
|
||||
leave.in.same.source.root=Leave in same source root
|
||||
test.root.is.selected.while.the.source.root.is.expected=Test root is selected while the source root is expected
|
||||
source.root.is.selected.while.the.test.root.is.expected=Source root is selected while the test root is expected
|
||||
source.root.is.selected.while.the.test.root.is.expected=Source root is selected while the test root is expected
|
||||
premature.end.of.template=Premature end of template
|
||||
choose.target.class.or.interface=Choose target class or interface
|
||||
text.abstract=abstract
|
||||
text.secondary.constructor=secondary constructor
|
||||
text.create=Create
|
||||
text.member=member
|
||||
text.extension=extension
|
||||
text.object=object
|
||||
text.interface=interface
|
||||
text.enum.constant=enum constant
|
||||
text.enum=enum
|
||||
text.annotation=annotation
|
||||
create.0.1=Create {0} ''{1}''
|
||||
choose.class.container=Choose class container
|
||||
file.0.already.exists.but.does.not.correspond.to.kotlin.file=File {0} already exists but does not correspond to Kotlin file
|
||||
create.file=Create file
|
||||
create.0=Create {0}
|
||||
create.package.0=Create package ''{0}''
|
||||
text.type.parameter=type {0, choice, 0#parameter|2#parameters}
|
||||
create.0.in.1=Create {0} in {1}
|
||||
searching.0=Searching {0}...
|
||||
create.property.0.as.constructor.parameter=Create property ''{0}'' as constructor parameter
|
||||
create.parameter.0=Create parameter ''{0}''
|
||||
add.property=Add property
|
||||
text.add=Add '
|
||||
property.0.to.1=' property ''{0}'' to ''{1}''
|
||||
add.method=Add method
|
||||
add.0.constructor.to.1=Add {0} constructor to ''{1}''
|
||||
text.secondary=secondary
|
||||
text.primary=primary
|
||||
add.method.0.to.1=Add method ''{0}'' to ''{1}''
|
||||
create.actual.0.for.module.1.2=Create actual {0} for module {1} ({2})
|
||||
create.expected.0.in.common.module.1=Create expected {0} in common module {1}
|
||||
repair.actual.members=Repair actual members
|
||||
these.declarations.cannot.be.transformed=These declarations cannot be transformed:
|
||||
unknown.types=Unknown types
|
||||
choose.actual.members=Choose actual members
|
||||
text.annotation.class=annotation class
|
||||
text.enum.class=enum class
|
||||
text.class=class
|
||||
type.0.1.is.not.accessible.from.target.module={0, choice, 0#Type|2#Types} {1} is not accessible from target module
|
||||
the.function.declaration.shouldn.t.have.a.default.implementation=The function declaration shouldn't have a default implementation
|
||||
some.types.are.not.accessible.from.0.1=Some types are not accessible from {0}:\n{1}
|
||||
the.declaration.has.0.modifier=The declaration has `'{0}`' modifier
|
||||
inaccessible.declaration=Inaccessible declaration
|
||||
fix.with.asdynamic=Fix with 'asDynamic'
|
||||
migrate.type.parameter.list.syntax=Migrate type parameter list syntax
|
||||
replace.deprecated.symbol.usage=Replace deprecated symbol usage
|
||||
replace.with.0=Replace with ''{0}''
|
||||
there.is.own.replacewith.on.0.that.is.used.through.this.alias.please.replace.usages.first=There is own ''ReplaceWith'' on ''{0}'' that is used through this alias. Please replace usages first.
|
||||
replace.deprecated.symbol.usage.in.whole.project=Replace deprecated symbol usage in whole project
|
||||
applying.0=Applying ''{0}''
|
||||
replace.usages.of.0.in.whole.project=Replace usages of ''{0}'' in whole project
|
||||
replace.with.publishedapi.bridge.call=Replace with @PublishedApi bridge call
|
||||
replace.with.generated.publishedapi.bridge.call.0=Replace with generated @PublishedApi bridge call ''{0}''
|
||||
convert.sealed.sub.class.to.object.fix.family.name=Convert sealed sub-class to object
|
||||
generate.identity.equals.fix.family.name=Generate equals & hashCode by identity
|
||||
+1
-1
@@ -277,7 +277,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
} else {
|
||||
val dialog = object : DialogWithEditor(project, KotlinBundle.message("fix.create.from.usage.dialog.title"), "") {
|
||||
override fun doOKAction() {
|
||||
project.executeWriteCommand("Premature end of template") {
|
||||
project.executeWriteCommand(KotlinBundle.message("premature.end.of.template")) {
|
||||
TemplateManagerImpl.getTemplateState(editor)?.gotoEnd(false)
|
||||
}
|
||||
super.doOKAction()
|
||||
|
||||
+12
-8
@@ -90,13 +90,14 @@ abstract class CreateCallableFromUsageFixBase<E : KtElement>(
|
||||
val renderedCallables = callableInfos.map {
|
||||
buildString {
|
||||
if (it.isAbstract) {
|
||||
append("abstract ")
|
||||
append(KotlinBundle.message("text.abstract"))
|
||||
append(' ')
|
||||
}
|
||||
|
||||
val kind = when (it.kind) {
|
||||
CallableKind.FUNCTION -> "function"
|
||||
CallableKind.PROPERTY -> "property"
|
||||
CallableKind.CONSTRUCTOR -> "secondary constructor"
|
||||
CallableKind.FUNCTION -> KotlinBundle.message("text.function")
|
||||
CallableKind.PROPERTY -> KotlinBundle.message("text.property")
|
||||
CallableKind.CONSTRUCTOR -> KotlinBundle.message("text.secondary.constructor")
|
||||
else -> throw AssertionError("Unexpected callable info: $it")
|
||||
}
|
||||
append(kind)
|
||||
@@ -130,13 +131,16 @@ abstract class CreateCallableFromUsageFixBase<E : KtElement>(
|
||||
}
|
||||
|
||||
return StringBuilder().apply {
|
||||
append("Create ")
|
||||
append(KotlinBundle.message("text.create"))
|
||||
append(' ')
|
||||
|
||||
if (!callableInfos.any { it.isAbstract }) {
|
||||
if (isExtension) {
|
||||
append("extension ")
|
||||
append(KotlinBundle.message("text.extension"))
|
||||
append(' ')
|
||||
} else if (receiverTypeInfo != TypeInfo.Empty) {
|
||||
append("member ")
|
||||
append(KotlinBundle.message("text.member"))
|
||||
append(' ')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +204,7 @@ abstract class CreateCallableFromUsageFixBase<E : KtElement>(
|
||||
return
|
||||
}
|
||||
|
||||
val popupTitle = "Choose target class or interface"
|
||||
val popupTitle = KotlinBundle.message("choose.target.class.or.interface")
|
||||
val receiverTypeInfo = callableInfo.receiverTypeInfo
|
||||
val receiverTypeCandidates = callableBuilder.computeTypeCandidates(receiverTypeInfo).let {
|
||||
if (callableInfo.isAbstract)
|
||||
|
||||
+21
-12
@@ -14,6 +14,9 @@ import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.core.getFqNameWithImplicitPrefix
|
||||
import org.jetbrains.kotlin.idea.core.quoteIfNeeded
|
||||
@@ -42,13 +45,13 @@ import org.jetbrains.kotlin.utils.SmartList
|
||||
import java.util.*
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.ClassKind as IdeaClassKind
|
||||
|
||||
enum class ClassKind(val keyword: String, val description: String) {
|
||||
PLAIN_CLASS("class", "class"),
|
||||
ENUM_CLASS("enum class", "enum"),
|
||||
ENUM_ENTRY("", "enum constant"),
|
||||
ANNOTATION_CLASS("annotation class", "annotation"),
|
||||
INTERFACE("interface", "interface"),
|
||||
OBJECT("object", "object"),
|
||||
enum class ClassKind(@NonNls val keyword: String, @Nls val description: String) {
|
||||
PLAIN_CLASS("class", KotlinBundle.message("find.usages.class")),
|
||||
ENUM_CLASS("enum class", KotlinBundle.message("text.enum")),
|
||||
ENUM_ENTRY("", KotlinBundle.message("text.enum.constant")),
|
||||
ANNOTATION_CLASS("annotation class", KotlinBundle.message("text.annotation")),
|
||||
INTERFACE("interface", KotlinBundle.message("text.interface")),
|
||||
OBJECT("object", KotlinBundle.message("text.object")),
|
||||
DEFAULT("", "") // Used as a placeholder and must be replaced with one of the kinds above
|
||||
}
|
||||
|
||||
@@ -79,7 +82,7 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
|
||||
element: E,
|
||||
private val classInfo: ClassInfo
|
||||
) : CreateFromUsageFixBase<E>(element) {
|
||||
override fun getText() = "Create ${classInfo.kind.description} '${classInfo.name}'"
|
||||
override fun getText() = KotlinBundle.message("create.0.1", classInfo.kind.description, classInfo.name)
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
|
||||
with(classInfo) {
|
||||
@@ -124,7 +127,13 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
|
||||
return doInvoke(targetParent, editor, file)
|
||||
}
|
||||
|
||||
chooseContainerElementIfNecessary(applicableParents.reversed(), editor, "Choose class container", true, { it }) {
|
||||
chooseContainerElementIfNecessary(
|
||||
applicableParents.reversed(),
|
||||
editor,
|
||||
KotlinBundle.message("choose.class.container"),
|
||||
true,
|
||||
{ it }
|
||||
) {
|
||||
doInvoke(it, editor, file)
|
||||
}
|
||||
}
|
||||
@@ -155,8 +164,8 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
|
||||
CodeInsightUtils.showErrorHint(
|
||||
targetDirectory.project,
|
||||
editor,
|
||||
"File $filePath already exists but does not correspond to Kotlin file",
|
||||
"Create file",
|
||||
KotlinBundle.message("file.0.already.exists.but.does.not.correspond.to.kotlin.file", filePath),
|
||||
KotlinBundle.message("create.file"),
|
||||
null
|
||||
)
|
||||
}
|
||||
@@ -175,7 +184,7 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
|
||||
val defaultPackageFqName = file.packageFqName
|
||||
val dialog = object : CreateKotlinClassDialog(
|
||||
file.project,
|
||||
"Create ${ideaClassKind.description.capitalize()}",
|
||||
KotlinBundle.message("create.0", ideaClassKind.description.capitalize()),
|
||||
className,
|
||||
defaultPackageFqName.asString(),
|
||||
ideaClassKind,
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ internal fun KtSimpleNameExpression.getCreatePackageFixIfApplicable(targetParent
|
||||
return object : DelegatingIntentionAction(javaFix) {
|
||||
override fun getFamilyName(): String = KotlinBundle.message("fix.create.from.usage.family")
|
||||
|
||||
override fun getText(): String = "Create package '$fullName'"
|
||||
override fun getText(): String = KotlinBundle.message("create.package.0", fullName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -12,6 +12,7 @@ import com.intellij.psi.ElementDescriptionUtil
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.usageView.UsageViewTypeLocation
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.addTypeParameter
|
||||
@@ -38,11 +39,11 @@ class CreateTypeParameterFromUsageFix(
|
||||
private val presentTypeParameterNames: Boolean
|
||||
) : CreateFromUsageFixBase<KtElement>(originalElement) {
|
||||
override fun getText(): String {
|
||||
val prefix = "type parameter".let { if (data.typeParameters.size > 1) StringUtil.pluralize(it) else it }
|
||||
val prefix = KotlinBundle.message("text.type.parameter", data.typeParameters.size)
|
||||
val typeParametersText = if (presentTypeParameterNames) data.typeParameters.joinToString(prefix = " ") { "'${it.name}'" } else ""
|
||||
val containerText = ElementDescriptionUtil.getElementDescription(data.declaration, UsageViewTypeLocation.INSTANCE) +
|
||||
" '${data.declaration.name}'"
|
||||
return "Create $prefix$typeParametersText in $containerText"
|
||||
return KotlinBundle.message("create.0.in.1", prefix + typeParametersText, containerText)
|
||||
}
|
||||
|
||||
override fun startInWriteAction() = false
|
||||
@@ -55,7 +56,7 @@ class CreateTypeParameterFromUsageFix(
|
||||
val declaration = data.declaration
|
||||
if (!declaration.isWritable) return emptyList()
|
||||
val project = declaration.project
|
||||
val usages = project.runSynchronouslyWithProgress("Searching ${declaration.name}...", true) {
|
||||
val usages = project.runSynchronouslyWithProgress(KotlinBundle.message("searching.0", declaration.name.toString()), true) {
|
||||
runReadAction {
|
||||
val expectedTypeArgumentCount = declaration.typeParameters.size + data.typeParameters.size
|
||||
ReferencesSearch
|
||||
@@ -98,12 +99,12 @@ class CreateTypeParameterFromUsageFix(
|
||||
)
|
||||
val anonymizedUpperBoundText = upperBoundType?.let {
|
||||
TypeSubstitutor.create(
|
||||
mapOf(
|
||||
typeParameter.fakeTypeParameter.typeConstructor to TypeProjectionImpl(
|
||||
anonymizedTypeParameter.defaultType
|
||||
mapOf(
|
||||
typeParameter.fakeTypeParameter.typeConstructor to TypeProjectionImpl(
|
||||
anonymizedTypeParameter.defaultType
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.substitute(upperBoundType, Variance.INVARIANT)
|
||||
}?.let {
|
||||
IdeDescriptorRenderers.SOURCE_CODE.renderType(it)
|
||||
|
||||
+5
-1
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.CreateFromUsageFixBase
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.CallableBuilderConfiguration
|
||||
@@ -28,7 +29,10 @@ open class CreateParameterFromUsageFix<E : KtElement>(
|
||||
) : CreateFromUsageFixBase<E>(data.originalExpression) {
|
||||
override fun getText(): String {
|
||||
return with(data.parameterInfo) {
|
||||
if (valOrVar != KotlinValVar.None) "Create property '$name' as constructor parameter" else "Create parameter '$name'"
|
||||
if (valOrVar != KotlinValVar.None)
|
||||
KotlinBundle.message("create.property.0.as.constructor.parameter", name)
|
||||
else
|
||||
KotlinBundle.message("create.parameter.0", name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
@@ -140,28 +141,25 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
|
||||
propertyInfo: PropertyInfo,
|
||||
private val classOrFileName: String?
|
||||
) : CreateCallableFromUsageFix<KtElement>(contextElement, listOf(propertyInfo)) {
|
||||
override fun getFamilyName() = "Add property"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.property")
|
||||
override fun getText(): String {
|
||||
val info = callableInfos.first() as PropertyInfo
|
||||
return buildString {
|
||||
append("Add '")
|
||||
append(KotlinBundle.message("text.add"))
|
||||
if (info.isLateinitPreferred || info.modifierList?.hasModifier(KtTokens.LATEINIT_KEYWORD) == true) {
|
||||
append("lateinit ")
|
||||
}
|
||||
append(if (info.writable) "var" else "val")
|
||||
append("' property '${info.name}' to '$classOrFileName'")
|
||||
append(KotlinBundle.message("property.0.to.1", info.name, classOrFileName.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun JvmClass.toKtClassOrFile(): KtElement? {
|
||||
val psi = sourceElement
|
||||
return when (psi) {
|
||||
is KtClassOrObject -> psi
|
||||
is KtLightClassForSourceDeclaration -> psi.kotlinOrigin
|
||||
is KtLightClassForFacade -> psi.files.firstOrNull()
|
||||
else -> null
|
||||
}
|
||||
private fun JvmClass.toKtClassOrFile(): KtElement? = when (val psi = sourceElement) {
|
||||
is KtClassOrObject -> psi
|
||||
is KtLightClassForSourceDeclaration -> psi.kotlinOrigin
|
||||
is KtLightClassForFacade -> psi.files.firstOrNull()
|
||||
else -> null
|
||||
}
|
||||
|
||||
private inline fun <reified T : KtElement> JvmElement.toKtElement() = sourceElement?.unwrapped as? T
|
||||
@@ -246,8 +244,12 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
|
||||
)
|
||||
val targetClassName = targetClass.name
|
||||
val addConstructorAction = object : CreateCallableFromUsageFix<KtElement>(targetKtClass, listOf(constructorInfo)) {
|
||||
override fun getFamilyName() = "Add method"
|
||||
override fun getText() = "Add ${if (needPrimary) "primary" else "secondary"} constructor to '$targetClassName'"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.method")
|
||||
override fun getText() = KotlinBundle.message(
|
||||
"add.0.constructor.to.1",
|
||||
if (needPrimary) KotlinBundle.message("text.primary") else KotlinBundle.message("text.secondary"),
|
||||
targetClassName.toString()
|
||||
)
|
||||
}
|
||||
|
||||
val changePrimaryConstructorAction = run {
|
||||
@@ -361,8 +363,8 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
|
||||
)
|
||||
val targetClassName = targetClass.name
|
||||
val action = object : CreateCallableFromUsageFix<KtElement>(targetContainer, listOf(functionInfo)) {
|
||||
override fun getFamilyName() = "Add method"
|
||||
override fun getText() = "Add method '$methodName' to '$targetClassName'"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.method")
|
||||
override fun getText() = KotlinBundle.message("add.method.0.to.1", methodName, targetClassName.toString())
|
||||
}
|
||||
|
||||
val nameAndKind = PropertyUtilBase.getPropertyNameAndKind(methodName) ?: return listOf(action)
|
||||
|
||||
+14
-20
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.quickfix.crossLanguage
|
||||
@@ -42,6 +31,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
@@ -152,16 +142,16 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
|
||||
propertyInfo: PropertyInfo,
|
||||
private val classOrFileName: String?
|
||||
) : CreateCallableFromUsageFix<KtElement>(contextElement, listOf(propertyInfo)) {
|
||||
override fun getFamilyName() = "Add property"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.property")
|
||||
override fun getText(): String {
|
||||
val info = callableInfos.first() as PropertyInfo
|
||||
return buildString {
|
||||
append("Add '")
|
||||
append(KotlinBundle.message("text.add"))
|
||||
if (info.isLateinitPreferred || info.modifierList?.hasModifier(KtTokens.LATEINIT_KEYWORD) == true) {
|
||||
append("lateinit ")
|
||||
}
|
||||
append(if (info.writable) "var" else "val")
|
||||
append("' property '${info.name}' to '$classOrFileName'")
|
||||
append(KotlinBundle.message("property.0.to.1", info.name, classOrFileName.toString()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,8 +248,12 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
|
||||
)
|
||||
val targetClassName = targetClass.name
|
||||
val addConstructorAction = object : CreateCallableFromUsageFix<KtElement>(targetKtClass, listOf(constructorInfo)) {
|
||||
override fun getFamilyName() = "Add method"
|
||||
override fun getText() = "Add ${if (needPrimary) "primary" else "secondary"} constructor to '$targetClassName'"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.method")
|
||||
override fun getText() = KotlinBundle.message(
|
||||
"add.0.constructor.to.1",
|
||||
if (needPrimary) KotlinBundle.message("text.primary") else KotlinBundle.message("text.secondary"),
|
||||
targetClassName.toString()
|
||||
)
|
||||
}
|
||||
|
||||
val changePrimaryConstructorAction = run {
|
||||
@@ -384,8 +378,8 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
|
||||
)
|
||||
val targetClassName = targetClass.name
|
||||
val action = object : CreateCallableFromUsageFix<KtElement>(targetContainer, listOf(functionInfo)) {
|
||||
override fun getFamilyName() = "Add method"
|
||||
override fun getText() = "Add method '$methodName' to '$targetClassName'"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.method")
|
||||
override fun getText() = KotlinBundle.message("add.method.0.to.1", methodName, targetClassName.toString())
|
||||
}
|
||||
|
||||
val nameAndKind = PropertyUtilBase.getPropertyNameAndKind(methodName) ?: return listOf(action)
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo
|
||||
import org.jetbrains.kotlin.idea.core.toDescriptor
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||
@@ -41,8 +42,12 @@ sealed class CreateActualFix<D : KtNamedDeclaration>(
|
||||
generateIt: KtPsiFactory.(Project, TypeAccessibilityChecker, D) -> D?
|
||||
) : AbstractCreateDeclarationFix<D>(declaration, actualModule, generateIt) {
|
||||
|
||||
override fun getText() =
|
||||
"Create actual $elementType for module ${module.name} (${actualPlatform.singleOrNull()?.platformName ?: actualPlatform})"
|
||||
override fun getText() = KotlinBundle.message(
|
||||
"create.actual.0.for.module.1.2",
|
||||
elementType,
|
||||
module.name,
|
||||
actualPlatform.singleOrNull()?.platformName ?: actualPlatform
|
||||
)
|
||||
|
||||
final override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val actualFile = getOrCreateImplementationFile() ?: return
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.project.implementedModules
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.makeActual
|
||||
@@ -46,7 +47,7 @@ sealed class CreateExpectedFix<D : KtNamedDeclaration>(
|
||||
|
||||
private val targetExpectedClassPointer = targetExpectedClass?.createSmartPointer()
|
||||
|
||||
override fun getText() = "Create expected $elementType in common module ${module.name}"
|
||||
override fun getText() = KotlinBundle.message("create.expected.0.in.common.module.1", elementType, module.name)
|
||||
|
||||
final override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val targetExpectedClass = targetExpectedClassPointer?.element
|
||||
@@ -148,7 +149,7 @@ class CreateExpectedClassFix(
|
||||
} else
|
||||
selectedElements
|
||||
|
||||
project.executeWriteCommand("Repair actual members") {
|
||||
project.executeWriteCommand(KotlinBundle.message("repair.actual.members")) {
|
||||
repairActualModifiers(originalElements + klass, resultDeclarations.toSet())
|
||||
}
|
||||
|
||||
@@ -162,7 +163,7 @@ private fun showUnknownTypeInDeclarationDialog(
|
||||
if (declarationsWithNonExistentClasses.isEmpty()) return true
|
||||
val message = escapeXml(
|
||||
declarationsWithNonExistentClasses.joinToString(
|
||||
prefix = "These declarations cannot be transformed:\n",
|
||||
prefix = "${KotlinBundle.message("these.declarations.cannot.be.transformed")}\n",
|
||||
separator = "\n",
|
||||
transform = ::getExpressionShortText
|
||||
)
|
||||
@@ -170,7 +171,7 @@ private fun showUnknownTypeInDeclarationDialog(
|
||||
|
||||
TypeAccessibilityChecker.testLog?.append("$message\n")
|
||||
return ApplicationManager.getApplication().isUnitTestMode || showOkNoDialog(
|
||||
"Unknown types",
|
||||
KotlinBundle.message("unknown.types"),
|
||||
message,
|
||||
project
|
||||
)
|
||||
@@ -200,7 +201,7 @@ private fun chooseMembers(project: Project, collection: Collection<KtNamedDeclar
|
||||
true,
|
||||
project
|
||||
).run {
|
||||
title = "Choose actual members"
|
||||
title = KotlinBundle.message("choose.actual.members")
|
||||
setCopyJavadocVisible(false)
|
||||
selectElements(classMembers.filter { filter((it.element as KtNamedDeclaration)) }.toTypedArray())
|
||||
show()
|
||||
|
||||
@@ -8,12 +8,12 @@ package org.jetbrains.kotlin.idea.quickfix.expectactual
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.JavaDirectoryService
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToBeShortenedDescendantsToWaitingSet
|
||||
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
|
||||
@@ -101,16 +101,16 @@ fun KtPsiFactory.createClassHeaderCopyByText(originalClass: KtClassOrObject): Kt
|
||||
}
|
||||
|
||||
fun KtNamedDeclaration?.getTypeDescription(): String = when (this) {
|
||||
is KtObjectDeclaration -> "object"
|
||||
is KtObjectDeclaration -> KotlinBundle.message("text.object")
|
||||
is KtClass -> when {
|
||||
isInterface() -> "interface"
|
||||
isEnum() -> "enum class"
|
||||
isAnnotation() -> "annotation class"
|
||||
else -> "class"
|
||||
isInterface() -> KotlinBundle.message("text.interface")
|
||||
isEnum() -> KotlinBundle.message("text.enum.class")
|
||||
isAnnotation() -> KotlinBundle.message("text.annotation.class")
|
||||
else -> KotlinBundle.message("text.class")
|
||||
}
|
||||
is KtProperty, is KtParameter -> "property"
|
||||
is KtFunction -> "function"
|
||||
else -> "declaration"
|
||||
is KtProperty, is KtParameter -> KotlinBundle.message("text.property")
|
||||
is KtFunction -> KotlinBundle.message("text.function")
|
||||
else -> KotlinBundle.message("text.declaration")
|
||||
}
|
||||
|
||||
internal fun KtPsiFactory.generateClassOrObject(
|
||||
@@ -381,10 +381,11 @@ private fun AnnotationDescriptor.isValidInModule(checker: TypeAccessibilityCheck
|
||||
}
|
||||
|
||||
class KotlinTypeInaccessibleException(fqNames: Collection<FqName?>) : Exception() {
|
||||
override val message: String = "${StringUtil.pluralize(
|
||||
"Type",
|
||||
fqNames.size
|
||||
)} ${TypeAccessibilityChecker.typesToString(fqNames)} is not accessible from target module"
|
||||
override val message: String = KotlinBundle.message(
|
||||
"type.0.1.is.not.accessible.from.target.module",
|
||||
fqNames.size,
|
||||
TypeAccessibilityChecker.typesToString(fqNames)
|
||||
)
|
||||
}
|
||||
|
||||
fun KtNamedDeclaration.isAlwaysActual(): Boolean = safeAs<KtParameter>()?.parent?.parent?.safeAs<KtPrimaryConstructor>()
|
||||
@@ -395,7 +396,10 @@ fun TypeAccessibilityChecker.isCorrectAndHaveAccessibleModifiers(declaration: Kt
|
||||
if (declaration.anyInaccessibleModifier(INACCESSIBLE_MODIFIERS, showErrorHint)) return false
|
||||
|
||||
if (declaration is KtFunction && declaration.hasBody() && declaration.containingClassOrObject?.isInterfaceClass() == true) {
|
||||
if (showErrorHint) showInaccessibleDeclarationError(declaration, "The function declaration shouldn't have a default implementation")
|
||||
if (showErrorHint) showInaccessibleDeclarationError(
|
||||
declaration,
|
||||
KotlinBundle.message("the.function.declaration.shouldn.t.have.a.default.implementation")
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -404,8 +408,10 @@ fun TypeAccessibilityChecker.isCorrectAndHaveAccessibleModifiers(declaration: Kt
|
||||
val types = incorrectTypes(declaration).ifEmpty { return true }
|
||||
showInaccessibleDeclarationError(
|
||||
declaration,
|
||||
"Some types are not accessible from ${targetModule.name}:\n" + TypeAccessibilityChecker.typesToString(
|
||||
types
|
||||
KotlinBundle.message(
|
||||
"some.types.are.not.accessible.from.0.1",
|
||||
targetModule.name,
|
||||
TypeAccessibilityChecker.typesToString(types)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -417,7 +423,7 @@ private val INACCESSIBLE_MODIFIERS = listOf(KtTokens.PRIVATE_KEYWORD, KtTokens.C
|
||||
private fun KtModifierListOwner.anyInaccessibleModifier(modifiers: Collection<KtModifierKeywordToken>, showErrorHint: Boolean): Boolean {
|
||||
for (modifier in modifiers) {
|
||||
if (hasModifier(modifier)) {
|
||||
if (showErrorHint) showInaccessibleDeclarationError(this, "The declaration has `$modifier` modifier")
|
||||
if (showErrorHint) showInaccessibleDeclarationError(this, KotlinBundle.message("the.declaration.has.0.modifier", modifier))
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -426,7 +432,7 @@ private fun KtModifierListOwner.anyInaccessibleModifier(modifiers: Collection<Kt
|
||||
|
||||
fun showInaccessibleDeclarationError(element: PsiElement, message: String, editor: Editor? = element.findExistingEditor()) {
|
||||
editor?.let {
|
||||
showErrorHint(element.project, editor, escapeXml(message), "Inaccessible declaration")
|
||||
showErrorHint(element.project, editor, escapeXml(message), KotlinBundle.message("inaccessible.declaration"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
|
||||
import org.jetbrains.kotlin.idea.intentions.declarations.ConvertMemberToExtensionIntention
|
||||
@@ -33,7 +34,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
class MigrateExternalExtensionFix(declaration: KtNamedDeclaration) : KotlinQuickFixAction<KtNamedDeclaration>(declaration), CleanupFix {
|
||||
|
||||
override fun getText() = "Fix with 'asDynamic'"
|
||||
override fun getText() = KotlinBundle.message("fix.with.asdynamic")
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.quickfix.CleanupFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||
@@ -20,7 +21,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
class MigrateTypeParameterListFix(typeParameterList: KtTypeParameterList) : KotlinQuickFixAction<KtTypeParameterList>(typeParameterList),
|
||||
CleanupFix {
|
||||
|
||||
override fun getFamilyName(): String = "Migrate type parameter list syntax"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("migrate.type.parameter.list.syntax")
|
||||
override fun getText(): String = familyName
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.codeInliner.UsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.core.moveCaret
|
||||
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||
@@ -35,9 +36,9 @@ class DeprecatedSymbolUsageFix(
|
||||
replaceWith: ReplaceWith
|
||||
) : DeprecatedSymbolUsageFixBase(element, replaceWith), CleanupFix, HighPriorityAction {
|
||||
|
||||
override fun getFamilyName() = "Replace deprecated symbol usage"
|
||||
override fun getFamilyName() = KotlinBundle.message("replace.deprecated.symbol.usage")
|
||||
|
||||
override fun getText() = "Replace with '${replaceWith.pattern}'"
|
||||
override fun getText() = KotlinBundle.message("replace.with.0", replaceWith.pattern)
|
||||
|
||||
override fun invoke(replacementStrategy: UsageReplacementStrategy, project: Project, editor: Editor?) {
|
||||
val element = element ?: return
|
||||
|
||||
+5
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
@@ -232,8 +233,10 @@ abstract class DeprecatedSymbolUsageFixBase(
|
||||
)
|
||||
HintManager.getInstance().showErrorHint(
|
||||
editor,
|
||||
"There is own 'ReplaceWith' on '$constructorStr' that is used through this alias. " +
|
||||
"Please replace usages first."
|
||||
KotlinBundle.message(
|
||||
"there.is.own.replacewith.on.0.that.is.used.through.this.alias.please.replace.usages.first",
|
||||
constructorStr
|
||||
)
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
+8
-3
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.codeInliner.UsageReplacementStrategy
|
||||
import org.jetbrains.kotlin.idea.codeInliner.replaceUsagesInWholeProject
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||
@@ -24,7 +25,7 @@ class DeprecatedSymbolUsageInWholeProjectFix(
|
||||
private val text: String
|
||||
) : DeprecatedSymbolUsageFixBase(element, replaceWith) {
|
||||
|
||||
override fun getFamilyName() = "Replace deprecated symbol usage in whole project"
|
||||
override fun getFamilyName() = KotlinBundle.message("replace.deprecated.symbol.usage.in.whole.project")
|
||||
|
||||
override fun getText() = text
|
||||
|
||||
@@ -37,7 +38,11 @@ class DeprecatedSymbolUsageInWholeProjectFix(
|
||||
|
||||
override fun invoke(replacementStrategy: UsageReplacementStrategy, project: Project, editor: Editor?) {
|
||||
val psiElement = targetPsiElement()!!
|
||||
replacementStrategy.replaceUsagesInWholeProject(psiElement, progressTitle = "Applying '$text'", commandName = text)
|
||||
replacementStrategy.replaceUsagesInWholeProject(
|
||||
psiElement,
|
||||
progressTitle = KotlinBundle.message("applying.0", text),
|
||||
commandName = text
|
||||
)
|
||||
}
|
||||
|
||||
private fun targetPsiElement(): KtDeclaration? = when (val referenceTarget = element?.mainReference?.resolve()) {
|
||||
@@ -68,7 +73,7 @@ class DeprecatedSymbolUsageInWholeProjectFix(
|
||||
return DeprecatedSymbolUsageInWholeProjectFix(
|
||||
nameExpression,
|
||||
replacement,
|
||||
"Replace usages of '$descriptorName' in whole project"
|
||||
KotlinBundle.message("replace.usages.of.0.in.whole.project", descriptorName)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||
@@ -49,10 +50,13 @@ class ReplaceProtectedToPublishedApiCallFix(
|
||||
val isPublishedMemberAlreadyExists: Boolean
|
||||
) : KotlinQuickFixAction<KtExpression>(element) {
|
||||
|
||||
override fun getFamilyName() = "Replace with @PublishedApi bridge call"
|
||||
override fun getFamilyName() = KotlinBundle.message("replace.with.publishedapi.bridge.call")
|
||||
|
||||
override fun getText() =
|
||||
"Replace with generated @PublishedApi bridge call '${originalName.newNameQuoted}${if (!isProperty) "(...)" else ""}'"
|
||||
KotlinBundle.message(
|
||||
"replace.with.generated.publishedapi.bridge.call.0",
|
||||
originalName.newNameQuoted + if (!isProperty) "(...)" else ""
|
||||
)
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.intentions.ConvertSecondaryConstructorToPrimaryIntention
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
@@ -23,7 +24,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
|
||||
class ConvertSealedSubClassToObjectFix : LocalQuickFix {
|
||||
|
||||
override fun getFamilyName() = "Convert sealed sub-class to object"
|
||||
override fun getFamilyName() = KotlinBundle.message("convert.sealed.sub.class.to.object.fix.family.name")
|
||||
|
||||
companion object {
|
||||
val JAVA_LANG = Language.findLanguageByID("JAVA")
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix.sealedSubClassToObject
|
||||
import com.intellij.codeInspection.LocalQuickFix
|
||||
import com.intellij.codeInspection.ProblemDescriptor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -44,5 +45,5 @@ class GenerateIdentityEqualsFix : LocalQuickFix {
|
||||
klass.addDeclaration(hashCodeFunction)
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Generate equals & hashCode by identity"
|
||||
override fun getFamilyName() = KotlinBundle.message("generate.identity.equals.fix.family.name")
|
||||
}
|
||||
Reference in New Issue
Block a user