i18n: add bundle for idea/quickfix
This commit is contained in:
@@ -973,6 +973,7 @@ text.refactoring.can.t.be.performed.on.the.selected.code.element=Refactoring can
|
||||
text.refactoring.is.not.applicable.to.this.code.fragment=Refactoring is not applicable to this code fragment
|
||||
text.references.in.code.to.0.1.and.its.declarations=References in code to {0} {1} and its declarations
|
||||
text.remove.0.no.longer.used=Remove {0} no longer used
|
||||
text.remove.question=Remove '?'
|
||||
text.remove=remove
|
||||
text.rename.as.part.of.phrase=rename
|
||||
text.rename.is.not.applicable.to.secondary.constructors=Rename is not applicable to secondary constructors
|
||||
@@ -1073,4 +1074,151 @@ 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
|
||||
generate.identity.equals.fix.family.name=Generate equals & hashCode by identity
|
||||
and.delete.initializer=\ and delete initializer
|
||||
change.to.val=Change to val
|
||||
change.to.var=Change to var
|
||||
change.type.of.0.to.1=Change type of {0} to ''{1}''
|
||||
change.type.to.0=Change type to ''{0}''
|
||||
base.property.0=base property {0}
|
||||
make.0=Make {0}
|
||||
make.0.1.explicitly=Make ''{0}'' {1} explicitly
|
||||
make.0.explicitly=Make {0} explicitly
|
||||
use.inherited.visibility=Use inherited visibility
|
||||
replace.with.in.when=Replace ',' with '||' in when
|
||||
remove.0=Remove ''.{0}''
|
||||
remove.conversion.from.kclass.to.class=Remove conversion from 'KClass' to 'Class'
|
||||
convert.to.0=Convert to {0}
|
||||
convert.expression.to.0.by.inserting.1=Convert expression to ''{0}'' by inserting ''.{1}''
|
||||
convert.extension.property.initializer.to.getter=Convert extension property initializer to getter
|
||||
convert.supertype.to.0=Convert supertype to ''{0}''
|
||||
convert.extension.function.type.to.regular.function.type=Convert extension function type to regular function type
|
||||
convert.to.notnull.delegate=Convert to notNull delegate
|
||||
convert.to.anonymous.object=Convert to anonymous object
|
||||
select.loop.statement.to.label=Select loop statement to label
|
||||
select.lambda.to.label=Select lambda to label
|
||||
create.label=Create label
|
||||
create.label.0=Create label {0}@
|
||||
convert.member.to.extension=Convert member to extension
|
||||
replace.annotation=Replace Annotation
|
||||
replace.annotation.with.0=Replace annotation with {0}
|
||||
add.initializer=Add initializer
|
||||
move.to.constructor.parameters=Move to constructor parameters
|
||||
initialize.with.constructor.parameter=Initialize with constructor parameter
|
||||
inline.type.parameter=Inline type parameter
|
||||
insert.explicit.delegation.call=Insert explicit delegation call
|
||||
kotlin.add.required.module.fix.family.name=Add 'requires' directive to module-info.java
|
||||
the.anonymous.object=the anonymous object
|
||||
text.implement=implement
|
||||
text.extend=extend
|
||||
let.0.1=Let {0} {1}
|
||||
let.type.implement.interface=Let type implement interface
|
||||
0.interface.1={0} interface ''{1}''
|
||||
lift.assignment.out.of.try.expression=Lift assignment out of 'try' expression
|
||||
make.class.an.annotation.class=Make class an annotation class
|
||||
make.0.an.annotation.class=Make ''{0}'' an annotation class
|
||||
make.constructor.parameter.a.property.0=Make constructor parameter a property{0}
|
||||
in.class.0=\ in class ''{0}''
|
||||
add.0.to.module.1.compiler.arguments=Add ''{0}'' to module {1} compiler arguments
|
||||
add.an.opt.in.requirement.marker.compiler.argument=Add an opt-in requirement marker compiler argument
|
||||
make.0.in.1.open=Make ''{0}'' in {1} open
|
||||
add.modifier=Add Modifier
|
||||
make.private.and.0.1=Make private and {0} ''{1}''
|
||||
text.overrides=overrides
|
||||
text.implements=implements
|
||||
make.type.parameter.reified.and.function.inline=Make type parameter reified and function inline
|
||||
change.all.usages.of.0.in.this.file.to.1=Change all usages of ''{0}'' in this file to ''{1}''
|
||||
change.all.usages.of.0.in.this.file.to.a.kotlin.class=Change all usages of ''{0}'' in this file to a Kotlin class
|
||||
change.to.kotlin.class=Change to Kotlin class
|
||||
choose.an.appropriate.kotlin.class=Choose an appropriate Kotlin class
|
||||
add.empty.brackets.after.primary.constructor=Add empty brackets after primary constructor
|
||||
add.constructor.keyword=Add 'constructor' keyword
|
||||
move.annotation.to.receiver.type=Move annotation to receiver type
|
||||
move.type.parameter.constraint.to.where.clause=Move type parameter constraint to 'where' clause
|
||||
move.else.branch.to.the.end=Move else branch to the end
|
||||
insert.number.conversion=Insert number conversion
|
||||
convert.expression.to.0=Convert expression to ''{0}''
|
||||
remove.from.annotation.argument=Remove @ from annotation argument
|
||||
remove.default.parameter.value=Remove default parameter value
|
||||
remove.final.upper.bound=Remove final upper bound
|
||||
remove.function.body=Remove function body
|
||||
remove.redundant.0.modifier=Remove redundant ''{0}'' modifier
|
||||
make.0.not.1=Make {0} not {1}
|
||||
remove.0.modifier=Remove ''{0}'' modifier
|
||||
remove.modifier=Remove modifier
|
||||
remove.identifier.from.anonymous.function=Remove identifier from anonymous function
|
||||
remove.constructor.call=Remove constructor call
|
||||
make.not.nullable=Make not-nullable
|
||||
remove.useless=Remove useless '?'
|
||||
remove.redundant=Remove redundant '?'
|
||||
remove.0.from.property=Remove {0} from property
|
||||
remove.parts.from.property=Remove parts from property
|
||||
text.initializer=initializer
|
||||
text.setter=setter
|
||||
text.getter=getter
|
||||
remove.element=Remove element
|
||||
for.0=for ''{0}''
|
||||
remove.conflicting.import.0=Remove conflicting import {0}
|
||||
remove.type.parameters=Remove type parameters
|
||||
remove.type.arguments=Remove type arguments
|
||||
remove.star=Remove '*'
|
||||
remove.variable.0=Remove variable ''{0}''
|
||||
remove.redundant.initializer=Remove redundant initializer
|
||||
remove.redundant.label=Remove redundant label
|
||||
remove.single.lambda.parameter.declaration=Remove single lambda parameter declaration
|
||||
remove.supertype=Remove supertype
|
||||
remove.0.variance.from.1=Remove ''{0}'' variance from ''{1}''
|
||||
remove.parameter.0=Remove parameter ''{0}''
|
||||
remove.redundant.assignment=Remove redundant assignment
|
||||
there.are.possible.side.effects.found.in.expressions.assigned.to.the.variable.0=There are possible side effects found in expressions assigned to the variable ''{0}''<br>You can:<br>- <b>Remove</b> the entire assignment, or<br>- <b>Transform</b> assignment right-hand side into the statement on its own.<br>
|
||||
remove.useless.cast=Remove useless cast
|
||||
remove.useless.elvis.operator=Remove useless elvis operator
|
||||
remove.useless.is.check=Remove useless is check
|
||||
remove.val.var.from.parameter=Remove 'val/var' from parameter
|
||||
remove.0.from.parameter=Remove ''{0}'' from parameter
|
||||
remove.else.branch=Remove else branch
|
||||
rename.identifier.fix.text=Rename
|
||||
rename.to.0=Rename to ''{0}''
|
||||
rename.parameter.to.match.overridden.method=Rename parameter to match overridden method
|
||||
rename.to.underscore=Rename to _
|
||||
replace.with.safe.this.call=Replace with safe (this?.) call
|
||||
replace.with.safe.call=Replace with safe (?.) call
|
||||
replace.scope.function.with.safe.call=Replace scope function with safe (?.) call
|
||||
replace.with.dot.call=Replace with dot call
|
||||
replace.with.safe.call1=Replace with safe (?.) call
|
||||
replace.invalid.positioned.arguments.for.annotation=Replace invalid positioned arguments for annotation
|
||||
replace.jvmfield.with.const=Replace '@JvmField' with 'const'
|
||||
replace.modifier=Replace modifier
|
||||
update.obsolete.label.syntax=Update obsolete label syntax
|
||||
replace.with.label.0.at=Replace with label {0}@
|
||||
replace.cast.with.call.to.to.0=Replace cast with call to ''to{0}()''
|
||||
replace.cast.with.primitive.conversion.method=Replace cast with primitive conversion method
|
||||
replace.with.array.call=Replace with array call
|
||||
remove.expression.target=Remove EXPRESSION target
|
||||
change.existent.retention.to.source=Change existent retention to SOURCE
|
||||
add.source.retention=Add SOURCE retention
|
||||
round.using.0=Round using {0}()
|
||||
simplify.0.to.1=Simplify {0} to ''{1}''
|
||||
simplify.comparison=Simplify comparison
|
||||
specify.override.for.0.explicitly=Specify override for ''{0}'' explicitly
|
||||
specify.override.explicitly=Specify override explicitly
|
||||
specify.return.type.explicitly=Specify return type explicitly
|
||||
specify.type.explicitly=Specify type explicitly
|
||||
add.constructor.parameters.from.0.1=Add constructor parameters from {0}{1}
|
||||
change.to.constructor.invocation=Change to constructor invocation
|
||||
add.constructor.parameters.from.superclass=Add constructor parameters from superclass
|
||||
surround.with.star.0=Surround with *{0}(...)
|
||||
surround.with.lambda=Surround with lambda
|
||||
surround.with.null.check=Surround with null check
|
||||
convert.too.long.character.literal.to.string=Convert too long character literal to string
|
||||
replace.array.of.boxed.with.array.of.primitive=Replace array of boxed with array of primitive
|
||||
migrate.unsupported.yield.syntax=Migrate unsupported yield syntax
|
||||
wrap.with=Wrap with []
|
||||
wrap.with.array.literal=Wrap with array literal
|
||||
wrap.with.collection.literal.call=Wrap with collection literal call
|
||||
wrap.element.with.0.call=Wrap element with ''{0}()'' call
|
||||
replace.with.0.call=Replace with ''{0}()'' call
|
||||
wrap.with.let.call=Wrap with '?.let { ... }' call
|
||||
change.to.0=Change to ''{0}''
|
||||
change.to.correct.long.suffix.l=Change to correct long suffix 'L'
|
||||
change.to.correct.primitive.type=Change to correct primitive type
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreatePropertyDelegateAccessorsActionFactory
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -38,7 +39,8 @@ class ChangeVariableMutabilityFix(
|
||||
) : KotlinQuickFixAction<KtValVarKeywordOwner>(element) {
|
||||
|
||||
override fun getText() = actionText
|
||||
?: (if (makeVar) "Change to var" else "Change to val") + (if (deleteInitializer) " and delete initializer" else "")
|
||||
?: (if (makeVar) KotlinBundle.message("change.to.var") else KotlinBundle.message("change.to.val")) +
|
||||
if (deleteInitializer) KotlinBundle.message("and.delete.initializer") else ""
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
@@ -125,7 +127,7 @@ class ChangeVariableMutabilityFix(
|
||||
val property = element.getStrictParentOfType<KtProperty>() ?: return null
|
||||
val info = CreatePropertyDelegateAccessorsActionFactory.extractFixData(property, diagnostic).singleOrNull() ?: return null
|
||||
if (info.name != OperatorNameConventions.SET_VALUE.asString()) return null
|
||||
return ChangeVariableMutabilityFix(property, makeVar = false, actionText = "Change to val")
|
||||
return ChangeVariableMutabilityFix(property, makeVar = false, actionText = KotlinBundle.message("change.to.val"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ open class ChangeVariableTypeFix(element: KtVariableDeclaration, type: KotlinTyp
|
||||
|
||||
val variablePresentation = variablePresentation()
|
||||
return if (variablePresentation != null) {
|
||||
"Change type of $variablePresentation to '$typePresentation'"
|
||||
KotlinBundle.message("change.type.of.0.to.1", variablePresentation, typePresentation)
|
||||
} else {
|
||||
"Change type to '$typePresentation'"
|
||||
KotlinBundle.message("change.type.to.0", typePresentation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ open class ChangeVariableTypeFix(element: KtVariableDeclaration, type: KotlinTyp
|
||||
class ForOverridden(element: KtVariableDeclaration, type: KotlinType) : ChangeVariableTypeFix(element, type) {
|
||||
override fun variablePresentation(): String? {
|
||||
val presentation = super.variablePresentation() ?: return null
|
||||
return "base property $presentation"
|
||||
return KotlinBundle.message("base.property.0", presentation)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.canBeInternal
|
||||
import org.jetbrains.kotlin.idea.core.canBePrivate
|
||||
import org.jetbrains.kotlin.idea.core.canBeProtected
|
||||
@@ -39,8 +40,8 @@ open class ChangeVisibilityFix(
|
||||
private val addImplicitVisibilityModifier: Boolean = false
|
||||
) : KotlinQuickFixAction<KtModifierListOwner>(element) {
|
||||
|
||||
override fun getText() = "Make '$elementName' $visibilityModifier"
|
||||
override fun getFamilyName() = "Make $visibilityModifier"
|
||||
override fun getText() = KotlinBundle.message("make.0.1", elementName, visibilityModifier)
|
||||
override fun getFamilyName() = KotlinBundle.message("make.0", visibilityModifier)
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val pointer = element?.createSmartPointer()
|
||||
@@ -95,8 +96,8 @@ open class ChangeVisibilityFix(
|
||||
KtTokens.PUBLIC_KEYWORD,
|
||||
addImplicitVisibilityModifier = true
|
||||
), HighPriorityAction {
|
||||
override fun getText() = "Make '$elementName' $visibilityModifier explicitly"
|
||||
override fun getFamilyName() = "Make $visibilityModifier explicitly"
|
||||
override fun getText() = KotlinBundle.message("make.0.1.explicitly", elementName, visibilityModifier)
|
||||
override fun getFamilyName() = KotlinBundle.message("make.0.explicitly", visibilityModifier)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -19,12 +19,13 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType
|
||||
|
||||
class ChangeVisibilityModifierFix(element: KtDeclaration) : KotlinQuickFixAction<KtDeclaration>(element) {
|
||||
override fun getFamilyName() = "Use inherited visibility"
|
||||
override fun getFamilyName() = KotlinBundle.message("use.inherited.visibility")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.combineWhenConditions
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -18,7 +19,7 @@ import java.util.*
|
||||
|
||||
class CommaInWhenConditionWithoutArgumentFix(element: PsiElement) : KotlinQuickFixAction<PsiElement>(element), CleanupFix {
|
||||
override fun getFamilyName(): String = text
|
||||
override fun getText(): String = "Replace ',' with '||' in when"
|
||||
override fun getText(): String = KotlinBundle.message("replace.with.in.when")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val whenExpression = element as? KtWhenExpression ?: return
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
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.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
|
||||
@@ -45,8 +46,8 @@ class ConvertClassToKClassFix(element: KtDotQualifiedExpression, type: KotlinTyp
|
||||
return@run firstChildType.isSubtypeOf(type)
|
||||
}
|
||||
|
||||
override fun getText() = element?.let { "Remove '.${it.children.lastOrNull()?.text}'" } ?: ""
|
||||
override fun getFamilyName() = "Remove conversion from 'KClass' to 'Class'"
|
||||
override fun getText() = element?.let { KotlinBundle.message("remove.0", it.children.lastOrNull()?.text.toString()) } ?: ""
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.conversion.from.kclass.to.class")
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) = isApplicable
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -30,8 +31,8 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
|
||||
class ConvertCollectionFix(element: KtExpression, val type: CollectionType) : KotlinQuickFixAction<KtExpression>(element) {
|
||||
override fun getFamilyName(): String = "Convert to ${type.displayName}"
|
||||
override fun getText() = "Convert expression to '${type.displayName}' by inserting '.${type.functionCall}'"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("convert.to.0", type.displayName)
|
||||
override fun getText() = KotlinBundle.message("convert.expression.to.0.by.inserting.1", type.displayName, type.functionCall)
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val expression = element ?: return
|
||||
|
||||
+2
-1
@@ -20,6 +20,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.intentions.ConvertPropertyInitializerToGetterIntention
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -27,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
|
||||
class ConvertExtensionPropertyInitializerToGetterFix(element: KtExpression) : KotlinQuickFixAction<KtExpression>(element) {
|
||||
override fun getText(): String = "Convert extension property initializer to getter"
|
||||
override fun getText(): String = KotlinBundle.message("convert.extension.property.initializer.to.getter")
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
|
||||
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.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
@@ -40,8 +41,8 @@ class ConvertExtensionToFunctionTypeFix(element: KtTypeReference, type: KotlinTy
|
||||
private val targetTypeStringShort = type.renderType(IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS)
|
||||
private val targetTypeStringLong = type.renderType(IdeDescriptorRenderers.SOURCE_CODE)
|
||||
|
||||
override fun getText() = "Convert supertype to '$targetTypeStringShort'"
|
||||
override fun getFamilyName() = "Convert extension function type to regular function type"
|
||||
override fun getText() = KotlinBundle.message("convert.supertype.to.0", targetTypeStringShort)
|
||||
override fun getFamilyName() = KotlinBundle.message("convert.extension.function.type.to.regular.function.type")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
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.lexer.KtTokens
|
||||
@@ -20,7 +21,7 @@ class ConvertLateinitPropertyToNotNullDelegateFix(
|
||||
property: KtProperty,
|
||||
private val type: String
|
||||
) : KotlinQuickFixAction<KtProperty>(property) {
|
||||
override fun getText() = "Convert to notNull delegate"
|
||||
override fun getText() = KotlinBundle.message("convert.to.notnull.delegate")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters3
|
||||
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.SamConversionToAnonymousObjectIntention
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
@@ -23,7 +24,7 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
|
||||
class ConvertToAnonymousObjectFix(element: KtNameReferenceExpression) : KotlinQuickFixAction<KtNameReferenceExpression>(element) {
|
||||
override fun getFamilyName() = "Convert to anonymous object"
|
||||
override fun getFamilyName() = KotlinBundle.message("convert.to.anonymous.object")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
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.refactoring.chooseContainerElementIfNecessary
|
||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -30,22 +31,22 @@ sealed class CreateLabelFix(
|
||||
expression: KtLabelReferenceExpression
|
||||
) : KotlinQuickFixAction<KtLabelReferenceExpression>(expression) {
|
||||
class ForLoop(expression: KtLabelReferenceExpression) : CreateLabelFix(expression) {
|
||||
override val chooserTitle = "Select loop statement to label"
|
||||
override val chooserTitle = KotlinBundle.message("select.loop.statement.to.label")
|
||||
|
||||
override fun getCandidateExpressions(labelReferenceExpression: KtLabelReferenceExpression) =
|
||||
labelReferenceExpression.getContainingLoops().toList()
|
||||
}
|
||||
|
||||
class ForLambda(expression: KtLabelReferenceExpression) : CreateLabelFix(expression) {
|
||||
override val chooserTitle = "Select lambda to label"
|
||||
override val chooserTitle = KotlinBundle.message("select.lambda.to.label")
|
||||
|
||||
override fun getCandidateExpressions(labelReferenceExpression: KtLabelReferenceExpression) =
|
||||
labelReferenceExpression.getContainingLambdas().toList()
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Create label"
|
||||
override fun getFamilyName() = KotlinBundle.message("create.label")
|
||||
|
||||
override fun getText() = "Create label ${element?.getReferencedName() ?: ""}@"
|
||||
override fun getText() = KotlinBundle.message("create.label.0", element?.getReferencedName() ?: "")
|
||||
|
||||
abstract val chooserTitle: String
|
||||
|
||||
|
||||
@@ -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.intentions.declarations.ConvertMemberToExtensionIntention
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -30,7 +31,7 @@ object DeclarationCantBeInlinedFactory : KotlinIntentionActionsFactory() {
|
||||
}
|
||||
|
||||
private class ConvertMemberToExtensionFix(element: KtNamedFunction) : KotlinQuickFixAction<KtNamedFunction>(element) {
|
||||
override fun getText() = "Convert member to extension"
|
||||
override fun getText() = KotlinBundle.message("convert.member.to.extension")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -5,6 +5,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.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
@@ -20,8 +21,8 @@ internal class DeprecatedJavaAnnotationFix(
|
||||
element: KtAnnotationEntry,
|
||||
private val annotationFqName: FqName
|
||||
) : KotlinQuickFixAction<KtAnnotationEntry>(element) {
|
||||
override fun getFamilyName() = "Replace Annotation"
|
||||
override fun getText(): String = "Replace annotation with ${annotationFqName.asString()}"
|
||||
override fun getFamilyName() = KotlinBundle.message("replace.annotation")
|
||||
override fun getText(): String = KotlinBundle.message("replace.annotation.with.0", annotationFqName.asString())
|
||||
|
||||
override fun startInWriteAction(): Boolean = false
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.codeInsight.shorten.runRefactoringAndKeepDelayedRequests
|
||||
import org.jetbrains.kotlin.idea.core.CollectingNameValidator
|
||||
@@ -41,7 +42,7 @@ import java.util.*
|
||||
|
||||
object InitializePropertyQuickFixFactory : KotlinIntentionActionsFactory() {
|
||||
class AddInitializerFix(property: KtProperty) : KotlinQuickFixAction<KtProperty>(property) {
|
||||
override fun getText() = "Add initializer"
|
||||
override fun getText() = KotlinBundle.message("add.initializer")
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
@@ -58,7 +59,7 @@ object InitializePropertyQuickFixFactory : KotlinIntentionActionsFactory() {
|
||||
}
|
||||
|
||||
class MoveToConstructorParameters(property: KtProperty) : KotlinQuickFixAction<KtProperty>(property) {
|
||||
override fun getText() = "Move to constructor parameters"
|
||||
override fun getText() = KotlinBundle.message("move.to.constructor.parameters")
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun startInWriteAction(): Boolean = false
|
||||
@@ -122,7 +123,7 @@ object InitializePropertyQuickFixFactory : KotlinIntentionActionsFactory() {
|
||||
}
|
||||
|
||||
class InitializeWithConstructorParameter(property: KtProperty) : KotlinQuickFixAction<KtProperty>(property) {
|
||||
override fun getText() = "Initialize with constructor parameter"
|
||||
override fun getText() = KotlinBundle.message("initialize.with.constructor.parameter")
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun startInWriteAction(): Boolean = false
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
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.analyzeWithContent
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
@@ -49,7 +50,7 @@ class InlineTypeParameterFix(val typeReference: KtTypeReference) : KotlinQuickFi
|
||||
}
|
||||
}
|
||||
|
||||
override fun getText() = "Inline type parameter"
|
||||
override fun getText() = KotlinBundle.message("inline.type.parameter")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
class InsertDelegationCallQuickfix(val isThis: Boolean, element: KtSecondaryConstructor) :
|
||||
KotlinQuickFixAction<KtSecondaryConstructor>(element) {
|
||||
override fun getText() = KotlinBundle.message("fix.insert.delegation.call", keywordToUse)
|
||||
override fun getFamilyName() = "Insert explicit delegation call"
|
||||
override fun getFamilyName() = KotlinBundle.message("insert.explicit.delegation.call")
|
||||
|
||||
private val keywordToUse = if (isThis) "this" else "super"
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.util.findRequireDirective
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
@@ -22,7 +23,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
class KotlinAddRequiredModuleFix(module: PsiJavaModule, private val requiredName: String) :
|
||||
LocalQuickFixAndIntentionActionOnPsiElement(module) {
|
||||
@Suppress("InvalidBundleOrProperty")
|
||||
override fun getFamilyName(): String = "Add 'requires' directive to module-info.java"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("kotlin.add.required.module.fix.family.name")
|
||||
|
||||
@Suppress("InvalidBundleOrProperty")
|
||||
override fun getText(): String = QuickFixBundle.message("module.info.add.requires.name", requiredName)
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.containsStarProjections
|
||||
@@ -59,14 +60,17 @@ class LetImplementInterfaceFix(
|
||||
expectedTypeName = expectedTypeNotNullable.renderShort()
|
||||
expectedTypeNameSourceCode = IdeDescriptorRenderers.SOURCE_CODE.renderType(expectedTypeNotNullable)
|
||||
|
||||
val verb = if (expressionType.isInterface()) "extend" else "implement"
|
||||
val typeDescription = if (element.isObjectLiteral()) "the anonymous object" else "'${expressionType.renderShort()}'"
|
||||
prefix = "Let $typeDescription $verb"
|
||||
val verb = if (expressionType.isInterface()) KotlinBundle.message("text.extend") else KotlinBundle.message("text.implement")
|
||||
val typeDescription = if (element.isObjectLiteral())
|
||||
KotlinBundle.message("the.anonymous.object")
|
||||
else
|
||||
"'${expressionType.renderShort()}'"
|
||||
prefix = KotlinBundle.message("let.0.1", typeDescription, verb)
|
||||
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Let type implement interface"
|
||||
override fun getText() = "$prefix interface '$expectedTypeName'"
|
||||
override fun getFamilyName() = KotlinBundle.message("let.type.implement.interface")
|
||||
override fun getText() = KotlinBundle.message("0.interface.1", prefix, expectedTypeName)
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) = validExpectedType
|
||||
|
||||
|
||||
@@ -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.intentions.branchedTransformations.BranchedFoldingUtils
|
||||
import org.jetbrains.kotlin.psi.KtCatchClause
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -18,7 +19,7 @@ import org.jetbrains.kotlin.psi.KtTryExpression
|
||||
class LiftAssignmentOutOfTryFix(element: KtTryExpression) : KotlinQuickFixAction<KtTryExpression>(element) {
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun getText() = "Lift assignment out of 'try' expression"
|
||||
override fun getText() = KotlinBundle.message("lift.assignment.out.of.try.expression")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -20,6 +20,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.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
@@ -27,9 +28,9 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class MakeClassAnAnnotationClassFix(annotationClass: KtClass) : KotlinQuickFixAction<KtClass>(annotationClass) {
|
||||
override fun getFamilyName() = "Make class an annotation class"
|
||||
override fun getFamilyName() = KotlinBundle.message("make.class.an.annotation.class")
|
||||
|
||||
override fun getText() = element?.let { "Make '${it.name}' an annotation class" } ?: ""
|
||||
override fun getText() = element?.let { KotlinBundle.message("make.0.an.annotation.class", it.name.toString()) } ?: ""
|
||||
|
||||
public override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -32,11 +33,11 @@ import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
class MakeConstructorParameterPropertyFix(
|
||||
element: KtParameter, private val kotlinValVar: KotlinValVar, className: String?
|
||||
) : KotlinQuickFixAction<KtParameter>(element) {
|
||||
override fun getFamilyName() = "Make constructor parameter a property"
|
||||
override fun getFamilyName() = KotlinBundle.message("make.constructor.parameter.a.property.0", "")
|
||||
|
||||
private val suffix = if (className != null) " in class '$className'" else ""
|
||||
private val suffix = if (className != null) KotlinBundle.message("in.class.0", className) else ""
|
||||
|
||||
override fun getText() = "Make constructor parameter a property$suffix"
|
||||
override fun getText() = KotlinBundle.message("make.constructor.parameter.a.property.0", suffix)
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
|
||||
val element = element ?: return false
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.CompilerSettings
|
||||
import org.jetbrains.kotlin.config.additionalArgumentsAsList
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.project.toDescriptor
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
@@ -35,9 +36,9 @@ class MakeModuleExperimentalFix(
|
||||
else
|
||||
"use-experimental"
|
||||
|
||||
override fun getText(): String = "Add '$compilerArgument' to module ${module.name} compiler arguments"
|
||||
override fun getText(): String = KotlinBundle.message("add.0.to.module.1.compiler.arguments", compilerArgument, module.name)
|
||||
|
||||
override fun getFamilyName(): String = "Add an opt-in requirement marker compiler argument"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("add.an.opt.in.requirement.marker.compiler.argument")
|
||||
|
||||
private val compilerArgument = "-X$experimentalPrefix=$annotationFqName"
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.isOverridable
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.core.util.CachedValue
|
||||
import org.jetbrains.kotlin.idea.core.util.getValue
|
||||
@@ -86,15 +87,16 @@ class MakeOverriddenMemberOpenFix(declaration: KtDeclaration) : KotlinQuickFixAc
|
||||
val element = element ?: return ""
|
||||
if (containingDeclarationsNames.size == 1) {
|
||||
val name = containingDeclarationsNames[0] + "." + element.name
|
||||
return "Make $name $OPEN_KEYWORD"
|
||||
return KotlinBundle.message("make.0", "$name $OPEN_KEYWORD")
|
||||
}
|
||||
val sortedDeclarationNames = containingDeclarationsNames.sorted()
|
||||
val declarations = sortedDeclarationNames.subList(0, sortedDeclarationNames.size - 1).joinToString(", ") + " and " +
|
||||
val declarations = sortedDeclarationNames.subList(0, sortedDeclarationNames.size - 1).joinToString(", ") +
|
||||
" ${KotlinBundle.message("configuration.text.and")} " +
|
||||
sortedDeclarationNames.last()
|
||||
return "Make '${element.name}' in $declarations open"
|
||||
return KotlinBundle.message("make.0.in.1.open", element.name.toString(), declarations)
|
||||
}
|
||||
|
||||
override fun getFamilyName(): String = "Add Modifier"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("add.modifier")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
for (overriddenMember in overriddenNonOverridableMembers) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.ImplementMembersHandler
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideImplementMembersHandler
|
||||
@@ -38,9 +39,19 @@ class MakePrivateAndOverrideMemberFix(
|
||||
val implement = (descriptor.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.INTERFACE
|
||||
val name = descriptor.name.asString()
|
||||
return if (makePrivate) {
|
||||
"Make private and ${if (implement) "implements" else "overrides"} '$name'"
|
||||
KotlinBundle.message(
|
||||
"make.private.and.0.1",
|
||||
if (implement)
|
||||
KotlinBundle.message("text.implements")
|
||||
else
|
||||
KotlinBundle.message("text.overrides"),
|
||||
name
|
||||
)
|
||||
} else {
|
||||
"${if (implement) "Implements" else "Overrides"} '$name'"
|
||||
(if (implement)
|
||||
KotlinBundle.message("highlighter.text.implements")
|
||||
else
|
||||
KotlinBundle.message("highlighter.text.overrides")) + " '$name'"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -25,7 +26,7 @@ class MakeTypeParameterReifiedAndFunctionInlineFix(
|
||||
|
||||
private val inlineFix = AddInlineToFunctionWithReifiedFix(function)
|
||||
|
||||
override fun getText() = "Make type parameter reified and function inline"
|
||||
override fun getText() = KotlinBundle.message("make.type.parameter.reified.and.function.inline")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.refactoring.rename.inplace.MyLookupExpression
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
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.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
@@ -41,13 +42,16 @@ class MapPlatformClassToKotlinFix(
|
||||
val platformClassQualifiedName = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(platformClass.defaultType)
|
||||
val singleClass = possibleClasses.singleOrNull()
|
||||
return if (singleClass != null)
|
||||
"Change all usages of '$platformClassQualifiedName' in this file to '${DescriptorRenderer.FQ_NAMES_IN_TYPES
|
||||
.renderType(singleClass.defaultType)}'"
|
||||
KotlinBundle.message(
|
||||
"change.all.usages.of.0.in.this.file.to.1",
|
||||
platformClassQualifiedName,
|
||||
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(singleClass.defaultType)
|
||||
)
|
||||
else
|
||||
"Change all usages of '$platformClassQualifiedName' in this file to a Kotlin class"
|
||||
KotlinBundle.message("change.all.usages.of.0.in.this.file.to.a.kotlin.class", platformClassQualifiedName)
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Change to Kotlin class"
|
||||
override fun getFamilyName() = KotlinBundle.message("change.to.kotlin.class")
|
||||
|
||||
public override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val bindingContext = file.analyzeWithContent()
|
||||
@@ -121,8 +125,14 @@ class MapPlatformClassToKotlinFix(
|
||||
caretModel.moveToOffset(file.node.startOffset)
|
||||
|
||||
val builder = TemplateBuilderImpl(file)
|
||||
val expression =
|
||||
MyLookupExpression(primaryReplacedExpression.text, options, null, null, false, "Choose an appropriate Kotlin class")
|
||||
val expression = MyLookupExpression(
|
||||
primaryReplacedExpression.text,
|
||||
options,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
KotlinBundle.message("choose.an.appropriate.kotlin.class")
|
||||
)
|
||||
|
||||
builder.replaceElement(primaryReplacedExpression, PRIMARY_USAGE, expression, true)
|
||||
for (replacedExpression in replacedElements) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.util.createIntentionForFirstParentOfType
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||
@@ -17,7 +18,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
|
||||
class MissingConstructorBracketsFix(element: KtPrimaryConstructor) : KotlinQuickFixAction<KtPrimaryConstructor>(element), CleanupFix {
|
||||
override fun getFamilyName(): String = text
|
||||
override fun getText(): String = "Add empty brackets after primary constructor"
|
||||
override fun getText(): String = KotlinBundle.message("add.empty.brackets.after.primary.constructor")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val constructor = element ?: return
|
||||
|
||||
@@ -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.util.addConstructorKeyword
|
||||
import org.jetbrains.kotlin.idea.util.createIntentionForFirstParentOfType
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -16,7 +17,7 @@ import org.jetbrains.kotlin.psi.KtPrimaryConstructor
|
||||
|
||||
class MissingConstructorKeywordFix(element: KtPrimaryConstructor) : KotlinQuickFixAction<KtPrimaryConstructor>(element), CleanupFix {
|
||||
override fun getFamilyName(): String = text
|
||||
override fun getText(): String = "Add 'constructor' keyword"
|
||||
override fun getText(): String = KotlinBundle.message("add.constructor.keyword")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
element?.addConstructorKeyword()
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -28,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
|
||||
class MoveReceiverAnnotationFix(element: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(element) {
|
||||
|
||||
override fun getFamilyName() = "Move annotation to receiver type"
|
||||
override fun getFamilyName() = KotlinBundle.message("move.annotation.to.receiver.type")
|
||||
override fun getText() = familyName
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -20,12 +20,13 @@ 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.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class MoveTypeParameterConstraintFix(element: KtTypeParameter) : KotlinQuickFixAction<KtTypeParameter>(element), CleanupFix {
|
||||
override fun getText(): String = "Move type parameter constraint to 'where' clause"
|
||||
override fun getText(): String = KotlinBundle.message("move.type.parameter.constraint.to.where.clause")
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightUtilCore
|
||||
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.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.KtWhenEntry
|
||||
@@ -27,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtWhenExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class MoveWhenElseBranchFix(element: KtWhenExpression) : KotlinQuickFixAction<KtWhenExpression>(element) {
|
||||
override fun getFamilyName() = "Move else branch to the end"
|
||||
override fun getFamilyName() = KotlinBundle.message("move.else.branch.to.the.end")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
@@ -46,8 +47,8 @@ class NumberConversionFix(
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) =
|
||||
disableIfAvailable?.isAvailable(project, editor, file) != true && isConversionAvailable
|
||||
|
||||
override fun getFamilyName() = "Insert number conversion"
|
||||
override fun getText() = "Convert expression to '$typePresentation'"
|
||||
override fun getFamilyName() = KotlinBundle.message("insert.number.conversion")
|
||||
override fun getText() = KotlinBundle.message("convert.expression.to.0", typePresentation)
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtAnnotatedExpression
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -26,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
|
||||
class RemoveAtFromAnnotationArgument(constructor: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(constructor) {
|
||||
|
||||
override fun getText() = "Remove @ from annotation argument"
|
||||
override fun getText() = KotlinBundle.message("remove.from.annotation.argument")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.util.CommentSaver
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
class RemoveDefaultParameterValueFix(parameter: KtParameter) : KotlinQuickFixAction<KtParameter>(parameter) {
|
||||
|
||||
override fun getText() = "Remove default parameter value"
|
||||
override fun getText() = KotlinBundle.message("remove.default.parameter.value")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtTypeParameter
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
@@ -30,7 +31,7 @@ class RemoveFinalUpperBoundFix(val typeReference: KtTypeReference) : KotlinQuick
|
||||
typeReference.getStrictParentOfType<KtTypeParameter>()?.extendsBound = null
|
||||
}
|
||||
|
||||
override fun getText() = "Remove final upper bound"
|
||||
override fun getText() = KotlinBundle.message("remove.final.upper.bound")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.util.CommentSaver
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtFunction
|
||||
@@ -15,7 +16,7 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiChildRange
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class RemoveFunctionBodyFix(element: KtFunction) : KotlinQuickFixAction<KtFunction>(element) {
|
||||
override fun getFamilyName() = "Remove function body"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.function.body")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -26,15 +27,15 @@ class RemoveModifierFix(
|
||||
val modifierText = modifier.value
|
||||
when {
|
||||
isRedundant ->
|
||||
"Remove redundant '$modifierText' modifier"
|
||||
KotlinBundle.message("remove.redundant.0.modifier", modifierText)
|
||||
modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD ->
|
||||
"Make ${AddModifierFix.getElementName(element)} not $modifierText"
|
||||
KotlinBundle.message("make.0.not.1", AddModifierFix.getElementName(element), modifierText)
|
||||
else ->
|
||||
"Remove '$modifierText' modifier"
|
||||
KotlinBundle.message("remove.0.modifier", modifierText, modifier)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Remove modifier"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.modifier")
|
||||
|
||||
override fun getText() = text
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.util.createIntentionForFirstParentOfType
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -15,7 +16,7 @@ import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
class RemoveNameFromFunctionExpressionFix(element: KtNamedFunction) : KotlinQuickFixAction<KtNamedFunction>(element), CleanupFix {
|
||||
override fun getText(): String = "Remove identifier from anonymous function"
|
||||
override fun getText(): String = KotlinBundle.message("remove.identifier.from.anonymous.function")
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.core.replaced
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -17,7 +18,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class RemoveNoConstructorFix(constructor: KtValueArgumentList) : KotlinQuickFixAction<KtValueArgumentList>(constructor) {
|
||||
|
||||
override fun getText() = "Remove constructor call"
|
||||
override fun getText() = KotlinBundle.message("remove.constructor.call")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNullableType
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
@@ -31,13 +32,13 @@ class RemoveNullableFix(
|
||||
private val typeOfError: NullableKind
|
||||
) : KotlinQuickFixAction<KtNullableType>(element) {
|
||||
enum class NullableKind(val message: String) {
|
||||
REDUNDANT("Remove redundant '?'"),
|
||||
SUPERTYPE("Remove '?'"),
|
||||
USELESS("Remove useless '?'"),
|
||||
PROPERTY("Make not-nullable")
|
||||
REDUNDANT(KotlinBundle.message("remove.redundant")),
|
||||
SUPERTYPE(KotlinBundle.message("text.remove.question")),
|
||||
USELESS(KotlinBundle.message("remove.useless")),
|
||||
PROPERTY(KotlinBundle.message("make.not.nullable"))
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Remove '?'"
|
||||
override fun getFamilyName() = KotlinBundle.message("text.remove.question")
|
||||
|
||||
override fun getText() = typeOfError.message
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
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.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
|
||||
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
|
||||
@@ -35,10 +36,12 @@ open class RemovePartsFromPropertyFix(
|
||||
element.setter?.bodyExpression != null
|
||||
)
|
||||
|
||||
override fun getText(): String =
|
||||
"Remove ${partsToRemove(removeGetter, removeSetter, removeInitializer)} from property"
|
||||
override fun getText(): String = KotlinBundle.message(
|
||||
"remove.0.from.property",
|
||||
partsToRemove(removeGetter, removeSetter, removeInitializer)
|
||||
)
|
||||
|
||||
override fun getFamilyName(): String = "Remove parts from property"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("remove.parts.from.property")
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
|
||||
val type = QuickFixUtil.getDeclarationReturnType(element) ?: return false
|
||||
@@ -90,17 +93,17 @@ open class RemovePartsFromPropertyFix(
|
||||
|
||||
private fun partsToRemove(getter: Boolean, setter: Boolean, initializer: Boolean): String = buildString {
|
||||
if (getter) {
|
||||
append("getter")
|
||||
append(KotlinBundle.message("text.getter"))
|
||||
if (setter && initializer)
|
||||
append(", ")
|
||||
else if (setter || initializer)
|
||||
append(" and ")
|
||||
append(" ${KotlinBundle.message("configuration.text.and")} ")
|
||||
}
|
||||
if (setter) {
|
||||
append("setter")
|
||||
if (initializer) append(" and ")
|
||||
append(KotlinBundle.message("text.setter"))
|
||||
if (initializer) append(" ${KotlinBundle.message("configuration.text.and")} ")
|
||||
}
|
||||
if (initializer) append("initializer")
|
||||
if (initializer) append(KotlinBundle.message("text.initializer"))
|
||||
}
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeIntention
|
||||
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -27,7 +28,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
open class RemovePsiElementSimpleFix(element: PsiElement, private val text: String) : KotlinQuickFixAction<PsiElement>(element) {
|
||||
override fun getFamilyName() = "Remove element"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.element")
|
||||
|
||||
override fun getText() = text
|
||||
|
||||
@@ -38,8 +39,8 @@ open class RemovePsiElementSimpleFix(element: PsiElement, private val text: Stri
|
||||
object RemoveImportFactory : KotlinSingleIntentionActionFactory() {
|
||||
public override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<PsiElement>? {
|
||||
val directive = diagnostic.psiElement.getNonStrictParentOfType<KtImportDirective>() ?: return null
|
||||
val refText = directive.importedReference?.let { "for '${it.text}'" } ?: ""
|
||||
return RemovePsiElementSimpleFix(directive, "Remove conflicting import $refText")
|
||||
val refText = directive.importedReference?.let { KotlinBundle.message("for.0", it.text) } ?: ""
|
||||
return RemovePsiElementSimpleFix(directive, KotlinBundle.message("remove.conflicting.import.0", refText))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,21 +48,21 @@ open class RemovePsiElementSimpleFix(element: PsiElement, private val text: Stri
|
||||
public override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<PsiElement>? {
|
||||
val element = diagnostic.psiElement
|
||||
if (element.node.elementType != KtTokens.MUL) return null
|
||||
return RemovePsiElementSimpleFix(element, "Remove '*'")
|
||||
return RemovePsiElementSimpleFix(element, KotlinBundle.message("remove.star"))
|
||||
}
|
||||
}
|
||||
|
||||
object RemoveTypeArgumentsFactory : KotlinSingleIntentionActionFactory() {
|
||||
public override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<PsiElement>? {
|
||||
val element = diagnostic.psiElement.getNonStrictParentOfType<KtTypeArgumentList>() ?: return null
|
||||
return RemovePsiElementSimpleFix(element, "Remove type arguments")
|
||||
return RemovePsiElementSimpleFix(element, KotlinBundle.message("remove.type.arguments"))
|
||||
}
|
||||
}
|
||||
|
||||
object RemoveTypeParametersFactory : KotlinSingleIntentionActionFactory() {
|
||||
public override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<PsiElement>? {
|
||||
val element = diagnostic.psiElement.getNonStrictParentOfType<KtTypeParameterList>() ?: return null
|
||||
return RemovePsiElementSimpleFix(element, "Remove type parameters")
|
||||
return RemovePsiElementSimpleFix(element, KotlinBundle.message("remove.type.parameters"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ open class RemovePsiElementSimpleFix(element: PsiElement, private val text: Stri
|
||||
public override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<PsiElement>? {
|
||||
val expression = diagnostic.psiElement.getNonStrictParentOfType<KtProperty>() ?: return null
|
||||
if (!RemoveExplicitTypeIntention.redundantTypeSpecification(expression.typeReference, expression.initializer)) return null
|
||||
return object : RemovePsiElementSimpleFix(expression, "Remove variable '${expression.name}'") {
|
||||
return object : RemovePsiElementSimpleFix(expression, KotlinBundle.message("remove.variable.0", expression.name.toString())) {
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val initializer = expression.initializer
|
||||
if (initializer != null && initializer !is KtConstantExpression) {
|
||||
|
||||
@@ -18,13 +18,14 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
|
||||
class RemoveRedundantInitializerFix(element: KtProperty) : RemovePartsFromPropertyFix(element, true, false, false) {
|
||||
|
||||
override fun getText(): String = "Remove redundant initializer"
|
||||
override fun getText(): String = KotlinBundle.message("remove.redundant.initializer")
|
||||
|
||||
override fun getFamilyName(): String = "Remove redundant initializer"
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<KtProperty>? {
|
||||
|
||||
@@ -8,13 +8,14 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtLabelReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtLabeledExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class RemoveRedundantLabelFix(element: KtLabeledExpression) : KotlinQuickFixAction<KtLabeledExpression>(element) {
|
||||
override fun getText(): String = "Remove redundant label"
|
||||
override fun getText(): String = KotlinBundle.message("remove.redundant.label")
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@ 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.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class RemoveSingleLambdaParameterFix(element: KtParameter) : KotlinQuickFixAction<KtParameter>(element) {
|
||||
override fun getFamilyName() = "Remove single lambda parameter declaration"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.single.lambda.parameter.declaration")
|
||||
override fun getText() = familyName
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtSuperTypeListEntry
|
||||
@@ -26,7 +27,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class RemoveSupertypeFix(superClass: KtSuperTypeListEntry) : KotlinQuickFixAction<KtSuperTypeListEntry>(superClass) {
|
||||
override fun getFamilyName() = "Remove supertype"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.supertype")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -26,7 +27,7 @@ class RemoveTypeVarianceFix(
|
||||
private val type: String
|
||||
) : KotlinQuickFixAction<KtTypeParameter>(typeParameter) {
|
||||
|
||||
override fun getText(): String = "Remove '${variance.label}' variance from '$type'"
|
||||
override fun getText(): String = KotlinBundle.message("remove.0.variance.from.1", variance.label, type)
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
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.resolveToParameterDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.intentions.RemoveEmptyPrimaryConstructorIntention
|
||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
@@ -23,7 +24,7 @@ class RemoveUnusedFunctionParameterFix(parameter: KtParameter, private val check
|
||||
KotlinQuickFixAction<KtParameter>(parameter) {
|
||||
override fun getFamilyName() = ChangeFunctionSignatureFix.FAMILY_NAME
|
||||
|
||||
override fun getText() = element?.let { "Remove parameter '${it.name}'" } ?: ""
|
||||
override fun getText() = element?.let { KotlinBundle.message("remove.parameter.0", it.name.toString()) } ?: ""
|
||||
|
||||
override fun startInWriteAction(): Boolean = false
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.getContainingPseudocode
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.sideEffectFree
|
||||
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.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -40,15 +41,10 @@ class RemoveUnusedValueFix(expression: KtBinaryExpression) : KotlinQuickFixActio
|
||||
private fun showDialog(variable: KtProperty, project: Project, element: KtBinaryExpression, rhs: KtExpression) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) return doRemove(RemoveMode.KEEP_INITIALIZE, element, rhs)
|
||||
|
||||
val message =
|
||||
"""<html>
|
||||
<body>
|
||||
There are possible side effects found in expressions assigned to the variable '${variable.name}'<br>
|
||||
You can:<br>
|
||||
- <b>Remove</b> the entire assignment, or<br>
|
||||
- <b>Transform</b> assignment right-hand side into the statement on its own.<br>
|
||||
</body>
|
||||
</html>"""
|
||||
val message = "<html><body>${KotlinBundle.message(
|
||||
"there.are.possible.side.effects.found.in.expressions.assigned.to.the.variable.0",
|
||||
variable.name.toString()
|
||||
)}</body></html>"
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val exitCode = Messages.showYesNoCancelDialog(
|
||||
@@ -66,7 +62,7 @@ class RemoveUnusedValueFix(expression: KtBinaryExpression) : KotlinQuickFixActio
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Remove redundant assignment"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.redundant.assignment")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.core.dropEnclosingParenthesesIfPossible
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.psi.KtBinaryExpressionWithTypeRHS
|
||||
@@ -16,7 +17,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class RemoveUselessCastFix(element: KtBinaryExpressionWithTypeRHS) : KotlinQuickFixAction<KtBinaryExpressionWithTypeRHS>(element),
|
||||
CleanupFix {
|
||||
override fun getFamilyName() = "Remove useless cast"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.useless.cast")
|
||||
|
||||
override fun getText(): String = familyName
|
||||
|
||||
|
||||
@@ -19,13 +19,14 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.core.dropEnclosingParenthesesIfPossible
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.psi.KtBinaryExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
class RemoveUselessElvisFix(element: KtBinaryExpression) : KotlinQuickFixAction<KtBinaryExpression>(element), CleanupFix {
|
||||
override fun getFamilyName(): String = "Remove useless elvis operator"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("remove.useless.elvis.operator")
|
||||
|
||||
override fun getText(): String = familyName
|
||||
|
||||
|
||||
@@ -19,13 +19,14 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtIsExpression
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class RemoveUselessIsCheckFix(element: KtIsExpression) : KotlinQuickFixAction<KtIsExpression>(element) {
|
||||
override fun getFamilyName() = "Remove useless is check"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.useless.is.check")
|
||||
|
||||
override fun getText(): String = familyName
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class RemoveUselessIsCheckFixForWhen(element: KtWhenConditionIsPattern) : KotlinQuickFixAction<KtWhenConditionIsPattern>(element) {
|
||||
override fun getFamilyName() = "Remove useless is check"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.useless.is.check")
|
||||
|
||||
override fun getText(): String = familyName
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtValVarKeywordOwner
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||
@@ -21,12 +22,12 @@ class RemoveValVarFromParameterFix(element: KtValVarKeywordOwner) : KotlinQuickF
|
||||
varOrVal = valOrVarNode.text
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Remove 'val/var' from parameter"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.val.var.from.parameter")
|
||||
|
||||
override fun getText(): String {
|
||||
val element = element ?: return ""
|
||||
val varOrVal = element.valOrVarKeyword?.text ?: return familyName
|
||||
return "Remove '$varOrVal' from parameter"
|
||||
return KotlinBundle.message("remove.0.from.parameter", varOrVal)
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -19,11 +19,12 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtWhenEntry
|
||||
|
||||
class RemoveWhenElseBranchFix(element: KtWhenEntry) : KotlinQuickFixAction<KtWhenEntry>(element) {
|
||||
override fun getFamilyName() = "Remove else branch"
|
||||
override fun getFamilyName() = KotlinBundle.message("remove.else.branch")
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.refactoring.RefactoringFactory
|
||||
import com.intellij.refactoring.rename.RenameHandlerRegistry
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
|
||||
open class RenameIdentifierFix : LocalQuickFix {
|
||||
override fun getName() = "Rename"
|
||||
override fun getName() = KotlinBundle.message("rename.identifier.fix.text")
|
||||
override fun getFamilyName() = name
|
||||
|
||||
override fun startInWriteAction(): Boolean = false
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.refactoring.rename.RenameProcessor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
@@ -29,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions.REM_TO_MOD_OPERATION_NAMES
|
||||
|
||||
class RenameModToRemFix(element: KtNamedFunction, val newName: Name) : KotlinQuickFixAction<KtNamedFunction>(element) {
|
||||
override fun getText(): String = "Rename to '$newName'"
|
||||
override fun getText(): String = KotlinBundle.message("rename.to.0", newName)
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.refactoring.rename.RenameProcessor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToParameterDescriptorIfAny
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
@@ -20,9 +21,9 @@ class RenameParameterToMatchOverriddenMethodFix(
|
||||
parameter: KtParameter,
|
||||
private val newName: String
|
||||
) : KotlinQuickFixAction<KtParameter>(parameter) {
|
||||
override fun getFamilyName() = "Rename"
|
||||
override fun getFamilyName() = KotlinBundle.message("rename.identifier.fix.text")
|
||||
|
||||
override fun getText() = "Rename parameter to match overridden method"
|
||||
override fun getText() = KotlinBundle.message("rename.parameter.to.match.overridden.method")
|
||||
|
||||
override fun startInWriteAction(): Boolean = false
|
||||
|
||||
|
||||
@@ -11,11 +11,12 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
class RenameToUnderscoreFix(element: KtCallableDeclaration) : KotlinQuickFixAction<KtCallableDeclaration>(element) {
|
||||
override fun getText() = "Rename to _"
|
||||
override fun getText() = KotlinBundle.message("rename.to.underscore")
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.refactoring.rename.RenameHandlerRegistry
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
@@ -41,7 +42,7 @@ class RenameUnderscoreFix(declaration: KtDeclaration) : KotlinQuickFixAction<KtD
|
||||
return editor != null
|
||||
}
|
||||
|
||||
override fun getText(): String = "Rename"
|
||||
override fun getText(): String = KotlinBundle.message("rename.identifier.fix.text")
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
@@ -74,7 +75,7 @@ class ReplaceImplicitReceiverCallFix(
|
||||
) : KotlinQuickFixAction<KtExpression>(expression) {
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun getText() = "Replace with safe (this?.) call"
|
||||
override fun getText() = KotlinBundle.message("replace.with.safe.this.call")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
@@ -92,7 +93,7 @@ class ReplaceWithSafeCallFix(
|
||||
notNullNeeded: Boolean
|
||||
) : ReplaceCallFix(expression, "?.", notNullNeeded) {
|
||||
|
||||
override fun getText() = "Replace with safe (?.) call"
|
||||
override fun getText() = KotlinBundle.message("replace.with.safe.call")
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
@@ -117,7 +118,7 @@ class ReplaceWithSafeCallForScopeFunctionFix(
|
||||
notNullNeeded: Boolean
|
||||
) : ReplaceCallFix(expression, "?.", notNullNeeded) {
|
||||
|
||||
override fun getText() = "Replace scope function with safe (?.) call"
|
||||
override fun getText() = KotlinBundle.message("replace.scope.function.with.safe.call")
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction<KtExpression>? {
|
||||
@@ -168,7 +169,7 @@ class ReplaceWithSafeCallForScopeFunctionFix(
|
||||
}
|
||||
|
||||
class ReplaceWithDotCallFix(expression: KtSafeQualifiedExpression) : ReplaceCallFix(expression, "."), CleanupFix {
|
||||
override fun getText() = "Replace with dot call"
|
||||
override fun getText() = KotlinBundle.message("replace.with.dot.call")
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
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.resolveToCall
|
||||
import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -25,7 +26,7 @@ class ReplaceInfixOrOperatorCallFix(
|
||||
private val notNullNeeded: Boolean
|
||||
) : KotlinQuickFixAction<KtExpression>(element) {
|
||||
|
||||
override fun getText() = "Replace with safe (?.) call"
|
||||
override fun getText() = KotlinBundle.message("replace.with.safe.call1")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.caches.resolve.resolveToCall
|
||||
import org.jetbrains.kotlin.idea.util.createIntentionForFirstParentOfType
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
@@ -18,7 +19,7 @@ import org.jetbrains.kotlin.resolve.jvm.checkers.JavaAnnotationCallChecker
|
||||
|
||||
class ReplaceJavaAnnotationPositionedArgumentsFix(element: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(element),
|
||||
CleanupFix {
|
||||
override fun getText(): String = "Replace invalid positioned arguments for annotation"
|
||||
override fun getText(): String = KotlinBundle.message("replace.invalid.positioned.arguments.for.annotation")
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -24,7 +25,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
|
||||
class ReplaceJvmFieldWithConstFix(annotation: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(annotation) {
|
||||
override fun getText(): String = "Replace '@JvmField' with 'const'"
|
||||
override fun getText(): String = KotlinBundle.message("replace.jvmfield.with.const")
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -21,11 +22,11 @@ class ReplaceModifierFix(
|
||||
private val replacement: KtModifierKeywordToken
|
||||
) : KotlinQuickFixAction<KtModifierListOwner>(element), CleanupFix {
|
||||
|
||||
private val text = "Replace with '${replacement.value}'"
|
||||
private val text = KotlinBundle.message("replace.with.0", replacement.value)
|
||||
|
||||
override fun getText() = text
|
||||
|
||||
override fun getFamilyName() = "Replace modifier"
|
||||
override fun getFamilyName() = KotlinBundle.message("replace.modifier")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
element?.addModifier(replacement)
|
||||
|
||||
@@ -10,12 +10,13 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
|
||||
class ReplaceObsoleteLabelSyntaxFix(element: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(element), CleanupFix {
|
||||
override fun getFamilyName(): String = "Update obsolete label syntax"
|
||||
override fun getText(): String = element?.let { "Replace with label ${it.calleeExpression?.text ?: ""}@" } ?: ""
|
||||
override fun getFamilyName(): String = KotlinBundle.message("update.obsolete.label.syntax")
|
||||
override fun getText(): String = element?.let { KotlinBundle.message("replace.with.label.0.at", it.calleeExpression?.text ?: "") } ?: ""
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
replaceWithLabel(element ?: return)
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.CAST_NEVER_SUCCEEDS
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS
|
||||
@@ -24,8 +25,8 @@ class ReplacePrimitiveCastWithNumberConversionFix(
|
||||
private val targetShortType: String
|
||||
) : KotlinQuickFixAction<KtBinaryExpressionWithTypeRHS>(element) {
|
||||
|
||||
override fun getText() = "Replace cast with call to 'to$targetShortType()'"
|
||||
override fun getFamilyName() = "Replace cast with primitive conversion method"
|
||||
override fun getText() = KotlinBundle.message("replace.cast.with.call.to.to.0", targetShortType)
|
||||
override fun getFamilyName() = KotlinBundle.message("replace.cast.with.primitive.conversion.method")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -19,12 +19,13 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
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.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class ReplaceWithArrayCallInAnnotationFix(argument: KtExpression) : KotlinQuickFixAction<KtExpression>(argument) {
|
||||
override fun getText() = "Replace with array call"
|
||||
override fun getText() = KotlinBundle.message("replace.with.array.call")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
+4
-3
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
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.name.FqName
|
||||
@@ -59,7 +60,7 @@ object RestrictedRetentionForExpressionAnnotationFactory : KotlinIntentionAction
|
||||
}
|
||||
|
||||
private class AddSourceRetentionFix(element: KtClass) : KotlinQuickFixAction<KtClass>(element) {
|
||||
override fun getText() = "Add SOURCE retention"
|
||||
override fun getText() = KotlinBundle.message("add.source.retention")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
@@ -73,7 +74,7 @@ object RestrictedRetentionForExpressionAnnotationFactory : KotlinIntentionAction
|
||||
private class ChangeRetentionToSourceFix(retentionAnnotation: KtAnnotationEntry) :
|
||||
KotlinQuickFixAction<KtAnnotationEntry>(retentionAnnotation) {
|
||||
|
||||
override fun getText() = "Change existent retention to SOURCE"
|
||||
override fun getText() = KotlinBundle.message("change.existent.retention.to.source")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
@@ -97,7 +98,7 @@ object RestrictedRetentionForExpressionAnnotationFactory : KotlinIntentionAction
|
||||
private class RemoveExpressionTargetFix(expressionTargetArgument: KtValueArgument) :
|
||||
KotlinQuickFixAction<KtValueArgument>(expressionTargetArgument) {
|
||||
|
||||
override fun getText() = "Remove EXPRESSION target"
|
||||
override fun getText() = KotlinBundle.message("remove.expression.target")
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
@@ -40,7 +41,7 @@ class RoundNumberFix(
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) =
|
||||
disableIfAvailable?.isAvailable(project, editor, file) != true && isTarget
|
||||
|
||||
override fun getText() = "Round using $roundFunction()"
|
||||
override fun getText() = KotlinBundle.message("round.using.0", roundFunction)
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters2
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.inspections.ConstantConditionIfInspection
|
||||
import org.jetbrains.kotlin.idea.intentions.SimplifyBooleanWithConstantsIntention
|
||||
@@ -29,9 +30,9 @@ import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
|
||||
class SimplifyComparisonFix(element: KtExpression, val value: Boolean) : KotlinQuickFixAction<KtExpression>(element) {
|
||||
override fun getFamilyName() = "Simplify $element to '$value'"
|
||||
override fun getFamilyName() = KotlinBundle.message("simplify.0.to.1", element.toString(), value)
|
||||
|
||||
override fun getText() = "Simplify comparison"
|
||||
override fun getText() = KotlinBundle.message("simplify.comparison")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
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.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideMemberChooserObject
|
||||
@@ -27,9 +28,9 @@ class SpecifyOverrideExplicitlyFix(
|
||||
element: KtClassOrObject, private val signature: String
|
||||
) : KotlinQuickFixAction<KtClassOrObject>(element) {
|
||||
|
||||
override fun getText() = "Specify override for '$signature' explicitly"
|
||||
override fun getText() = KotlinBundle.message("specify.override.for.0.explicitly", signature)
|
||||
|
||||
override fun getFamilyName() = "Specify override explicitly"
|
||||
override fun getFamilyName() = KotlinBundle.message("specify.override.explicitly")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
@@ -29,7 +30,7 @@ import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.types.isError
|
||||
|
||||
class SpecifyTypeExplicitlyFix : PsiElementBaseIntentionAction() {
|
||||
override fun getFamilyName() = "Specify type explicitly"
|
||||
override fun getFamilyName() = KotlinBundle.message("specify.type.explicitly")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return
|
||||
@@ -43,8 +44,8 @@ class SpecifyTypeExplicitlyFix : PsiElementBaseIntentionAction() {
|
||||
val declaration = declarationByElement(element)
|
||||
if (declaration?.typeReference != null) return false
|
||||
text = when (declaration) {
|
||||
is KtProperty -> "Specify type explicitly"
|
||||
is KtNamedFunction -> "Specify return type explicitly"
|
||||
is KtProperty -> KotlinBundle.message("specify.type.explicitly")
|
||||
is KtNamedFunction -> KotlinBundle.message("specify.return.type.explicitly")
|
||||
else -> return false
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToParameterDescriptorIfAny
|
||||
@@ -99,7 +100,7 @@ object SuperClassNotInitialized : KotlinIntentionActionsFactory() {
|
||||
types.asSequence().take(maxParamsToDisplay).map { DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }
|
||||
.toList()
|
||||
val parameterString = typesRendered.joinToString(", ", "(", if (types.size <= maxParamsToDisplay) ")" else ",...)")
|
||||
val text = "Add constructor parameters from " + superClass.name.asString() + parameterString
|
||||
val text = KotlinBundle.message("add.constructor.parameters.from.0.1", superClass.name.asString(), parameterString)
|
||||
fixes.addIfNotNull(AddParametersFix.create(delegator, classOrObjectDeclaration, constructor, text))
|
||||
}
|
||||
}
|
||||
@@ -114,7 +115,7 @@ object SuperClassNotInitialized : KotlinIntentionActionsFactory() {
|
||||
val putCaretIntoParenthesis: Boolean
|
||||
) : KotlinQuickFixAction<KtSuperTypeEntry>(element), HighPriorityAction {
|
||||
|
||||
override fun getFamilyName() = "Change to constructor invocation" //TODO?
|
||||
override fun getFamilyName() = KotlinBundle.message("change.to.constructor.invocation") //TODO?
|
||||
|
||||
override fun getText() = familyName
|
||||
|
||||
@@ -200,7 +201,7 @@ object SuperClassNotInitialized : KotlinIntentionActionsFactory() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Add constructor parameters from superclass"
|
||||
override fun getFamilyName() = KotlinBundle.message("add.constructor.parameters.from.superclass")
|
||||
|
||||
override fun getText() = text
|
||||
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
|
||||
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.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
@@ -20,7 +21,7 @@ class SurroundWithArrayOfWithSpreadOperatorInFunctionFix(
|
||||
val wrapper: Name,
|
||||
argument: KtExpression
|
||||
) : KotlinQuickFixAction<KtExpression>(argument) {
|
||||
override fun getText() = "Surround with *$wrapper(...)"
|
||||
override fun getText() = KotlinBundle.message("surround.with.star.0", wrapper)
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -23,7 +24,7 @@ class SurroundWithLambdaFix(
|
||||
) : KotlinQuickFixAction<KtExpression>(expression), HighPriorityAction {
|
||||
|
||||
override fun getFamilyName() = text
|
||||
override fun getText() = "Surround with lambda"
|
||||
override fun getText() = KotlinBundle.message("surround.with.lambda")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val nameReference = element ?: return
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
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.branchedTransformations.isStableSimpleExpression
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -41,7 +42,7 @@ class SurroundWithNullCheckFix(
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun getText() = "Surround with null check"
|
||||
override fun getText() = KotlinBundle.message("surround.with.null.check")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -4,6 +4,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.psi.KtConstantExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -11,7 +12,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
class TooLongCharLiteralToStringFix(
|
||||
element: KtConstantExpression
|
||||
) : KotlinQuickFixAction<KtConstantExpression>(element) {
|
||||
override fun getText(): String = "Convert too long character literal to string"
|
||||
override fun getText(): String = KotlinBundle.message("convert.too.long.character.literal.to.string")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -22,7 +23,7 @@ class TypeOfAnnotationMemberFix(
|
||||
typeReference: KtTypeReference,
|
||||
private val fixedType: String
|
||||
) : KotlinQuickFixAction<KtTypeReference>(typeReference), CleanupFix {
|
||||
override fun getText(): String = "Replace array of boxed with array of primitive"
|
||||
override fun getText(): String = KotlinBundle.message("replace.array.of.boxed.with.array.of.primitive")
|
||||
|
||||
override fun getFamilyName(): String = text
|
||||
|
||||
|
||||
@@ -11,12 +11,13 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.MESSAGE_FOR_YIELD_BEFORE_LAMBDA
|
||||
|
||||
class UnsupportedYieldFix(psiElement: PsiElement) : KotlinQuickFixAction<PsiElement>(psiElement), CleanupFix {
|
||||
override fun getFamilyName(): String = "Migrate unsupported yield syntax"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("migrate.unsupported.yield.syntax")
|
||||
override fun getText(): String = familyName
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -14,9 +15,9 @@ import org.jetbrains.kotlin.psi.createExpressionByPattern
|
||||
|
||||
class WrapWithArrayLiteralFix(expression: KtExpression) : KotlinQuickFixAction<KtExpression>(expression) {
|
||||
|
||||
override fun getFamilyName() = "Wrap with array literal"
|
||||
override fun getFamilyName() = KotlinBundle.message("wrap.with.array.literal")
|
||||
|
||||
override fun getText() = "Wrap with []"
|
||||
override fun getText() = KotlinBundle.message("wrap.with")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isNullExpression
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -35,12 +36,12 @@ class WrapWithCollectionLiteralCallFix private constructor(
|
||||
editor?.caretModel?.moveToOffset(replaced.endOffset)
|
||||
}
|
||||
|
||||
override fun getFamilyName(): String = "Wrap with collection literal call"
|
||||
override fun getFamilyName(): String = KotlinBundle.message("wrap.with.collection.literal.call")
|
||||
override fun getText() =
|
||||
if (wrapInitialElement)
|
||||
"Wrap element with '$functionName()' call"
|
||||
KotlinBundle.message("wrap.element.with.0.call", functionName)
|
||||
else
|
||||
"Replace with '$functionName()' call"
|
||||
KotlinBundle.message("replace.with.0.call", functionName)
|
||||
|
||||
companion object {
|
||||
fun create(expectedType: KotlinType, expressionType: KotlinType, element: KtExpression): List<WrapWithCollectionLiteralCallFix> {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
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.resolveToCall
|
||||
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
|
||||
import org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator
|
||||
@@ -40,7 +41,7 @@ class WrapWithSafeLetCallFix(
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun getText() = "Wrap with '?.let { ... }' call"
|
||||
override fun getText() = KotlinBundle.message("wrap.with.let.call")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.psi.KtConstantExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -17,8 +18,8 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
class WrongLongSuffixFix(element: KtConstantExpression) : KotlinQuickFixAction<KtConstantExpression>(element) {
|
||||
private val corrected = element.text.trimEnd('l') + 'L'
|
||||
|
||||
override fun getText() = "Change to '$corrected'"
|
||||
override fun getFamilyName() = "Change to correct long suffix 'L'"
|
||||
override fun getText() = KotlinBundle.message("change.to.0", corrected)
|
||||
override fun getFamilyName() = KotlinBundle.message("change.to.correct.long.suffix.l")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
element?.replace(KtPsiFactory(project).createExpression(corrected))
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
@@ -82,8 +83,8 @@ class WrongPrimitiveLiteralFix(element: KtConstantExpression, type: KotlinType)
|
||||
return constValue.toLong() in valueRanges[typeName] ?: return false
|
||||
}
|
||||
|
||||
override fun getFamilyName() = "Change to correct primitive type"
|
||||
override fun getText() = "Change to '$fixedExpression'"
|
||||
override fun getFamilyName() = KotlinBundle.message("change.to.correct.primitive.type")
|
||||
override fun getText() = KotlinBundle.message("change.to.0", fixedExpression)
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
|
||||
Reference in New Issue
Block a user