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