i18n: add bundle for idea/inspections

This commit is contained in:
Dmitry Gridin
2020-03-04 15:28:43 +07:00
parent 76ac4ffb96
commit 0a3e577b6c
138 changed files with 769 additions and 315 deletions
@@ -942,7 +942,7 @@ text.move.declarations=Move declarations
text.move.file.0=Move {0}
text.move.refactoring.not.available.during.indexing=Move refactoring is not available while indexing is in progress
text.moving.multiple.nested.classes.to.top.level.not.supported=Moving multiple nested classes to top-level is not supported
text.name=Name
text.Name=Name
text.nested.classes.to.upper.level=Nested Classes to Upper Level
text.no.elements.to.move.are.selected=No elements to move are selected
text.no.files.to.move=There is no given files to move
@@ -1309,4 +1309,293 @@ replace.substring.call.with.droplast.call=Replace 'substring' call with 'dropLas
replace.substring.call.with.indexing.operation.call=Replace 'substring' call with indexing operation call
replace.substring.call.with.substringbefore.call=Replace 'substring' call with 'substringBefore' call
replace.substring.call.with.substringafter.call=Replace 'substring' call with 'substringAfter' call
replace.substring.call.with.take.call=Replace 'substring' call with 'take' call
replace.substring.call.with.take.call=Replace 'substring' call with 'take' call
add.operator.modifier=Add 'operator' modifier
function.should.have.operator.modifier=Function should have 'operator' modifier
type.parameter.can.have.0.variance=Type parameter can have {0} variance
add.variance.fix.text=Add ''{0}'' variance
add.variance.fix.family.name=Add variance
generate.equals.and.hashcode.fix.text=Generate equals() and hashCode()
array.property.in.data.class.it.s.recommended.to.override.equals.hashcode=Array property in data class: it's recommended to override equals() / hashCode()
report.also.on.call.with.single.boolean.literal.argument=Report also on call with single boolean literal argument
boolean.literal.argument.without.parameter.name=Boolean literal argument without parameter name
constructor.parameter.is.never.used.as.a.property=Constructor parameter is never used as a property
property.is.explicitly.assigned.to.parameter.0.can=Property is explicitly assigned to parameter {0}, can be declared directly in constructor
variable.is.never.modified.and.can.be.declared.immutable.using.val=Variable is never modified and can be declared immutable using 'val'
sealed.sub.class.has.no.state.and.no.overridden.equals=Sealed sub-class has no state and no overridden equals
cascade.if.should.be.replaced.with.when=Cascade if should be replaced with when
mark.as.deprecated.level.deprecationlevel.hidden=Mark as @Deprecated(..., level = DeprecationLevel.HIDDEN)
searching.for.imports.to.delete=Searching for imports to delete
delete.redundant.extension.property=Delete redundant extension property
this.property.conflicts.with.synthetic.extension.and.should.be.removed.or.renamed.to.avoid.breaking.code.by.future.changes.in.the.compiler=This property conflicts with synthetic extension and should be removed or renamed to avoid breaking code by future changes in the compiler
condition.is.always.0=Condition is always ''{0}''
remove.fix.text=Delete expression
simplify.fix.text=Simplify expression
0.has.empty.body=''{0}'' has empty body
convert.na.n.equality.quick.fix.text=Replace with 'isNaN()'
equality.check.with.nan.should.be.replaced.with.isnan=Equality check with NaN should be replaced with 'isNaN()'
convert.pair.constructor.to.to.fix.text=Convert to 'to'
can.be.converted.to.to=Can be converted to 'to'
convert.to.a.range.check=Convert to a range check
two.comparisons.should.be.converted.to.a.range.check=Two comparisons should be converted to a range check
copy.method.of.data.class.is.called.without.named.arguments='copy' method of data class is called without named arguments
private.data.class.constructor.is.exposed.via.the.generated.copy.method=Private data class constructor is exposed via the generated 'copy' method.
remove.var.keyword.text=Remove var
delegating.to.var.property.does.not.take.its.changes.into.account=Delegating to 'var' property does not take its changes into account
add.replacewith.argument.to.specify.replacement.pattern=Add 'replaceWith' argument to specify replacement pattern
deprecated.annotation.without.replacewith.argument=@Deprecated annotation without 'replaceWith' argument
variable.name.0.matches.the.name.of.a.different.component=Variable name ''{0}'' matches the name of a different component
replace.with.down.to.fix.text=Replace with 'downTo'
this.range.is.empty.did.you.mean.to.use.downto=This range is empty. Did you mean to use 'downTo'?
equals.hashcode.in.object.declaration=equals()/hashCode() in object declaration
hash.code.text=Generate 'hashCode()'
equals.text=Generate 'equals()'
delete.equals.and.hash.code.fix.text=Delete equals()/hashCode()
redundant.explicit.this=Redundant explicit this
explicit.this.expression.fix.family.name=Remove redundant ''{0}''
use.of.non.const.kotlin.property.as.java.constant.is.incorrect.will.be.forbidden.in.1.4=Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4
replace.if.with.elvis.operator=Replace 'if' with elvis operator
if.null.return.break.foldable.to=If-Null return/break/... foldable to '?:'
loop.parameter.0.is.unused=Loop parameter ''{0}'' is unused
replace.with.repeat.fix.family.name=Replace with 'repeat()'
introduce.anonymous.parameter.fix.family.name=Introduce anonymous parameter
wrap.run.fix.text=Convert to run { ... }
remove.braces.fix.text=Remove braces
function.with.and.inferred.return.type=Function with `= { ... }` and inferred return type
report.for.types.with.platform.arguments=Report for types with platform arguments
apply.only.to.public.or.protected.members=Apply only to public or protected members
declaration.has.type.inferred.from.a.platform.call.which.can.lead.to.unchecked.nullability.issues=Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
callable.reference.fix.family.name=Add explicit ''{0}''
java.collections.static.method.call.should.be.replaced.with.kotlin.stdlib=Java Collections static method call should be replaced with Kotlin stdlib
replace.with.std.lib.fix.text=Replace with {0}.{1}
call.of.java.mutator.0.on.immutable.kotlin.collection.1=Call of Java mutator ''{0}'' on immutable Kotlin collection ''{1}''
replace.with.kotlin.s.foreach=Replace with Kotlin's forEach
java.map.foreach.method.call.should.be.replaced.with.kotlin.s.foreach=Java Map.forEach method call should be replaced with Kotlin's forEach
remove.deprecated.symbol.import=Remove deprecated symbol import
usage.of.redundant.or.deprecated.syntax.or.deprecated.symbols=Usage of redundant or deprecated syntax or deprecated symbols
equals.should.take.any.as.its.argument='equals' should take 'Any?' as its argument
double.negation.fix.text=Remove redundant negations
redundant.double.negation=Redundant double negation
equals.between.objects.of.inconvertible.types='equals()' between objects of inconvertible types
usage.of.kotlin.internal.declaration.from.different.module=Usage of Kotlin internal declaration from different module
junit.static.methods=JUnit static methods
redundant.override.fix.text=Remove redundant overriding method
redundant.overriding.method=Redundant overriding method
throwable.instance.0.is.not.thrown=Throwable instance ''{0}'' is not thrown
result.of.0.call.is.not.thrown=Result of ''{0}'' call is not thrown
optimize.imports=Optimize imports
unused.import.directive=Unused import directive
lateinit.var.overrides.lateinit.var=lateinit var overrides lateinit var
leaking.this.in.constructor.of.non.final.class.0=Leaking 'this' in constructor of non-final class {0}
leaking.this.in.constructor.of.enum.class.0.with.overridable.members=Leaking 'this' in constructor of enum class {0} (with overridable members)
accessing.non.final.property.0.in.constructor=Accessing non-final property {0} in constructor
calling.non.final.function.0.in.constructor=Calling non-final function {0} in constructor
text.can=can
text.should=should
text.Assignment=Assignment
text.Return=Return
text.return=return
0.1.be.lifted.out.of.2={0} {1} be lifted out of ''{2}''
lift.assignment.out.fix.text.0=Lift assignment out of ''{0}''
lift.return.out.fix.text.0=Lift return out of '
change.main.function.return.type.to.unit.fix.text=Add explicit Unit return type
change.main.function.return.type.to.unit.fix.text2=Change return type to Unit
0.should.return.unit={0} should return Unit
junit.test=JUnit test
map.get.with.not.null.assertion.operator=map.get() with not-null assertion operator (!!)
replace.with.get.or.else.fix.text=Replace with 'getOrElse' call
replace.with.get.value.call.fix.text=Replace with 'getValue' call
replace.with.elvis.error.fix.text=Replace with '?: error("")'
might.be.const=Might be 'const'
const.might.be.used.instead.of.jvmfield='const' might be used instead of '@JvmField'
text.Function=Function
text.Property=Property
0.1.could.be.private={0} ''{1}'' could be private
diagnostic.name.should.be.replaced.by.the.new.one=Diagnostic name should be replaced by the new one
replace.diagnostic.name.fix.text={0} with {1}
replace.diagnostic.name.fix.family.name=Replace diagnostic name
lambda.argument.0.be.moved.out=Lambda argument {0} be moved out of parentheses
move.lambda.argument.out.of.parentheses=Move lambda argument out of parentheses
suspicious.callable.reference.as.the.only.lambda.element=Suspicious callable reference as the only lambda element
inline.variable=Inline variable
move.variable.declaration.into.when=Move variable declaration into `when`
nothing.to.do=Nothing to do
variable.declaration.could.be.inlined=Variable declaration could be inlined
variable.declaration.could.be.moved.into.when=Variable declaration could be moved into `when`
may.contain.only.letters.digits.or.underscores=may contain only letters, digits or underscores
may.contain.only.letters.and.digits=may contain only letters and digits
should.not.contain.underscores.in.the.middle.or.the.end=should not contain underscores in the middle or the end
should.not.start.with.an.underscore=should not start with an underscore
should.not.start.with.an.uppercase.letter=should not start with an uppercase letter
should.not.contain.underscores=should not contain underscores
should.start.with.a.lowercase.letter=should start with a lowercase letter
should.start.with.an.uppercase.letter=should start with an uppercase letter
doesn.t.match.regex.0=doesn't match regex ''{0}''
text.pattern=Pattern:
package.name=Package name
text.part=part
text.name=name
text.Package=Package
add.explicit.parameter.to.outer.lambda.fix.text=Add explicit parameter name to outer lambda
implicit.parameter.it.of.enclosing.lambda.is.shadowed=Implicit parameter 'it' of enclosing lambda is shadowed
equality.cehck.0.be.used.instead.of.elvis.for.nullable.boolean.check=Equality check {0} be used instead of elvis for nullable boolean check
replace.with.equality.check.fix.text=Replace with equality check
null.checks.to.safe.call.check.fix.text=Replace chained null-checks with safe-calls
null.checks.replaceable.with.safe.calls=Null-checks replaceable with safe-calls
optionally.expected.annotation.has.no.actual.annotation.in.module.0.for.platform.1=Optionally expected annotation has no actual annotation in module {0} for platform {1}
call.of.inline.function.with.nullable.extension.receiver.can.provoke.npe.in.kotlin.1.2=Call of inline function with nullable extension receiver can provoke NPE in Kotlin 1.2+
make.open.fix.text=Make class open
make.private.fix.text=Make private
protected.visibility.is.effectively.private.in.a.final.class='protected' visibility is effectively 'private' in a final class
apply.also.to.private.members=Apply also to private members
apply.also.to.internal.members=Apply also to internal members
for.api.stability.it.s.recommended.to.specify.explicitly.declaration.types=For API stability, it's recommended to specify explicitly declaration types
for.api.stability.it.s.recommended.to.specify.explicitly.public.protected.declaration.types=For API stability, it's recommended to specify explicitly public & protected declaration types
recursive.equals.call=Recursive equals call
replace.with.field.fix.text=Replace with 'field'
recursive.synthetic.property.accessor=Recursive synthetic property accessor
recursive.property.accessor=Recursive property accessor
remove.redundant.companion.reference.fix.text=Remove redundant Companion reference
redundant.companion.reference=Redundant Companion reference
remove.redundant.else.fix.text=Remove redundant 'else'
redundant.else=Redundant 'else'
remove.initializer.block.fix.text=Remove initializer block
redundant.empty.initializer.block=Redundant empty initializer block
remove.enum.constructor.invocation.fix.text=Remove enum constructor invocation
redundant.enum.constructor.invocation=Redundant enum constructor invocation
explicitly.given.type.is.redundant.here=Explicitly given type is redundant here
remove.redundant.getter.fix.text=Remove redundant getter
redundant.getter=Redundant getter
remove.redundant.if.text=Remove redundant 'if' statement
redundant.if.statement=Redundant 'if' statement
delete.fix.family.name=Remove arrow
redundant.lambda.arrow=Redundant lambda arrow
remove.let.call=Remove `let` call
redundant.let.call.could.be.removed=Redundant `let` call could be removed
redundant.modality.modifier=Redundant modality modifier
this.type.probably.can.be.changed.to.nullable=This type probably can be changed to nullable
redundant.type.checks.for.object=Redundant type checks for object
replace.with.equality.fix.text=Replace ''{0}'' with ''{1}''
redundant.0.call=Redundant ''{0}'' call
remove.require.not.null.call.fix.text=Remove ''{0}'' call
remove.return.label.fix.text=Remove redundant ''@{0}''
remove.return.label.fix.family=Remove redundant label
redundant.0=Redundant ''@{0}''
remove.redundant.sam.constructors=Remove redundant SAM-constructors
remove.redundant.sam.constructor=Remove redundant SAM-constructor
redundant.sam.constructors=Redundant SAM-constructors
redundant.sam.constructor=Redundant SAM-constructor
fix.text=Remove redundant semicolon
redundant.semicolon=Redundant semicolon
remove.redundant.setter.fix.text=Remove redundant setter
redundant.setter=Redundant setter
redundant.suspend.modifier=Redundant 'suspend' modifier
redundant.unit.return.type=Redundant 'Unit' return type
redundant.visibility.modifier=Redundant visibility modifier
remove.redundant.unit.fix.text=Remove redundant 'Unit'
redundant.unit=Redundant 'Unit'
remove.redundant.with.fix.text=Remove redundant 'with' call
redundant.with.call=Redundant 'with' call
reformat.quick.fix.family.name=Reformat File
apply.only.to.modified.files.for.projects.under.a.version.control=Apply only to modified files (for projects under a version control)
file.is.not.properly.formatted=File is not properly formatted
remove.jvmoverloads.annotation=Remove @JvmOverloads annotation
report.also.for.a.variables.without.a.whitespace.around=Report also for a variables without a whitespace around
remove.curly.braces=Remove curly braces
redundant.curly.braces.in.string.template=Redundant curly braces in string template
remove.empty.parentheses.from.annotation.entry.fix.text=Remove unnecessary parentheses
parentheses.should.be.removed=Parentheses should be removed
remove.redundant.qualifier.name.quick.fix.text=Remove redundant qualifier name
redundant.qualifier.name=Redundant qualifier name
remove.redundant.backticks.quick.fix.text=Remove redundant backticks
remove.redundant.spread.operator.quickfix.text=Remove redundant spread operator
remove.to.string.fix.text=Remove 'toString()' call
redundant.tostring.call.in.string.template=Redundant 'toString()' call in string template
redundant.setter.parameter.type=Redundant setter parameter type
replace.with.contentequals=Replace '!=' with 'contentEquals'
replace.with.contentequals2=Replace '==' with 'contentEquals'
replace.with.contentequals3=Replace with 'contentEquals'
dangerous.array.comparison=Dangerous array comparison
replace.with.array.literal.fix.family.name=Replace with [...]
0.call.should.be.replaced.with.array.literal=''{0}'' call should be replaced with array literal [...]
replace.assert.boolean.with.assert.equality=Replace assert boolean with assert equality
replace.0.with.1=Replace ''{0}'' with ''{1}''
replace.collection.count.with.size.quick.fix.text=Replace 'count' with 'size'
could.be.replaced.with.size=Could be replaced with `size`
replace.with.kotlin.s.function.call=Replace with kotlin's function call
replace.guard.clause.with.kotlin.s.function.call=Replace guard clause with kotlin's function call
replace.index.loop.with.collection.loop.quick.fix.text=Replace with loop over elements
replace.manual.range.with.indices.call.quick.fix.text=Replace with indices
range.could.be.replaced.with.indices.call=Range could be replaced with '.indices' call
for.loop.over.indices.could.be.replaced.with.loop.over.elements=For loop over indices could be replaced with loop over elements
replace.negated.0.with.1=Replace negated ''{0}'' with ''{1}''
replace.with.elvis.return.fix.text=Replace with ''?: return{0}''
replace.with.return=Replace '!!' with '?: return'
convert.put.to.assignment=Convert put to assignment
map.put.should.be.converted.to.assignment=map.put() should be converted to assignment
replace.int.range.end.inclusive.with.last.quick.fix.text=Replace 'endInclusive' with 'last'
replace.int.range.start.with.first.quick.fix.text=Replace 'start' with 'first'
could.be.replaced.with.unboxed.last=Could be replaced with unboxed `last`
could.be.replaced.with.unboxed.first=Could be replaced with unboxed `first`
replace.with.until.quick.fix.text=Replace with until
rangeto.or.the.call.should.be.replaced.with.until='rangeTo' or the '..' call should be replaced with 'until'
replace.with.string.literal.fix.family.name=Replace with string templates
string.format.call.can.be.replaced.with.string.templates=String.format call can be replaced with string templates
replace.tostring.with.string.template=Replace 'toString' with string template
call.of.tostring.could.be.replaced.with.string.template=Call of 'toString' could be replaced with string template
replace.to.with.infix.form.quickfix.text=Replace 'to' with infix form
replace.with.enum.map.fix.text=Replace with EnumMap
replaceable.with.enummap=Replaceable with EnumMap
replace.with.operator.assignment=Replace with operator-assignment
replaceable.with.operator.assignment=Replaceable with operator-assignment
replace.with.0.eq=Replace with ''{0}=''
replace.with.if.fix.text=Replace with 'if' type check
should.be.replaced.with.if.type.check=Should be replaced with 'if' type check
call.is.replaceable.with.another.scope.function=Call is replaceable with another scope function
convert.scope.function.fix.family.name=Convert to ''{0}''
variable.0.is.assigned.to.itself=Variable ''{0}'' is assigned to itself
remove.self.assignment.fix.text=Remove self assignment
convert.to.nullable.type.fix.text=Convert to nullable type
constructor.has.non.null.self.reference.parameter=Constructor has non-null self reference parameter
assign.backing.field.fix.text=Assign backing field
existing.backing.field.is.not.assigned.by.the.setter=Existing backing field is not assigned by the setter
replace.with.error=Replace with '?: error(...)'
replace.with.operator=Replace with '!!' operator
replace.assert.with.operator=Replace assert with operator
assert.should.be.replaced.with.operator=assert should be replaced with operator
simplify.negated.operation=Simplify negated operation
negated.operation.should.be.simplified=Negated operation should be simplified
replace.negated.0.operation.with.1=Replace negated ''{0}'' operation with ''{1}''
simplify.when.fix.text=Simplify 'when'
this.when.is.simplifiable=This 'when' is simplifiable
sort.modifiers=Sort modifiers
non.canonical.modifiers.order=Non-canonical modifiers order
modifiers.should.follow.annotations=Modifiers should follow annotations
remove.as.dynamic.call.fix.text=Remove 'asDynamic' invocation
suspicious.asdynamic.member.invocation=Suspicious 'asDynamic' member invocation
0.creates.new.1.under.the.hood=''{0}'' creates new {1} under the hood
replace.with.filter.fix.text=Replace with filter
change.type.to.mutable.fix.text=Change type to mutable
replace.with.assignment.fix.text=Replace with assignment (original is empty)
join.with.initializer.fix.text=Join with initializer
suspicious.combination.of.and=Suspicious combination of == and ===
unlabeled.return.inside.lambda=Unlabeled return inside lambda
suspicious.var.property.its.setter.does.not.influence.its.getter.result=Suspicious 'var' property: its setter does not influence its getter result
variable.used.only.in.following.return.and.should.be.inlined=Variable used only in following return and should be inlined
variable.is.same.as.0.and.should.be.inlined=Variable is same as ''{0}'' and should be inlined
implicit.unsafe.cast.from.dynamic.to.0=Implicit (unsafe) cast from dynamic to {0}
cast.explicitly.fix.text=Cast explicitly
unused.equals.expression=Unused equals expression
since.kotlin.1.3.main.parameter.is.not.necessary=Since Kotlin 1.3 main parameter is not necessary
remove.token.from.function.declaration=Remove '=' token from function declaration
unused.return.value.of.a.function.with.lambda.expression.body=Unused return value of a function with lambda expression body
safe.delete.constructor=Safe delete constructor
remove.unary.operator.fix.text=Remove unused unary operator
unused.unary.operator=Unused unary operator
one.line.return=one-line return
return.when='return when'
block.body=block body
use.expression.body.instead.of.0=Use expression body instead of {0}
convert.to.expression.body.fix.text=Convert to expression body
when.has.only.else.branch.and.should.be.simplified='when' has only 'else' branch and should be simplified
wrap.unary.operator.quickfix.text=Wrap unary operator and value with ()
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
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.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.refactoring.withExpectedActuals
import org.jetbrains.kotlin.idea.util.application.runWriteAction
@@ -18,9 +19,9 @@ import org.jetbrains.kotlin.util.OperatorChecks
class AddOperatorModifierInspection : AbstractApplicabilityBasedInspection<KtNamedFunction>(KtNamedFunction::class.java) {
override fun inspectionHighlightRangeInElement(element: KtNamedFunction) = element.nameIdentifierTextRangeInThis()
override fun inspectionText(element: KtNamedFunction) = "Function should have 'operator' modifier"
override fun inspectionText(element: KtNamedFunction) = KotlinBundle.message("function.should.have.operator.modifier")
override val defaultFixText = "Add 'operator' modifier"
override val defaultFixText = KotlinBundle.message("add.operator.modifier")
override fun isApplicable(element: KtNamedFunction): Boolean {
if (element.nameIdentifier == null || element.hasModifier(KtTokens.OPERATOR_KEYWORD)) return false
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.MemberDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -64,7 +65,7 @@ class AddVarianceModifierInspection : AbstractKotlinInspection() {
val fixes = variances.map(::AddVarianceFix)
holder.registerProblem(
typeParameter,
"Type parameter can have $suggested variance",
KotlinBundle.message("type.parameter.can.have.0.variance", suggested),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
*fixes.toTypedArray()
)
@@ -86,9 +87,9 @@ class AddVarianceModifierInspection : AbstractKotlinInspection() {
class AddVarianceFix(val variance: Variance) : LocalQuickFix {
override fun getName() = "Add '$variance' variance"
override fun getName() = KotlinBundle.message("add.variance.fix.text", variance)
override fun getFamilyName() = "Add variance"
override fun getFamilyName() = KotlinBundle.message("add.variance.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
if (!FileModificationService.getInstance().preparePsiElementForWrite(descriptor.psiElement)) return
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateEqualsAndHashcodeAction
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -36,7 +37,7 @@ class ArrayInDataClassInspection : AbstractKotlinInspection() {
if (KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) {
holder.registerProblem(
parameter,
"Array property in data class: it's recommended to override equals() / hashCode()",
KotlinBundle.message("array.property.in.data.class.it.s.recommended.to.override.equals.hashcode"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
GenerateEqualsAndHashcodeFix()
)
@@ -65,7 +66,7 @@ class ArrayInDataClassInspection : AbstractKotlinInspection() {
}
class GenerateEqualsAndHashcodeFix : LocalQuickFix {
override fun getName() = "Generate equals() and hashCode()"
override fun getName() = KotlinBundle.message("generate.equals.and.hashcode.fix.text")
override fun getFamilyName() = name
@@ -12,6 +12,7 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.intentions.AddNameToArgumentIntention
@@ -69,14 +70,14 @@ class BooleanLiteralArgumentInspection(
IntentionWrapper(AddNameToArgumentIntention(), argument.containingKtFile)
}
holder.registerProblemWithoutOfflineInformation(
argument, "Boolean literal argument without parameter name",
argument, KotlinBundle.message("boolean.literal.argument.without.parameter.name"),
isOnTheFly, highlightType, fix
)
})
override fun createOptionsPanel(): JComponent? {
val panel = MultipleCheckboxOptionsPanel(this)
panel.addCheckbox("Report also on call with single boolean literal argument", "reportSingle")
panel.addCheckbox(KotlinBundle.message("report.also.on.call.with.single.boolean.literal.argument"), "reportSingle")
return panel
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.search.PsiSearchHelper.SearchCostResult.FEW_OCCURRENCES
import com.intellij.psi.search.PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.quickfix.RemoveValVarFromParameterFix
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
import org.jetbrains.kotlin.idea.search.isCheapEnoughToSearchConsideringOperators
@@ -102,7 +103,7 @@ class CanBeParameterInspection : AbstractKotlinInspection() {
if (references.any { it.element.parent is KtCallableReferenceExpression || it.usedAsPropertyIn(klass) }) return
holder.registerProblem(
valOrVar,
"Constructor parameter is never used as a property",
KotlinBundle.message("constructor.parameter.is.never.used.as.a.property"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveValVarFix(parameter)
)
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.intentions.MovePropertyToConstructorIntention
import org.jetbrains.kotlin.idea.intentions.loopToCallChain.hasUsages
@@ -56,7 +57,7 @@ class CanBePrimaryConstructorPropertyInspection : AbstractKotlinInspection() {
holder.manager.createProblemDescriptor(
nameIdentifier,
nameIdentifier,
"Property is explicitly assigned to parameter ${assignedDescriptor.name}, can be declared directly in constructor",
KotlinBundle.message("property.is.explicitly.assigned.to.parameter.0.can", assignedDescriptor.name),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly,
MovePropertyToConstructorIntention()
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.AccessTarget
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.WriteValueInstruction
import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDeclarationInstruction
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.quickfix.ChangeVariableMutabilityFix
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
@@ -56,7 +57,7 @@ class CanBeValInspection : AbstractKotlinInspection() {
val problemDescriptor = holder.manager.createProblemDescriptor(
keyword,
keyword,
"Variable is never modified and can be declared immutable using 'val'",
KotlinBundle.message("variable.is.never.modified.and.can.be.declared.immutable.using.val"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly,
IntentionWrapper(ChangeVariableMutabilityFix(declaration, false), declaration.containingFile)
@@ -20,6 +20,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.asJava.classes.KtLightClassImpl
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.getModalityFromDescriptor
import org.jetbrains.kotlin.idea.quickfix.sealedSubClassToObject.ConvertSealedSubClassToObjectFix
@@ -59,7 +60,7 @@ class CanSealedSubClassBeObjectInspection : AbstractKotlinInspection() {
val keyword = klass.getClassOrInterfaceKeyword() ?: return
holder.registerProblem(
keyword,
"Sealed sub-class has no state and no overridden equals",
KotlinBundle.message("sealed.sub.class.has.no.state.and.no.overridden.equals"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ConvertSealedSubClassToObjectFix(),
GenerateIdentityEqualsFix()
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.IntentionWrapper
import com.intellij.codeInspection.LocalInspectionToolSession
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfToWhenIntention
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isElseIf
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isOneLiner
@@ -52,7 +53,7 @@ class CascadeIfInspection : AbstractKotlinInspection() {
holder.registerProblem(
expression.ifKeyword,
"Cascade if should be replaced with when",
KotlinBundle.message("cascade.if.should.be.replaced.with.when"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
IntentionWrapper(IfToWhenIntention(), expression.containingKtFile)
)
@@ -24,6 +24,7 @@ import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.ui.GuiUtils
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -69,7 +70,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() {
val problemDescriptor = holder.manager.createProblemDescriptor(
nameElement,
"This property conflicts with synthetic extension and should be removed or renamed to avoid breaking code by future changes in the compiler",
KotlinBundle.message("this.property.conflicts.with.synthetic.extension.and.should.be.removed.or.renamed.to.avoid.breaking.code.by.future.changes.in.the.compiler"),
true,
fixes,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
@@ -177,7 +178,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() {
private class DeleteRedundantExtensionAction(property: KtProperty) : KotlinQuickFixAction<KtProperty>(property) {
private val LOG = Logger.getInstance(DeleteRedundantExtensionAction::class.java)
override fun getFamilyName() = "Delete redundant extension property"
override fun getFamilyName() = KotlinBundle.message("delete.redundant.extension.property")
override fun getText() = familyName
override fun startInWriteAction() = false
@@ -187,7 +188,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() {
val fqName = declaration.unsafeResolveToDescriptor(BodyResolveMode.PARTIAL).importableFqName
if (fqName != null) {
ProgressManager.getInstance().run(
object : Task.Modal(project, "Searching for imports to delete", true) {
object : Task.Modal(project, KotlinBundle.message("searching.for.imports.to.delete"), true) {
override fun run(indicator: ProgressIndicator) {
val importsToDelete = runReadAction {
val searchScope = KotlinSourceFilterScope.projectSources(GlobalSearchScope.projectScope(project), project)
@@ -220,7 +221,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() {
}
private class MarkHiddenAndDeprecatedAction(property: KtProperty) : KotlinQuickFixAction<KtProperty>(property) {
override fun getFamilyName() = "Mark as @Deprecated(..., level = DeprecationLevel.HIDDEN)"
override fun getFamilyName() = KotlinBundle.message("mark.as.deprecated.level.deprecationlevel.hidden")
override fun getText() = familyName
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -12,6 +12,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.search.LocalSearchScope
import com.intellij.psi.search.searches.ReferencesSearch
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.intentions.branchedTransformations.isElseIf
@@ -38,7 +39,7 @@ class ConstantConditionIfInspection : AbstractKotlinInspection() {
val fixes = collectFixes(expression, constantValue)
holder.registerProblem(
expression.condition!!,
"Condition is always '$constantValue'",
KotlinBundle.message("condition.is.always.0", constantValue),
*fixes.toTypedArray()
)
}
@@ -89,7 +90,7 @@ class ConstantConditionIfInspection : AbstractKotlinInspection() {
) : ConstantConditionIfFix {
override fun getFamilyName() = name
override fun getName() = "Simplify expression"
override fun getName() = KotlinBundle.message("simplify.fix.text")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val ifExpression = descriptor.psiElement.getParentOfType<KtIfExpression>(strict = true) ?: return
@@ -107,7 +108,7 @@ class ConstantConditionIfInspection : AbstractKotlinInspection() {
private class RemoveFix : ConstantConditionIfFix {
override fun getFamilyName() = name
override fun getName() = "Delete expression"
override fun getName() = KotlinBundle.message("remove.fix.text")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val ifExpression = descriptor.psiElement.getParentOfType<KtIfExpression>(strict = true) ?: return
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
import org.jetbrains.kotlin.idea.util.hasComments
import org.jetbrains.kotlin.lexer.KtTokens
@@ -76,7 +77,7 @@ class ControlFlowWithEmptyBodyInspection : AbstractKotlinInspection() {
registerProblem(
expression,
keyword.textRange.shiftLeft(expression.startOffset),
"'$keywordText' has empty body"
KotlinBundle.message("0.has.empty.body", keywordText)
)
}
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -27,7 +28,7 @@ class ConvertNaNEqualityInspection : AbstractKotlinInspection() {
}
holder.registerProblem(
expression,
"Equality check with NaN should be replaced with 'isNaN()'",
KotlinBundle.message("equality.check.with.nan.should.be.replaced.with.isnan"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ConvertNaNEqualityQuickFix(inverted)
)
@@ -37,7 +38,7 @@ class ConvertNaNEqualityInspection : AbstractKotlinInspection() {
}
private class ConvertNaNEqualityQuickFix(val inverted: Boolean) : LocalQuickFix {
override fun getName() = "Replace with 'isNaN()'"
override fun getName() = KotlinBundle.message("convert.na.n.equality.quick.fix.text")
override fun getFamilyName() = name
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.getCallableDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtCallExpression
@@ -25,7 +26,7 @@ class ConvertPairConstructorToToFunctionInspection : AbstractKotlinInspection()
if (expression.isPairConstructorCall()) {
holder.registerProblem(
expression,
"Can be converted to 'to'",
KotlinBundle.message("can.be.converted.to.to"),
ProblemHighlightType.INFORMATION,
ConvertPairConstructorToToFix()
)
@@ -35,7 +36,7 @@ class ConvertPairConstructorToToFunctionInspection : AbstractKotlinInspection()
}
private class ConvertPairConstructorToToFix : LocalQuickFix {
override fun getName() = "Convert to 'to'"
override fun getName() = KotlinBundle.message("convert.pair.constructor.to.to.fix.text")
override fun getFamilyName() = name
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.evaluatesTo
import org.jetbrains.kotlin.lexer.KtTokens
@@ -23,9 +24,9 @@ import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType
class ConvertTwoComparisonsToRangeCheckInspection :
AbstractApplicabilityBasedInspection<KtBinaryExpression>(KtBinaryExpression::class.java) {
override fun inspectionText(element: KtBinaryExpression) = "Two comparisons should be converted to a range check"
override fun inspectionText(element: KtBinaryExpression) = KotlinBundle.message("two.comparisons.should.be.converted.to.a.range.check")
override val defaultFixText = "Convert to a range check"
override val defaultFixText = KotlinBundle.message("convert.to.a.range.check")
override fun isApplicable(element: KtBinaryExpression) = generateRangeExpressionData(element) != null
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.intentions.AddNamesToCallArgumentsIntention
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
@@ -37,7 +38,7 @@ class CopyWithoutNamedArgumentsInspection : AbstractKotlinInspection() {
holder.registerProblem(
expression.calleeExpression ?: return,
"'copy' method of data class is called without named arguments",
KotlinBundle.message("copy.method.of.data.class.is.called.without.named.arguments"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
IntentionWrapper(AddNamesToCallArgumentsIntention(), expression.containingKtFile)
)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.primaryConstructorVisitor
import org.jetbrains.kotlin.psi.psiUtil.containingClass
@@ -21,7 +22,7 @@ class DataClassPrivateConstructorInspection : AbstractKotlinInspection() {
val problemDescriptor = holder.manager.createProblemDescriptor(
keyword,
keyword,
"Private data class constructor is exposed via the generated 'copy' method.",
KotlinBundle.message("private.data.class.constructor.is.exposed.via.the.generated.copy.method"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly
)
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.quickfix.ChangeVariableMutabilityFix
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.lexer.KtTokens
@@ -20,7 +21,7 @@ class DelegationToVarPropertyInspection : AbstractKotlinInspection() {
if (parameter.valOrVarKeyword?.node?.elementType != KtTokens.VAR_KEYWORD) return
holder.registerProblem(
parameter,
"Delegating to 'var' property does not take its changes into account",
KotlinBundle.message("delegating.to.var.property.does.not.take.its.changes.into.account"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
IntentionWrapper(ChangeVariableMutabilityFix(parameter, false), parameter.containingFile),
RemoveVarKeyword()
@@ -29,7 +30,7 @@ class DelegationToVarPropertyInspection : AbstractKotlinInspection() {
}
private class RemoveVarKeyword : LocalQuickFix {
override fun getName() = "Remove var"
override fun getName() = KotlinBundle.message("remove.var.keyword.text")
override fun getFamilyName() = name
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -37,13 +38,13 @@ import java.util.*
class DeprecatedCallableAddReplaceWithInspection : AbstractApplicabilityBasedInspection<KtCallableDeclaration>(
KtCallableDeclaration::class.java
) {
override fun inspectionText(element: KtCallableDeclaration) = "@Deprecated annotation without 'replaceWith' argument"
override fun inspectionText(element: KtCallableDeclaration) = KotlinBundle.message("deprecated.annotation.without.replacewith.argument")
override fun inspectionHighlightRangeInElement(element: KtCallableDeclaration) = element.annotationEntries.first {
it.shortName == DEPRECATED_NAME
}.textRangeIn(element)
override val defaultFixText = "Add 'replaceWith' argument to specify replacement pattern"
override val defaultFixText = KotlinBundle.message("add.replacewith.argument.to.specify.replacement.pattern")
private class ReplaceWith(val expression: String, vararg val imports: String)
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.daemon.impl.quickfix.RenameElementFix
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.destructuringDeclarationVisitor
@@ -34,7 +35,7 @@ class DestructuringWrongNameInspection : AbstractKotlinInspection() {
val fix = primaryParameterNames.getOrNull(entryIndex)?.let { RenameElementFix(entry, it) }
holder.registerProblem(
entry,
"Variable name '$variableName' matches the name of a different component",
KotlinBundle.message("variable.name.0.matches.the.name.of.a.different.component", variableName),
*listOfNotNull(fix).toTypedArray()
)
break
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
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.intentions.getArguments
import org.jetbrains.kotlin.psi.KtExpression
@@ -30,14 +31,14 @@ class EmptyRangeInspection : AbstractPrimitiveRangeToInspection() {
holder.registerProblem(
expression,
"This range is empty. Did you mean to use 'downTo'?",
KotlinBundle.message("this.range.is.empty.did.you.mean.to.use.downto"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceWithDownToFix()
)
}
class ReplaceWithDownToFix : LocalQuickFix {
override fun getName() = "Replace with 'downTo'"
override fun getName() = KotlinBundle.message("replace.with.down.to.fix.text")
override fun getFamilyName() = name
@@ -13,6 +13,7 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateEqualsAndHashcodeAction
import org.jetbrains.kotlin.idea.actions.generate.findDeclaredEquals
import org.jetbrains.kotlin.idea.actions.generate.findDeclaredHashCode
@@ -24,7 +25,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.source.getPsi
object DeleteEqualsAndHashCodeFix : LocalQuickFix {
override fun getName() = "Delete equals()/hashCode()"
override fun getName() = KotlinBundle.message("delete.equals.and.hash.code.fix.text")
override fun getFamilyName() = name
@@ -39,11 +40,11 @@ object DeleteEqualsAndHashCodeFix : LocalQuickFix {
sealed class GenerateEqualsOrHashCodeFix : LocalQuickFix {
object Equals : GenerateEqualsOrHashCodeFix() {
override fun getName() = "Generate 'equals()'"
override fun getName() = InspectionsBundle.message("inspection.equals.hashcode.generate.equals.quickfix")
}
object HashCode : GenerateEqualsOrHashCodeFix() {
override fun getName() = "Generate 'hashCode()'"
override fun getName() = InspectionsBundle.message("inspection.equals.hashcode.generate.hashcode.quickfix")
}
override fun getFamilyName() = name
@@ -68,7 +69,11 @@ class EqualsOrHashCodeInspection : AbstractKotlinInspection() {
when (classDescriptor.kind) {
ClassKind.OBJECT -> {
if (classOrObject.superTypeListEntries.isNotEmpty()) return
holder.registerProblem(nameIdentifier, "equals()/hashCode() in object declaration", DeleteEqualsAndHashCodeFix)
holder.registerProblem(
nameIdentifier,
KotlinBundle.message("equals.hashcode.in.object.declaration"),
DeleteEqualsAndHashCodeFix
)
}
ClassKind.CLASS -> {
if (hasEquals && hasHashCode) return
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.intentions.getCallableDescriptor
import org.jetbrains.kotlin.idea.references.mainReference
@@ -42,7 +43,7 @@ class ExplicitThisInspection : AbstractKotlinInspection() {
if (hasExplicitThis(expression)) {
holder.registerProblem(
thisExpression,
"Redundant explicit this",
KotlinBundle.message("redundant.explicit.this"),
LIKE_UNUSED_SYMBOL,
ExplicitThisExpressionFix(thisExpression.text)
)
@@ -108,7 +109,7 @@ class ExplicitThisInspection : AbstractKotlinInspection() {
}
class ExplicitThisExpressionFix(private val text: String) : LocalQuickFix {
override fun getFamilyName(): String = "Remove redundant '$text'"
override fun getFamilyName(): String = KotlinBundle.message("explicit.this.expression.fix.family.name", text)
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val thisExpression = descriptor.psiElement as? KtThisExpression ?: return
@@ -22,6 +22,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.*
import org.jetbrains.kotlin.asJava.elements.KtLightFieldForSourceDeclarationSupport
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.inspections.MayBeConstantInspection.Status.*
import org.jetbrains.kotlin.idea.quickfix.AddConstModifierFix
import org.jetbrains.kotlin.psi.KtProperty
@@ -98,7 +99,7 @@ class FakeJvmFieldConstantInspection : AbstractKotlinInspection() {
}
holder.registerProblem(
valueExpression,
"Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4",
KotlinBundle.message("use.of.non.const.kotlin.property.as.java.constant.is.incorrect.will.be.forbidden.in.1.4"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
*fixes.toTypedArray()
)
@@ -14,6 +14,7 @@ import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.search.LocalSearchScope
import com.intellij.psi.search.searches.ReferencesSearch
import org.jetbrains.kotlin.descriptors.VariableDescriptor
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.core.replaced
@@ -38,9 +39,9 @@ import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
class FoldInitializerAndIfToElvisInspection : AbstractApplicabilityBasedInspection<KtIfExpression>(KtIfExpression::class.java) {
override fun inspectionText(element: KtIfExpression): String = "If-Null return/break/... foldable to '?:'"
override fun inspectionText(element: KtIfExpression): String = KotlinBundle.message("if.null.return.break.foldable.to")
override val defaultFixText: String = "Replace 'if' with elvis operator"
override val defaultFixText: String = KotlinBundle.message("replace.if.with.elvis.operator")
override fun inspectionHighlightRangeInElement(element: KtIfExpression) = element.fromIfKeywordToRightParenthesisTextRangeInThis()
@@ -14,6 +14,7 @@ import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl.WithDestructuringDeclaration
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.core.moveFunctionLiteralOutsideParentheses
@@ -59,7 +60,7 @@ class ForEachParameterNotUsedInspection : AbstractKotlinInspection() {
fixes += IntroduceAnonymousParameterFix()
holder.registerProblem(
calleeExpression,
"Loop parameter '${iterableParameter.getThisLabelName()}' is unused",
KotlinBundle.message("loop.parameter.0.is.unused", iterableParameter.getThisLabelName()),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
*fixes.toTypedArray()
)
@@ -70,7 +71,7 @@ class ForEachParameterNotUsedInspection : AbstractKotlinInspection() {
}
private class IntroduceAnonymousParameterFix : LocalQuickFix {
override fun getFamilyName() = "Introduce anonymous parameter"
override fun getFamilyName() = KotlinBundle.message("introduce.anonymous.parameter.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val callExpression = descriptor.psiElement.parent as? KtCallExpression ?: return
@@ -84,7 +85,7 @@ class ForEachParameterNotUsedInspection : AbstractKotlinInspection() {
}
private class ReplaceWithRepeatFix : LocalQuickFix {
override fun getFamilyName() = "Replace with 'repeat()'"
override fun getFamilyName() = KotlinBundle.message("replace.with.repeat.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val callExpression = descriptor.psiElement.parent as? KtCallExpression ?: return
@@ -11,6 +11,7 @@ import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.search.searches.ReferencesSearch
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.core.setType
@@ -59,7 +60,7 @@ class FunctionWithLambdaExpressionBodyInspection : AbstractKotlinInspection() {
)
holder.registerProblem(
lambda,
"Function with `= { ... }` and inferred return type",
KotlinBundle.message("function.with.and.inferred.return.type"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
*fixes.toTypedArray()
)
@@ -71,7 +72,7 @@ class FunctionWithLambdaExpressionBodyInspection : AbstractKotlinInspection() {
}
private class RemoveBracesFix : LocalQuickFix {
override fun getName() = "Remove braces"
override fun getName() = KotlinBundle.message("remove.braces.fix.text")
override fun getFamilyName() = name
@@ -84,7 +85,7 @@ class FunctionWithLambdaExpressionBodyInspection : AbstractKotlinInspection() {
}
private class WrapRunFix : LocalQuickFix {
override fun getName() = "Convert to run { ... }"
override fun getName() = KotlinBundle.message("wrap.run.fix.text")
override fun getFamilyName() = name
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.IntentionWrapper
import com.intellij.codeInspection.LocalQuickFix
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
import org.jetbrains.kotlin.idea.intentions.isFlexibleRecursive
import org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
@@ -43,8 +44,9 @@ class HasPlatformTypeInspection(
}
) {
override val problemText = "Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. " +
"Specify type explicitly as nullable or non-nullable."
override val problemText = KotlinBundle.message(
"declaration.has.type.inferred.from.a.platform.call.which.can.lead.to.unchecked.nullability.issues"
)
override fun additionalFixes(element: KtCallableDeclaration): List<LocalQuickFix>? {
val type = SpecifyTypeExplicitlyIntention.dangerousFlexibleTypeOrNull(
@@ -65,8 +67,8 @@ class HasPlatformTypeInspection(
override fun createOptionsPanel(): JComponent? {
val panel = MultipleCheckboxOptionsPanel(this)
panel.addCheckbox("Apply only to public or protected members", "publicAPIOnly")
panel.addCheckbox("Report for types with platform arguments", "reportPlatformArguments")
panel.addCheckbox(KotlinBundle.message("apply.only.to.public.or.protected.members"), "publicAPIOnly")
panel.addCheckbox(KotlinBundle.message("report.for.types.with.platform.arguments"), "reportPlatformArguments")
return panel
}
}
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
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.intentions.getCallableDescriptor
import org.jetbrains.kotlin.idea.util.getFactoryForImplicitReceiverWithSubtypeOf
@@ -50,7 +51,12 @@ class ImplicitThisInspection : AbstractKotlinInspection() {
val receiverText = if (expressionFactory.isImmediate) "this" else expressionFactory.expressionText
val fix = fixFactory(receiverText)
holder.registerProblem(expression, "Add explicit '$receiverText'", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fix)
holder.registerProblem(
expression,
KotlinBundle.message("callable.reference.fix.family.name", receiverText),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
fix
)
}
private fun KtExpression.isSelectorOfDotQualifiedExpression(): Boolean {
@@ -60,7 +66,7 @@ class ImplicitThisInspection : AbstractKotlinInspection() {
}
private class CallFix(private val receiverText: String) : LocalQuickFix {
override fun getFamilyName() = "Add explicit '$receiverText'"
override fun getFamilyName() = KotlinBundle.message("callable.reference.fix.family.name", receiverText)
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val expression = descriptor.psiElement as? KtExpression ?: return
@@ -72,7 +78,7 @@ class ImplicitThisInspection : AbstractKotlinInspection() {
}
private class CallableReferenceFix(private val receiverText: String) : LocalQuickFix {
override fun getFamilyName() = "Add explicit '$receiverText'"
override fun getFamilyName() = KotlinBundle.message("callable.reference.fix.family.name", receiverText)
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val expression = descriptor.psiElement as? KtCallableReferenceExpression ?: return
@@ -14,6 +14,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.intentions.callExpression
@@ -32,7 +33,7 @@ class JavaCollectionsStaticMethodInspection : AbstractKotlinInspection() {
val (methodName, firstArg) = getTargetMethodOnMutableList(expression) ?: return
holder.registerProblem(
expression,
"Java Collections static method call should be replaced with Kotlin stdlib",
KotlinBundle.message("java.collections.static.method.call.should.be.replaced.with.kotlin.stdlib"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceWithStdLibFix(methodName, firstArg.text)
)
@@ -101,7 +102,7 @@ private fun KotlinType.isListOrSubtype(): Boolean {
}
private class ReplaceWithStdLibFix(private val methodName: String, private val receiver: String) : LocalQuickFix {
override fun getName() = "Replace with $receiver.$methodName"
override fun getName() = KotlinBundle.message("replace.with.std.lib.fix.text", receiver, methodName)
override fun getFamilyName() = name
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.callExpression
import org.jetbrains.kotlin.psi.dotQualifiedExpressionVisitor
@@ -16,7 +17,7 @@ class JavaCollectionsStaticMethodOnImmutableListInspection : AbstractKotlinInspe
val (methodName, firstArg) = JavaCollectionsStaticMethodInspection.getTargetMethodOnImmutableList(expression) ?: return
holder.registerProblem(
expression.callExpression?.calleeExpression ?: expression,
"Call of Java mutator '$methodName' on immutable Kotlin collection '${firstArg.text}'"
KotlinBundle.message("call.of.java.mutator.0.on.immutable.kotlin.collection.1", methodName, firstArg.text)
)
})
}
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.getLastLambdaExpression
import org.jetbrains.kotlin.idea.inspections.collections.isMap
@@ -43,9 +44,10 @@ class JavaMapForEachInspection : AbstractApplicabilityBasedInspection<KtDotQuali
override fun inspectionHighlightRangeInElement(element: KtDotQualifiedExpression): TextRange? = element.calleeTextRangeInThis()
override fun inspectionText(element: KtDotQualifiedExpression) = "Java Map.forEach method call should be replaced with Kotlin's forEach"
override fun inspectionText(element: KtDotQualifiedExpression) =
KotlinBundle.message("java.map.foreach.method.call.should.be.replaced.with.kotlin.s.foreach")
override val defaultFixText = "Replace with Kotlin's forEach"
override val defaultFixText = KotlinBundle.message("replace.with.kotlin.s.foreach")
override fun applyTo(element: KtDotQualifiedExpression, project: Project, editor: Editor?) {
val call = element.callExpression ?: return
@@ -15,6 +15,7 @@ import com.intellij.psi.PsiFile
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.analyzeWithAllCompilerChecks
import org.jetbrains.kotlin.idea.highlighter.KotlinPsiChecker
import org.jetbrains.kotlin.idea.quickfix.CleanupFix
@@ -32,7 +33,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
class KotlinCleanupInspection : LocalInspectionTool(), CleanupLocalInspectionTool {
// required to simplify the inspection registration in tests
override fun getDisplayName(): String = "Usage of redundant or deprecated syntax or deprecated symbols"
override fun getDisplayName(): String = KotlinBundle.message("usage.of.redundant.or.deprecated.syntax.or.deprecated.symbols")
override fun checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array<out ProblemDescriptor>? {
if (isOnTheFly || file !is KtFile || !ProjectRootsUtil.isInProjectSource(file)) {
@@ -134,7 +135,7 @@ class KotlinCleanupInspection : LocalInspectionTool(), CleanupLocalInspectionToo
}
private class RemoveImportFix(import: KtImportDirective) : KotlinQuickFixAction<KtImportDirective>(import), CleanupFix {
override fun getFamilyName() = "Remove deprecated symbol import"
override fun getFamilyName() = KotlinBundle.message("remove.deprecated.symbol.import")
override fun getText() = familyName
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
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
@@ -36,7 +37,7 @@ class KotlinCovariantEqualsInspection : AbstractKotlinInspection() {
if (classOrObject.body?.children?.any { (it as? KtNamedFunction)?.isEquals() == true } == true) return
holder.registerProblem(nameIdentifier, "'equals' should take 'Any?' as its argument")
holder.registerProblem(nameIdentifier, KotlinBundle.message("equals.should.take.any.as.its.argument"))
})
private fun KtNamedFunction.isEquals(): Boolean {
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.*
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.lexer.KtTokens
@@ -31,7 +32,7 @@ class KotlinDoubleNegationInspection : AbstractKotlinInspection(), CleanupLocalI
if (parent is KtPrefixExpression && parent.operationToken == KtTokens.EXCL) {
holder.registerProblem(
expression,
"Redundant double negation",
KotlinBundle.message("redundant.double.negation"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
DoubleNegationFix()
)
@@ -39,7 +40,7 @@ class KotlinDoubleNegationInspection : AbstractKotlinInspection(), CleanupLocalI
})
private class DoubleNegationFix : LocalQuickFix {
override fun getName() = "Remove redundant negations"
override fun getName() = KotlinBundle.message("double.negation.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
@@ -27,7 +28,7 @@ class KotlinEqualsBetweenInconvertibleTypesInspection : AbstractKotlinInspection
val receiver = call.getQualifiedExpressionForSelector()?.receiverExpression ?: return
val argument = call.valueArguments.singleOrNull()?.getArgumentExpression() ?: return
if (call.analyze(BodyResolveMode.PARTIAL).isInconvertibleTypes(receiver, argument)) {
holder.registerProblem(callee, "'equals()' between objects of inconvertible types")
holder.registerProblem(callee, KotlinBundle.message("equals.between.objects.of.inconvertible.types"))
}
})
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.*
import org.jetbrains.kotlin.asJava.elements.KtLightElement
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.util.module
import org.jetbrains.kotlin.lexer.KtTokens.INTERNAL_KEYWORD
import org.jetbrains.kotlin.psi.KtModifierListOwner
@@ -35,7 +36,7 @@ class KotlinInternalInJavaInspection : LocalInspectionTool() {
}
if (modifierListOwner.hasModifier(INTERNAL_KEYWORD)) {
holder.registerProblem(this, "Usage of Kotlin internal declaration from different module")
holder.registerProblem(this, KotlinBundle.message("usage.of.kotlin.internal.declaration.from.different.module"))
}
}
@@ -14,9 +14,10 @@ import com.intellij.openapi.util.DefaultJDOMExternalizer
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import org.jdom.Element
import org.jetbrains.kotlin.idea.KotlinBundle
class KotlinJUnitStaticEntryPoint(@JvmField var wasSelected: Boolean = true) : EntryPoint() {
override fun getDisplayName() = "JUnit static methods"
override fun getDisplayName() = KotlinBundle.message("junit.static.methods")
override fun isSelected() = wasSelected
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.Modality
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.lexer.KtTokens
@@ -67,7 +68,7 @@ class KotlinRedundantOverrideInspection : AbstractKotlinInspection(), CleanupLoc
val descriptor = holder.manager.createProblemDescriptor(
function,
TextRange(modifierList.startOffsetInParent, funKeyword.endOffset - function.startOffset),
"Redundant overriding method",
KotlinBundle.message("redundant.overriding.method"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
isOnTheFly,
RedundantOverrideFix()
@@ -109,7 +110,7 @@ class KotlinRedundantOverrideInspection : AbstractKotlinInspection(), CleanupLoc
}
private class RedundantOverrideFix : LocalQuickFix {
override fun getName() = "Remove redundant overriding method"
override fun getName() = KotlinBundle.message("redundant.override.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -12,6 +12,7 @@ import com.siyeh.ig.psiutils.TestUtils
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.psi.*
@@ -35,9 +36,9 @@ class KotlinThrowableNotThrownInspection : AbstractKotlinInspection() {
if (callExpression.isUsed()) return
val description = if (resultingDescriptor is ConstructorDescriptor) {
"Throwable instance '${calleeExpression.text}' is not thrown"
KotlinBundle.message("throwable.instance.0.is.not.thrown", calleeExpression.text)
} else {
"Result of '${calleeExpression.text}' call is not thrown"
KotlinBundle.message("result.of.0.call.is.not.thrown", calleeExpression.text)
}
holder.registerProblem(calleeExpression, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)
})
@@ -40,6 +40,7 @@ import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.util.PsiModificationTracker
import com.intellij.psi.util.PsiUtilBase
import com.intellij.util.DocumentUtil
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.KotlinCodeInsightWorkspaceSettings
import org.jetbrains.kotlin.idea.core.targetDescriptors
@@ -124,7 +125,7 @@ class KotlinUnusedImportInspection : AbstractKotlinInspection() {
}
manager.createProblemDescriptor(
it,
"Unused import directive",
KotlinBundle.message("unused.import.directive"),
isOnTheFly,
fixes.toTypedArray(),
ProblemHighlightType.LIKE_UNUSED_SYMBOL
@@ -220,7 +221,7 @@ class KotlinUnusedImportInspection : AbstractKotlinInspection() {
}
private class OptimizeImportsQuickFix(file: KtFile) : LocalQuickFixOnPsiElement(file) {
override fun getText() = "Optimize imports"
override fun getText() = KotlinBundle.message("optimize.imports")
override fun getFamilyName() = name
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtProperty
@@ -24,7 +25,7 @@ class LateinitVarOverridesLateinitVarInspection : AbstractKotlinInspection() {
if (descriptor.overriddenDescriptors.any { (it as? PropertyDescriptor)?.let { d -> d.isLateInit && d.isVar } == true }) {
holder.registerProblem(
identifier,
"lateinit var overrides lateinit var"
KotlinBundle.message("lateinit.var.overrides.lateinit.var")
)
}
}
@@ -14,6 +14,7 @@ import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.search.searches.DefinitionsScopedSearch
import org.jetbrains.kotlin.cfg.LeakingThisDescriptor.*
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.quickfix.AddModifierFix
import org.jetbrains.kotlin.lexer.KtTokens
@@ -40,21 +41,21 @@ class LeakingThisInspection : AbstractKotlinInspection() {
if (expression is KtThisExpression && expression.getStrictParentOfType<KtClassLiteralExpression>() == null) {
val name = leakingThisDescriptor.klass.name
klass.createDescription(
"Leaking 'this' in constructor of non-final class $name",
"Leaking 'this' in constructor of enum class $name (with overridable members)"
KotlinBundle.message("leaking.this.in.constructor.of.non.final.class.0", name),
KotlinBundle.message("leaking.this.in.constructor.of.enum.class.0.with.overridable.members", name)
) { it.hasOverriddenMember() } ?: continue@these
} else {
continue@these // Not supported yet
}
is NonFinalProperty -> {
val name = leakingThisDescriptor.property.name.asString()
klass.createDescription("Accessing non-final property $name in constructor") {
klass.createDescription(KotlinBundle.message("accessing.non.final.property.0.in.constructor", name)) {
it.hasOverriddenMember { owner -> owner.name == name }
} ?: continue@these
}
is NonFinalFunction -> {
val function = leakingThisDescriptor.function
klass.createDescription("Calling non-final function ${function.name} in constructor") {
klass.createDescription(KotlinBundle.message("calling.non.final.function.0.in.constructor", function.name)) {
it.hasOverriddenMember { owner ->
owner is KtNamedFunction &&
owner.name == function.name.asString() &&
@@ -21,6 +21,7 @@ import com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING
import com.intellij.codeInspection.ProblemHighlightType.INFORMATION
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFoldingUtils
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isElseIf
@@ -62,11 +63,11 @@ class LiftReturnOrAssignmentInspection @JvmOverloads constructor(private val ski
highlightElement: PsiElement = keyword,
highlightType: ProblemHighlightType = if (isSerious) GENERIC_ERROR_OR_WARNING else INFORMATION
) {
val subject = if (fix is LiftReturnOutFix) "Return" else "Assignment"
val verb = if (isSerious) "should" else "can"
val subject = if (fix is LiftReturnOutFix) KotlinBundle.message("text.Return") else KotlinBundle.message("text.Assignment")
val verb = if (isSerious) KotlinBundle.message("text.should") else KotlinBundle.message("text.can")
holder.registerProblemWithoutOfflineInformation(
expression,
"$subject $verb be lifted out of '${keyword.text}'",
KotlinBundle.message("0.1.be.lifted.out.of.2", subject, verb, keyword.text),
isOnTheFly,
highlightType,
highlightElement.textRange?.shiftRight(-expression.startOffset),
@@ -77,7 +78,7 @@ class LiftReturnOrAssignmentInspection @JvmOverloads constructor(private val ski
}
private class LiftReturnOutFix(private val keyword: String) : LocalQuickFix {
override fun getName() = "Lift return out of '$keyword'"
override fun getName() = KotlinBundle.message("lift.return.out.fix.text.0", keyword)
override fun getFamilyName() = name
@@ -88,7 +89,7 @@ class LiftReturnOrAssignmentInspection @JvmOverloads constructor(private val ski
}
private class LiftAssignmentOutFix(private val keyword: String) : LocalQuickFix {
override fun getName() = "Lift assignment out of '$keyword'"
override fun getName() = KotlinBundle.message("lift.assignment.out.fix.text.0", keyword)
override fun getFamilyName() = name
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -48,7 +49,7 @@ class MainFunctionReturnUnitInspection : AbstractKotlinInspection() {
holder.registerProblem(
function.nameIdentifier ?: function,
"${if (isMain) "main" else "JUnit test"} should return Unit",
KotlinBundle.message("0.should.return.unit", if (isMain) "main" else KotlinBundle.message("junit.test")),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ChangeMainFunctionReturnTypeToUnitFix(function.typeReference != null)
)
@@ -63,7 +64,10 @@ private fun KtAnnotationEntry.fqName(): FqName? {
}
private class ChangeMainFunctionReturnTypeToUnitFix(private val hasExplicitReturnType: Boolean) : LocalQuickFix {
override fun getName() = if (hasExplicitReturnType) "Change return type to Unit" else "Add explicit Unit return type"
override fun getName() = if (hasExplicitReturnType)
KotlinBundle.message("change.main.function.return.type.to.unit.fix.text2")
else
KotlinBundle.message("change.main.function.return.type.to.unit.fix.text")
override fun getFamilyName() = name
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiDocumentManager
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.idea.intentions.callExpression
@@ -29,7 +30,7 @@ class MapGetWithNotNullAssertionOperatorInspection : AbstractKotlinInspection()
if (expression.baseExpression?.resolveToCall()?.resultingDescriptor?.fqNameSafe != FqName("kotlin.collections.Map.get")) return
holder.registerProblem(
expression.operationReference,
"map.get() with not-null assertion operator (!!)",
KotlinBundle.message("map.get.with.not.null.assertion.operator"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceWithGetValueCallFix(),
ReplaceWithGetOrElseFix(),
@@ -38,7 +39,7 @@ class MapGetWithNotNullAssertionOperatorInspection : AbstractKotlinInspection()
})
private class ReplaceWithGetValueCallFix : LocalQuickFix {
override fun getName() = "Replace with 'getValue' call"
override fun getName() = KotlinBundle.message("replace.with.get.value.call.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val expression = descriptor.psiElement.parent as? KtPostfixExpression ?: return
@@ -49,7 +50,7 @@ class MapGetWithNotNullAssertionOperatorInspection : AbstractKotlinInspection()
}
private class ReplaceWithGetOrElseFix : LocalQuickFix {
override fun getName() = "Replace with 'getOrElse' call"
override fun getName() = KotlinBundle.message("replace.with.get.or.else.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val expression = descriptor.psiElement.parent as? KtPostfixExpression ?: return
@@ -66,7 +67,7 @@ class MapGetWithNotNullAssertionOperatorInspection : AbstractKotlinInspection()
}
private class ReplaceWithElvisErrorFix : LocalQuickFix {
override fun getName() = "Replace with '?: error(\"\")'"
override fun getName() = KotlinBundle.message("replace.with.elvis.error.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val expression = descriptor.psiElement.parent as? KtPostfixExpression ?: return
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.inspections.MayBeConstantInspection.Status.*
import org.jetbrains.kotlin.idea.quickfix.AddConstModifierFix
@@ -47,7 +48,10 @@ class MayBeConstantInspection : AbstractKotlinInspection() {
MIGHT_BE_CONST, JVM_FIELD_MIGHT_BE_CONST -> {
holder.registerProblem(
property.nameIdentifier ?: property,
if (status == JVM_FIELD_MIGHT_BE_CONST) "'const' might be used instead of '@JvmField'" else "Might be 'const'",
if (status == JVM_FIELD_MIGHT_BE_CONST)
KotlinBundle.message("const.might.be.used.instead.of.jvmfield")
else
KotlinBundle.message("might.be.const"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
IntentionWrapper(AddConstModifierFix(property), property.containingFile)
)
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
import org.jetbrains.kotlin.descriptors.EffectiveVisibility
import org.jetbrains.kotlin.descriptors.effectiveVisibility
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.core.canBePrivate
import org.jetbrains.kotlin.idea.core.isInheritable
@@ -150,13 +151,13 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() {
private fun registerProblem(holder: ProblemsHolder, declaration: KtDeclaration) {
val modifierListOwner = declaration.getParentOfType<KtModifierListOwner>(false) ?: return
val member = when (declaration) {
is KtNamedFunction -> "Function"
else -> "Property"
is KtNamedFunction -> KotlinBundle.message("text.Function")
else -> KotlinBundle.message("text.Property")
}
val nameElement = (declaration as? PsiNameIdentifierOwner)?.nameIdentifier ?: return
holder.registerProblem(
declaration.visibilityModifier() ?: nameElement,
"$member '${declaration.getName()}' could be private",
KotlinBundle.message("0.1.could.be.private", member, declaration.getName().toString()),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
IntentionWrapper(AddModifierFix(modifierListOwner, KtTokens.PRIVATE_KEYWORD), declaration.containingKtFile)
)
@@ -13,6 +13,7 @@ import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
@@ -36,7 +37,7 @@ class MigrateDiagnosticSuppressionInspection : AbstractKotlinInspection(), Clean
holder.registerProblem(
expression,
"Diagnostic name should be replaced by the new one",
KotlinBundle.message("diagnostic.name.should.be.replaced.by.the.new.one"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceDiagnosticNameFix(newDiagnosticFactory)
)
@@ -45,9 +46,9 @@ class MigrateDiagnosticSuppressionInspection : AbstractKotlinInspection(), Clean
}
class ReplaceDiagnosticNameFix(private val diagnosticFactory: DiagnosticFactory<*>) : LocalQuickFix {
override fun getName() = "$familyName with ${diagnosticFactory.name}"
override fun getName() = KotlinBundle.message("replace.diagnostic.name.fix.text", familyName, diagnosticFactory.name)
override fun getFamilyName() = "Replace diagnostic name"
override fun getFamilyName() = KotlinBundle.message("replace.diagnostic.name.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val expression = descriptor.psiElement as? KtStringTemplateExpression ?: return
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.canMoveLambdaOutsideParentheses
import org.jetbrains.kotlin.idea.core.getLastLambdaExpression
import org.jetbrains.kotlin.idea.core.moveFunctionLiteralOutsideParentheses
@@ -27,7 +28,7 @@ class MoveLambdaOutsideParenthesesInspection : AbstractApplicabilityBasedInspect
}
private val KtCallExpression.verb: String
get() = if (withInformationLevel()) "can" else "should"
get() = if (withInformationLevel()) KotlinBundle.message("text.can") else KotlinBundle.message("text.should")
override fun inspectionHighlightType(element: KtCallExpression): ProblemHighlightType =
if (element.withInformationLevel()) ProblemHighlightType.INFORMATION else ProblemHighlightType.GENERIC_ERROR_OR_WARNING
@@ -40,11 +41,11 @@ class MoveLambdaOutsideParenthesesInspection : AbstractApplicabilityBasedInspect
}
}
override fun inspectionText(element: KtCallExpression) = "Lambda argument ${element.verb} be moved out of parentheses"
override fun inspectionText(element: KtCallExpression) = KotlinBundle.message("lambda.argument.0.be.moved.out", element.verb)
override fun inspectionHighlightRangeInElement(element: KtCallExpression) = element.getLastLambdaExpression()
?.getStrictParentOfType<KtValueArgument>()?.asElement()
?.textRangeIn(element)
override val defaultFixText = "Move lambda argument out of parentheses"
override val defaultFixText = KotlinBundle.message("move.lambda.argument.out.of.parentheses")
}
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -59,7 +60,7 @@ class MoveSuspiciousCallableReferenceIntoParenthesesInspection : AbstractKotlinI
null
holder.registerProblem(
lambdaExpression,
"Suspicious callable reference as the only lambda element",
KotlinBundle.message("suspicious.callable.reference.as.the.only.lambda.element"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
quickFix
)
@@ -15,6 +15,7 @@ import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.SmartPsiElementPointer
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.moveCaret
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isOneLiner
import org.jetbrains.kotlin.idea.intentions.loopToCallChain.countUsages
@@ -55,14 +56,14 @@ private enum class Action {
val description: String
get() = when (this) {
MOVE -> "Variable declaration could be moved into `when`"
INLINE -> "Variable declaration could be inlined"
NOTHING -> "Nothing to do"
MOVE -> KotlinBundle.message("variable.declaration.could.be.moved.into.when")
INLINE -> KotlinBundle.message("variable.declaration.could.be.inlined")
NOTHING -> KotlinBundle.message("nothing.to.do")
}
fun createFix(subjectExpressionPointer: SmartPsiElementPointer<KtExpression>): VariableDeclarationIntoWhenFix = when (this) {
MOVE -> VariableDeclarationIntoWhenFix("Move variable declaration into `when`", subjectExpressionPointer) { it }
INLINE -> VariableDeclarationIntoWhenFix("Inline variable", subjectExpressionPointer) { it.initializer }
MOVE -> VariableDeclarationIntoWhenFix(KotlinBundle.message("move.variable.declaration.into.when"), subjectExpressionPointer) { it }
INLINE -> VariableDeclarationIntoWhenFix(KotlinBundle.message("inline.variable"), subjectExpressionPointer) { it.initializer }
else -> error("Illegal action")
}
}
@@ -25,6 +25,7 @@ import org.intellij.lang.annotations.Language
import org.intellij.lang.regexp.RegExpFileType
import org.jdom.Element
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.packageMatchesDirectoryOrImplicit
import org.jetbrains.kotlin.idea.quickfix.RenameIdentifierFix
import org.jetbrains.kotlin.idea.refactoring.isInjectedFragment
@@ -48,35 +49,35 @@ private fun findRuleMessage(checkString: String, rules: Array<out NamingRule>):
return null
}
private val START_UPPER = NamingRule("should start with an uppercase letter") {
private val START_UPPER = NamingRule(KotlinBundle.message("should.start.with.an.uppercase.letter")) {
it.getOrNull(0)?.isUpperCase() == false
}
private val START_LOWER = NamingRule("should start with a lowercase letter") {
private val START_LOWER = NamingRule(KotlinBundle.message("should.start.with.a.lowercase.letter")) {
it.getOrNull(0)?.isLowerCase() == false
}
private val NO_UNDERSCORES = NamingRule("should not contain underscores") {
private val NO_UNDERSCORES = NamingRule(KotlinBundle.message("should.not.contain.underscores")) {
'_' in it
}
private val NO_START_UPPER = NamingRule("should not start with an uppercase letter") {
private val NO_START_UPPER = NamingRule(KotlinBundle.message("should.not.start.with.an.uppercase.letter")) {
it.getOrNull(0)?.isUpperCase() == true
}
private val NO_START_UNDERSCORE = NamingRule("should not start with an underscore") {
private val NO_START_UNDERSCORE = NamingRule(KotlinBundle.message("should.not.start.with.an.underscore")) {
it.startsWith('_')
}
private val NO_MIDDLE_UNDERSCORES = NamingRule("should not contain underscores in the middle or the end") {
private val NO_MIDDLE_UNDERSCORES = NamingRule(KotlinBundle.message("should.not.contain.underscores.in.the.middle.or.the.end")) {
'_' in it.substring(1)
}
private val NO_BAD_CHARACTERS = NamingRule("may contain only letters and digits") {
private val NO_BAD_CHARACTERS = NamingRule(KotlinBundle.message("may.contain.only.letters.and.digits")) {
it.any { c -> c !in 'a'..'z' && c !in 'A'..'Z' && c !in '0'..'9' }
}
private val NO_BAD_CHARACTERS_OR_UNDERSCORE = NamingRule("may contain only letters, digits or underscores") {
private val NO_BAD_CHARACTERS_OR_UNDERSCORE = NamingRule(KotlinBundle.message("may.contain.only.letters.digits.or.underscores")) {
it.any { c -> c !in 'a'..'z' && c !in 'A'..'Z' && c !in '0'..'9' && c != '_' }
}
@@ -106,7 +107,7 @@ class NamingConventionInspectionSettings(
val message = getNameMismatchMessage(name)
holder.registerProblem(
element.nameIdentifier!!,
"$entityName name <code>#ref</code> $message #loc",
"$entityName ${KotlinBundle.message("text.name")}<code>#ref</code> $message #loc",
RenameIdentifierFix()
)
}
@@ -120,7 +121,7 @@ class NamingConventionInspectionSettings(
return findRuleMessage(name, rules) ?: getDefaultErrorMessage()
}
fun getDefaultErrorMessage() = "doesn't match regex '$namePattern'"
fun getDefaultErrorMessage() = KotlinBundle.message("doesn.t.match.regex.0", namePattern)
fun createOptionsPanel(): JPanel = NamingConventionOptionsPanel(this)
@@ -136,7 +137,7 @@ class NamingConventionInspectionSettings(
settings.namePattern = regexField.text
}
})
val labeledComponent = LabeledComponent.create(regexField, "Pattern:", BorderLayout.WEST)
val labeledComponent = LabeledComponent.create(regexField, KotlinBundle.message("text.pattern"), BorderLayout.WEST)
add(labeledComponent, BorderLayout.NORTH)
}
}
@@ -329,10 +330,10 @@ private class PackageNameInspectionLocal(
data class CheckResult(val errorMessage: String, val isForPart: Boolean)
fun CheckResult.toProblemTemplateString(): String {
return if (isForPart) {
"Package name <code>#ref</code> part $errorMessage #loc"
return KotlinBundle.message("package.name") + if (isForPart) {
" <code>#ref</code> ${KotlinBundle.message("text.part")} $errorMessage #loc"
} else {
"Package name <code>#ref</code> $errorMessage #loc"
" <code>#ref</code> $errorMessage #loc"
}
}
@@ -378,10 +379,10 @@ class PackageNameInspection : BaseGlobalInspection() {
val PART_RULES = arrayOf(NO_BAD_CHARACTERS_OR_UNDERSCORE, NO_START_UPPER)
private fun PackageNameInspectionLocal.Companion.CheckResult.toErrorMessage(qualifiedName: String): String {
return if (isForPart) {
"Package name <code>$qualifiedName</code> part $errorMessage"
return KotlinBundle.message("package.name") + if (isForPart) {
" <code>$qualifiedName</code> ${KotlinBundle.message("text.part")} $errorMessage"
} else {
"Package name <code>$qualifiedName</code> $errorMessage"
" <code>$qualifiedName</code> $errorMessage"
}
}
}
@@ -391,7 +392,7 @@ class PackageNameInspection : BaseGlobalInspection() {
var namePattern: String = DEFAULT_PACKAGE_NAME_PATTERN
private val namingSettings = NamingConventionInspectionSettings(
"Package",
KotlinBundle.message("text.Package"),
DEFAULT_PACKAGE_NAME_PATTERN,
setNamePatternCallback = { value ->
namePattern = value
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
import org.jetbrains.kotlin.idea.intentions.ReplaceItWithExplicitFunctionLiteralParamIntention
@@ -52,7 +53,7 @@ class NestedLambdaShadowedImplicitParameterInspection : AbstractKotlinInspection
if (it.isImplicitParameterReference(lambda, implicitParameter, context)) {
holder.registerProblem(
it,
"Implicit parameter 'it' of enclosing lambda is shadowed",
KotlinBundle.message("implicit.parameter.it.of.enclosing.lambda.is.shadowed"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
AddExplicitParameterToOuterLambdaFix(),
IntentionWrapper(ReplaceItWithExplicitFunctionLiteralParamIntention(), containingFile)
@@ -63,7 +64,7 @@ class NestedLambdaShadowedImplicitParameterInspection : AbstractKotlinInspection
}
private class AddExplicitParameterToOuterLambdaFix : LocalQuickFix {
override fun getName() = "Add explicit parameter name to outer lambda"
override fun getName() = KotlinBundle.message("add.explicit.parameter.to.outer.lambda.fix.text")
override fun getFamilyName() = name
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInsight.FileModificationService
import com.intellij.codeInspection.*
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.intentions.branchedTransformations.isStableSimpleExpression
@@ -24,7 +25,7 @@ class NullChecksToSafeCallInspection : AbstractKotlinInspection() {
if (isNullChecksToSafeCallFixAvailable(expression)) {
holder.registerProblem(
expression,
"Null-checks replaceable with safe-calls",
KotlinBundle.message("null.checks.replaceable.with.safe.calls"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
NullChecksToSafeCallCheckFix()
)
@@ -32,7 +33,7 @@ class NullChecksToSafeCallInspection : AbstractKotlinInspection() {
}
private class NullChecksToSafeCallCheckFix : LocalQuickFix {
override fun getName() = "Replace chained null-checks with safe-calls"
override fun getName() = KotlinBundle.message("null.checks.to.safe.call.check.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING
import com.intellij.codeInspection.ProblemHighlightType.INFORMATION
import com.intellij.openapi.project.Project
import com.intellij.psi.util.PsiTreeUtil
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.lexer.KtTokens
@@ -37,13 +38,13 @@ class NullableBooleanElvisInspection : AbstractKotlinInspection(), CleanupLocalI
else -> null
}
val (highlightType, verb) = if (condition != null && condition in expression.parentsWithSelf)
GENERIC_ERROR_OR_WARNING to "should"
GENERIC_ERROR_OR_WARNING to KotlinBundle.message("text.should")
else
INFORMATION to "can"
INFORMATION to KotlinBundle.message("text.can")
holder.registerProblemWithoutOfflineInformation(
expression,
"Equality check $verb be used instead of elvis for nullable boolean check",
KotlinBundle.message("equality.cehck.0.be.used.instead.of.elvis.for.nullable.boolean.check", verb),
isOnTheFly,
highlightType,
ReplaceWithEqualityCheckFix()
@@ -52,7 +53,7 @@ class NullableBooleanElvisInspection : AbstractKotlinInspection(), CleanupLocalI
})
private class ReplaceWithEqualityCheckFix : LocalQuickFix {
override fun getName() = "Replace with equality check"
override fun getName() = KotlinBundle.message("replace.with.equality.check.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.LocalInspectionToolSession
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo
import org.jetbrains.kotlin.idea.caches.project.implementingDescriptors
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
@@ -57,7 +58,11 @@ class OptionalExpectationInspection : AbstractKotlinInspection() {
val actualModule = (actualModuleDescriptor.getCapability(ModuleInfo.Capability) as? ModuleSourceInfo)?.module ?: continue
holder.registerProblem(
classOrObject.nameIdentifier ?: classOrObject,
"Optionally expected annotation has no actual annotation in module $displayedName for platform ${platform.oldFashionedDescription}",
KotlinBundle.message(
"optionally.expected.annotation.has.no.actual.annotation.in.module.0.for.platform.1",
displayedName,
platform.oldFashionedDescription
),
// NB: some highlighting is not suggested for this inspection
ProblemHighlightType.INFORMATION,
IntentionWrapper(CreateActualClassFix(classOrObject, actualModule, platform), classOrObject.containingFile)
@@ -16,6 +16,7 @@ import com.intellij.ui.EditorTextField
import org.intellij.lang.regexp.RegExpFileType
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.project.languageVersionSettings
@@ -77,7 +78,7 @@ class PlatformExtensionReceiverOfInlineInspection : AbstractKotlinInspection() {
holder.registerProblem(
receiverExpression,
"Call of inline function with nullable extension receiver can provoke NPE in Kotlin 1.2+",
KotlinBundle.message("call.of.inline.function.with.nullable.extension.receiver.can.provoke.npe.in.kotlin.1.2"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
IntentionWrapper(AddExclExclCallFix(receiverExpression), receiverExpression.containingKtFile)
)
@@ -98,7 +99,7 @@ class PlatformExtensionReceiverOfInlineInspection : AbstractKotlinInspection() {
owner.namePattern = regexField.text
}
})
val labeledComponent = LabeledComponent.create(regexField, "Pattern:", BorderLayout.WEST)
val labeledComponent = LabeledComponent.create(regexField, KotlinBundle.message("text.pattern"), BorderLayout.WEST)
add(labeledComponent, BorderLayout.NORTH)
}
}
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.FileModificationService
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.implicitVisibility
import org.jetbrains.kotlin.idea.core.isInheritable
import org.jetbrains.kotlin.idea.intentions.isFinalizeMethod
@@ -33,7 +34,7 @@ class ProtectedInFinalInspection : AbstractKotlinInspection() {
) {
holder.registerProblem(
visibilityModifier,
"'protected' visibility is effectively 'private' in a final class",
KotlinBundle.message("protected.visibility.is.effectively.private.in.a.final.class"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
MakePrivateFix(),
MakeOpenFix()
@@ -44,7 +45,7 @@ class ProtectedInFinalInspection : AbstractKotlinInspection() {
}
class MakePrivateFix : LocalQuickFix {
override fun getName(): String = "Make private"
override fun getName(): String = KotlinBundle.message("make.private.fix.text")
override fun getFamilyName(): String = name
@@ -57,7 +58,7 @@ class ProtectedInFinalInspection : AbstractKotlinInspection() {
}
class MakeOpenFix : LocalQuickFix {
override fun getName(): String = "Make class open"
override fun getName(): String = KotlinBundle.message("make.open.fix.text")
override fun getFamilyName(): String = name
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel
import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.ExplicitApiMode
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.project.languageVersionSettings
import org.jetbrains.kotlin.resolve.checkers.ExplicitApiDeclarationChecker
@@ -30,15 +31,15 @@ class PublicApiImplicitTypeInspection(
override val problemText: String
get() {
return if (!reportInternal && !reportPrivate)
"For API stability, it's recommended to specify explicitly public & protected declaration types"
KotlinBundle.message("for.api.stability.it.s.recommended.to.specify.explicitly.public.protected.declaration.types")
else
"For API stability, it's recommended to specify explicitly declaration types"
KotlinBundle.message("for.api.stability.it.s.recommended.to.specify.explicitly.declaration.types")
}
override fun createOptionsPanel(): JComponent? {
val panel = MultipleCheckboxOptionsPanel(this)
panel.addCheckbox("Apply also to internal members", "reportInternal")
panel.addCheckbox("Apply also to private members", "reportPrivate")
panel.addCheckbox(KotlinBundle.message("apply.also.to.internal.members"), "reportInternal")
panel.addCheckbox(KotlinBundle.message("apply.also.to.private.members"), "reportPrivate")
return panel
}
}
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.isAnyEquals
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
@@ -44,7 +45,7 @@ class RecursiveEqualsCallInspection : AbstractKotlinInspection() {
private fun KtExpression.reportRecursiveEquals(invert: Boolean = false) {
holder.registerProblem(
this,
"Recursive equals call",
KotlinBundle.message("recursive.equals.call"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceWithReferentialEqualityFix(invert)
)
@@ -73,7 +74,7 @@ class RecursiveEqualsCallInspection : AbstractKotlinInspection() {
private class ReplaceWithReferentialEqualityFix(invert: Boolean) : LocalQuickFix {
private val operator = if (invert) "!==" else "==="
override fun getName() = "Replace with '$operator'"
override fun getName() = KotlinBundle.message("replace.with.0", operator)
override fun getFamilyName() = name
@@ -11,6 +11,7 @@ import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -28,14 +29,14 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() {
if (isRecursivePropertyAccess(expression)) {
holder.registerProblem(
expression,
"Recursive property accessor",
KotlinBundle.message("recursive.property.accessor"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceWithFieldFix()
)
} else if (isRecursiveSyntheticPropertyAccess(expression)) {
holder.registerProblem(
expression,
"Recursive synthetic property accessor",
KotlinBundle.message("recursive.synthetic.property.accessor"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
)
}
@@ -44,7 +45,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() {
class ReplaceWithFieldFix : LocalQuickFix {
override fun getName() = "Replace with 'field'"
override fun getName() = KotlinBundle.message("replace.with.field.fix.text")
override fun getFamilyName() = name
@@ -12,10 +12,10 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.analysis.analyzeAsReplacement
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.search.usagesSearch.descriptor
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.load.java.JvmAbi
@@ -41,7 +41,7 @@ class RedundantCompanionReferenceInspection : AbstractKotlinInspection() {
if (isRedundantCompanionReference(expression)) {
holder.registerProblem(
expression,
"Redundant Companion reference",
KotlinBundle.message("redundant.companion.reference"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveRedundantCompanionReferenceFix()
)
@@ -140,7 +140,7 @@ private fun CallableDescriptor.isLocalOrExtension(extensionClassDescriptor: Clas
}
class RemoveRedundantCompanionReferenceFix : LocalQuickFix {
override fun getName() = "Remove redundant Companion reference"
override fun getName() = KotlinBundle.message("remove.redundant.companion.reference.fix.text")
override fun getFamilyName() = name
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.formatter.adjustLineIndent
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isElseIf
@@ -34,7 +35,7 @@ class RedundantElseInIfInspection : AbstractKotlinInspection() {
holder.manager.createProblemDescriptor(
ifExpression,
rangeInElement,
"Redundant 'else'",
KotlinBundle.message("redundant.else"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly,
RemoveRedundantElseFix()
@@ -44,7 +45,7 @@ class RedundantElseInIfInspection : AbstractKotlinInspection() {
}
private class RemoveRedundantElseFix : LocalQuickFix {
override fun getName() = "Remove redundant 'else'"
override fun getName() = KotlinBundle.message("remove.redundant.else.fix.text")
override fun getFamilyName() = name
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.kotlin.psi.KtClassInitializer
import org.jetbrains.kotlin.psi.classInitializerVisitor
@@ -20,14 +21,14 @@ class RedundantEmptyInitializerBlockInspection : AbstractKotlinInspection() {
if (body.statements.isNotEmpty()) return
holder.registerProblem(
initializer,
"Redundant empty initializer block",
KotlinBundle.message("redundant.empty.initializer.block"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveInitializerBlockFix()
)
})
private class RemoveInitializerBlockFix : LocalQuickFix {
override fun getName() = "Remove initializer block"
override fun getName() = KotlinBundle.message("remove.initializer.block.fix.text")
override fun getFamilyName() = name
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.KtEnumEntry
import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry
@@ -25,7 +26,7 @@ class RedundantEnumConstructorInvocationInspection : AbstractKotlinInspection()
val valueArgumentList = enumEntry.valueArgumentListIfEmpty() ?: return
holder.registerProblem(
valueArgumentList,
"Redundant enum constructor invocation",
KotlinBundle.message("redundant.enum.constructor.invocation"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveEnumConstructorInvocationFix()
)
@@ -33,7 +34,7 @@ class RedundantEnumConstructorInvocationInspection : AbstractKotlinInspection()
}
private class RemoveEnumConstructorInvocationFix : LocalQuickFix {
override fun getName() = "Remove enum constructor invocation"
override fun getName() = KotlinBundle.message("remove.enum.constructor.invocation.fix.text")
override fun getFamilyName() = name
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeIntention
import org.jetbrains.kotlin.psi.*
@@ -22,7 +23,7 @@ class RedundantExplicitTypeInspection : AbstractKotlinInspection() {
if (hasRedundantType(property)) {
holder.registerProblem(
typeReference,
"Explicitly given type is redundant here",
KotlinBundle.message("explicitly.given.type.is.redundant.here"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(RemoveExplicitTypeIntention(), property.containingKtFile)
)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
@@ -21,7 +22,7 @@ class RedundantGetterInspection : AbstractKotlinInspection(), CleanupLocalInspec
if (accessor.isRedundantGetter()) {
holder.registerProblem(
accessor,
"Redundant getter",
KotlinBundle.message("redundant.getter"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
rangeInElement,
RemoveRedundantGetterFix()
@@ -62,7 +63,7 @@ fun KtPropertyAccessor.deleteBody() {
}
class RemoveRedundantGetterFix : LocalQuickFix {
override fun getName() = "Remove redundant getter"
override fun getName() = KotlinBundle.message("remove.redundant.getter.fix.text")
override fun getFamilyName() = name
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.CodeInsightUtil
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.negate
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -23,7 +24,7 @@ class RedundantIfInspection : AbstractKotlinInspection(), CleanupLocalInspection
holder.registerProblem(
expression,
"Redundant 'if' statement",
KotlinBundle.message("redundant.if.statement"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
RemoveRedundantIf(redundancyType, branchType)
)
@@ -81,7 +82,7 @@ class RedundantIfInspection : AbstractKotlinInspection(), CleanupLocalInspection
}
private class RemoveRedundantIf(private val redundancyType: RedundancyType, private val branchType: BranchType) : LocalQuickFix {
override fun getName() = "Remove redundant 'if' statement"
override fun getName() = KotlinBundle.message("remove.redundant.if.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -14,6 +14,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.refactoring.replaceWithCopyWithResolveCheck
@@ -68,7 +69,7 @@ class RedundantLambdaArrowInspection : AbstractKotlinInspection() {
holder.manager.createProblemDescriptor(
functionLiteral,
TextRange((singleParameter?.startOffset ?: arrow.startOffset) - startOffset, arrow.endOffset - startOffset),
"Redundant lambda arrow",
KotlinBundle.message("redundant.lambda.arrow"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
isOnTheFly,
DeleteFix()
@@ -78,7 +79,7 @@ class RedundantLambdaArrowInspection : AbstractKotlinInspection() {
}
class DeleteFix : LocalQuickFix {
override fun getFamilyName() = "Remove arrow"
override fun getFamilyName() = KotlinBundle.message("delete.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val element = descriptor.psiElement as? KtFunctionLiteral ?: return
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
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.intentions.*
@@ -28,11 +29,11 @@ import org.jetbrains.kotlin.types.isNullable
abstract class RedundantLetInspection : AbstractApplicabilityBasedInspection<KtCallExpression>(
KtCallExpression::class.java
) {
override fun inspectionText(element: KtCallExpression) = "Redundant `let` call could be removed"
override fun inspectionText(element: KtCallExpression) = KotlinBundle.message("redundant.let.call.could.be.removed")
final override fun inspectionHighlightRangeInElement(element: KtCallExpression) = element.calleeExpression?.textRangeIn(element)
final override val defaultFixText = "Remove `let` call"
final override val defaultFixText = KotlinBundle.message("remove.let.call")
final override fun isApplicable(element: KtCallExpression): Boolean {
if (!element.isLetMethodCall()) return false
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.*
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.implicitModality
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
import org.jetbrains.kotlin.psi.declarationVisitor
@@ -23,7 +24,7 @@ class RedundantModalityModifierInspection : AbstractKotlinInspection(), CleanupL
holder.registerProblem(
modalityModifier,
"Redundant modality modifier",
KotlinBundle.message("redundant.modality.modifier"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(
RemoveModifierFix(declaration, implicitModality, isRedundant = true),
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.project.languageVersionSettings
import org.jetbrains.kotlin.lexer.KtTokens
@@ -106,7 +107,7 @@ class RedundantNotNullExtensionReceiverOfInlineInspection : AbstractKotlinInspec
holder.registerProblem(
receiverTypeReference,
"This type probably can be changed to nullable",
KotlinBundle.message("this.type.probably.can.be.changed.to.nullable"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
)
})
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
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
@@ -41,7 +42,7 @@ class RedundantObjectTypeCheckInspection : AbstractKotlinInspection() {
holder.registerProblem(
expression.operationReference,
TextRange(0, if (expression.isNegated) 3 else 2),
"Redundant type checks for object",
KotlinBundle.message("redundant.type.checks.for.object"),
ReplaceWithEqualityFix(expression.isNegated)
)
}
@@ -60,7 +61,7 @@ private class ReplaceWithEqualityFix(isNegated: Boolean) : LocalQuickFix {
private val equality = if (isNegated) "!==" else "==="
override fun getName() = "Replace '$isOperator' with '$equality'"
override fun getName() = KotlinBundle.message("replace.with.equality.fix.text", isOperator, equality)
override fun getFamilyName() = name
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
@@ -47,7 +48,7 @@ class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
val functionName = callee.text
holder.registerProblem(
callee,
"Redundant '$functionName' call",
KotlinBundle.message("redundant.0.call", functionName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
RemoveRequireNotNullCallFix(functionName)
)
@@ -63,7 +64,7 @@ class RedundantRequireNotNullCallInspection : AbstractKotlinInspection() {
}
private class RemoveRequireNotNullCallFix(private val functionName: String) : LocalQuickFix {
override fun getName() = "Remove '$functionName' call"
override fun getName() = KotlinBundle.message("remove.require.not.null.call.fix.text", functionName)
override fun getFamilyName() = name
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.IntentionWrapper
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.quickfix.RemoveReturnLabelFix
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.kotlin.psi.KtNamedFunction
@@ -24,7 +25,7 @@ class RedundantReturnLabelInspection : AbstractKotlinInspection() {
val labelName = label.getReferencedName()
holder.registerProblem(
label,
"Redundant '@$labelName'",
KotlinBundle.message("redundant.0", labelName),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(RemoveReturnLabelFix(returnExpression, labelName), returnExpression.containingKtFile),
)
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.codegen.SamCodegenUtil
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.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.project.languageVersionSettings
@@ -36,7 +37,8 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.sam.SamConversionOracle
import org.jetbrains.kotlin.resolve.sam.SamConversionResolver
import org.jetbrains.kotlin.resolve.sam.getFunctionTypeForPossibleSamType
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.isNullable
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
@@ -53,7 +55,7 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
val problemDescriptor = holder.manager.createProblemDescriptor(
single.getQualifiedExpressionForSelector()?.receiverExpression ?: calleeExpression,
single.typeArgumentList ?: calleeExpression,
"Redundant SAM-constructor",
KotlinBundle.message("redundant.sam.constructor"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
isOnTheFly,
createQuickFix(single)
@@ -63,7 +65,7 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
} else {
val problemDescriptor = holder.manager.createProblemDescriptor(
expression.valueArgumentList!!,
"Redundant SAM-constructors",
KotlinBundle.message("redundant.sam.constructors"),
createQuickFix(samConstructorCalls),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly
@@ -76,7 +78,7 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
private fun createQuickFix(expression: KtCallExpression): LocalQuickFix {
return object : LocalQuickFix {
override fun getName() = "Remove redundant SAM-constructor"
override fun getName() = KotlinBundle.message("remove.redundant.sam.constructor")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
if (!FileModificationService.getInstance().preparePsiElementForWrite(expression)) return
@@ -87,7 +89,7 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
private fun createQuickFix(expressions: Collection<KtCallExpression>): LocalQuickFix {
return object : LocalQuickFix {
override fun getName() = "Remove redundant SAM-constructors"
override fun getName() = KotlinBundle.message("remove.redundant.sam.constructors")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
for (callExpression in expressions) {
@@ -13,6 +13,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.PsiWhiteSpace
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.util.isLineBreak
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
@@ -30,7 +31,7 @@ class RedundantSemicolonInspection : AbstractKotlinInspection(), CleanupLocalIns
if (element.node.elementType == KtTokens.SEMICOLON && isRedundantSemicolon(element)) {
holder.registerProblem(
element,
"Redundant semicolon",
KotlinBundle.message("redundant.semicolon"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
Fix
)
@@ -110,7 +111,7 @@ class RedundantSemicolonInspection : AbstractKotlinInspection(), CleanupLocalIns
}
private object Fix : LocalQuickFix {
override fun getName() = "Remove redundant semicolon"
override fun getName() = KotlinBundle.message("fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -20,7 +21,7 @@ class RedundantSetterInspection : AbstractKotlinInspection(), CleanupLocalInspec
if (accessor.isRedundantSetter()) {
holder.registerProblem(
accessor,
"Redundant setter",
KotlinBundle.message("redundant.setter"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
rangeInElement,
RemoveRedundantSetterFix()
@@ -46,7 +47,7 @@ fun KtPropertyAccessor.isRedundantSetter(): Boolean {
class RemoveRedundantSetterFix : LocalQuickFix {
override fun getName() = "Remove redundant setter"
override fun getName() = KotlinBundle.message("remove.redundant.setter.fix.text")
override fun getFamilyName() = name
@@ -12,6 +12,7 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.highlighter.hasSuspendCalls
import org.jetbrains.kotlin.idea.project.languageVersionSettings
@@ -41,7 +42,7 @@ class RedundantSuspendModifierInspection : AbstractKotlinInspection() {
holder.registerProblem(
suspendModifier,
"Redundant 'suspend' modifier",
KotlinBundle.message("redundant.suspend.modifier"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(
RemoveModifierFix(function, KtTokens.SUSPEND_KEYWORD, isRedundant = true),
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.intentions.loopToCallChain.previousStatement
@@ -31,7 +32,7 @@ class RedundantUnitExpressionInspection : AbstractKotlinInspection(), CleanupLoc
if (expression.isRedundantUnit()) {
holder.registerProblem(
expression,
"Redundant 'Unit'",
KotlinBundle.message("redundant.unit"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveRedundantUnitFix()
)
@@ -84,7 +85,7 @@ private fun KtReturnExpression.expectedReturnType(): KotlinType? {
}
private class RemoveRedundantUnitFix : LocalQuickFix {
override fun getName() = "Remove redundant 'Unit'"
override fun getName() = KotlinBundle.message("remove.redundant.unit.fix.text")
override fun getFamilyName() = name
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.IntentionWrapper
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeIntention
import org.jetbrains.kotlin.psi.KtCodeFragment
@@ -25,7 +26,7 @@ class RedundantUnitReturnTypeInspection : AbstractKotlinInspection(), CleanupLoc
if (hasRedundantUnitReturnType(function)) {
holder.registerProblem(
typeElement,
"Redundant 'Unit' return type",
KotlinBundle.message("redundant.unit.return.type"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(RemoveExplicitTypeIntention(), function.containingKtFile)
)
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.config.ExplicitApiMode
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.implicitVisibility
import org.jetbrains.kotlin.idea.project.languageVersionSettings
@@ -60,7 +61,7 @@ class RedundantVisibilityModifierInspection : AbstractKotlinInspection(), Cleanu
holder.registerProblem(
visibilityModifier,
"Redundant visibility modifier",
KotlinBundle.message("redundant.visibility.modifier"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(
RemoveModifierFix(declaration, redundantVisibility, isRedundant = true),
@@ -11,6 +11,7 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.moveCaret
import org.jetbrains.kotlin.idea.core.replaced
@@ -66,7 +67,7 @@ class RedundantWithInspection : AbstractKotlinInspection() {
}
holder.registerProblem(
callee,
"Redundant 'with' call",
KotlinBundle.message("redundant.with.call"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
quickfix
)
@@ -78,7 +79,7 @@ private fun KtValueArgument.lambdaExpression(): KtLambdaExpression? =
(this as? KtLambdaArgument)?.getLambdaExpression() ?: this.getArgumentExpression() as? KtLambdaExpression
private class RemoveRedundantWithFix : LocalQuickFix {
override fun getName() = "Remove redundant 'with' call"
override fun getName() = KotlinBundle.message("remove.redundant.with.fix.text")
override fun getFamilyName() = name
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.codeStyle.CodeStyleManager
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.formatter.FormattingChange
import org.jetbrains.kotlin.idea.formatter.FormattingChange.ReplaceWhiteSpace
import org.jetbrains.kotlin.idea.formatter.FormattingChange.ShiftIndentInsideRange
@@ -71,7 +72,7 @@ class ReformatInspection : LocalInspectionTool() {
return elements.map {
ProblemDescriptorImpl(
it, it,
"File is not properly formatted",
KotlinBundle.message("file.is.not.properly.formatted"),
arrayOf(ReformatQuickFix),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null,
isOnTheFly
@@ -81,7 +82,7 @@ class ReformatInspection : LocalInspectionTool() {
override fun createOptionsPanel(): JComponent? {
return SingleCheckboxOptionsPanel(
"Apply only to modified files (for projects under a version control)",
KotlinBundle.message("apply.only.to.modified.files.for.projects.under.a.version.control"),
this,
"processChangedFilesOnly"
)
@@ -98,7 +99,7 @@ class ReformatInspection : LocalInspectionTool() {
}
private object ReformatQuickFix : LocalQuickFix {
override fun getFamilyName(): String = "Reformat File"
override fun getFamilyName(): String = KotlinBundle.message("reformat.quick.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
CodeStyleManager.getInstance(project).reformat(descriptor.psiElement.containingFile)
}
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
import org.jetbrains.kotlin.psi.KtAnnotationEntry
@@ -27,7 +28,7 @@ class RemoveAnnotationFix(private val text: String, annotationEntry: KtAnnotatio
object JvmOverloads : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): RemoveAnnotationFix? {
val annotationEntry = diagnostic.psiElement as? KtAnnotationEntry ?: return null
return RemoveAnnotationFix("Remove @JvmOverloads annotation", annotationEntry)
return RemoveAnnotationFix(KotlinBundle.message("remove.jvmoverloads.annotation"), annotationEntry)
}
}
@@ -10,19 +10,21 @@ import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.canDropBraces
import org.jetbrains.kotlin.idea.core.dropBraces
import org.jetbrains.kotlin.psi.KtBlockStringTemplateEntry
class RemoveCurlyBracesFromTemplateInspection(@JvmField var reportWithoutWhitespace: Boolean = false) :
AbstractApplicabilityBasedInspection<KtBlockStringTemplateEntry>(KtBlockStringTemplateEntry::class.java) {
override fun inspectionText(element: KtBlockStringTemplateEntry): String = "Redundant curly braces in string template"
override fun inspectionText(element: KtBlockStringTemplateEntry): String =
KotlinBundle.message("redundant.curly.braces.in.string.template")
override fun inspectionHighlightType(element: KtBlockStringTemplateEntry) =
if (reportWithoutWhitespace || element.hasWhitespaceAround()) ProblemHighlightType.GENERIC_ERROR_OR_WARNING
else ProblemHighlightType.INFORMATION
override val defaultFixText: String = "Remove curly braces"
override val defaultFixText: String = KotlinBundle.message("remove.curly.braces")
override fun isApplicable(element: KtBlockStringTemplateEntry): Boolean = element.canDropBraces()
@@ -31,7 +33,7 @@ class RemoveCurlyBracesFromTemplateInspection(@JvmField var reportWithoutWhitesp
}
override fun createOptionsPanel() = MultipleCheckboxOptionsPanel(this).apply {
addCheckbox("Report also for a variables without a whitespace around", "reportWithoutWhitespace")
addCheckbox(KotlinBundle.message("report.also.for.a.variables.without.a.whitespace.around"), "reportWithoutWhitespace")
}
}
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtValueArgumentList
@@ -37,7 +38,7 @@ class RemoveEmptyParenthesesFromAnnotationEntryInspection : AbstractKotlinInspec
holder.registerProblem(
list,
"Parentheses should be removed",
KotlinBundle.message("parentheses.should.be.removed"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveEmptyParenthesesFromAnnotationEntryFix()
)
@@ -54,7 +55,7 @@ class RemoveEmptyParenthesesFromAnnotationEntryInspection : AbstractKotlinInspec
private class RemoveEmptyParenthesesFromAnnotationEntryFix : LocalQuickFix {
override fun getName() = "Remove unnecessary parentheses"
override fun getName() = KotlinBundle.message("remove.empty.parentheses.from.annotation.entry.fix.text")
override fun getFamilyName() = name
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.impl.source.tree.SharedImplUtil
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.unquote
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtElement
@@ -59,7 +60,7 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
private fun registerProblem(holder: ProblemsHolder, element: PsiElement) {
holder.registerProblem(
element,
"Remove redundant backticks",
KotlinBundle.message("remove.redundant.backticks.quick.fix.text"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
RemoveRedundantBackticksQuickFix()
)
@@ -67,7 +68,7 @@ class RemoveRedundantBackticksInspection : AbstractKotlinInspection() {
}
class RemoveRedundantBackticksQuickFix : LocalQuickFix {
override fun getName() = "Remove redundant backticks"
override fun getName() = KotlinBundle.message("remove.redundant.backticks.quick.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -11,6 +11,7 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.analysis.analyzeAsReplacement
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.ShortenReferences
@@ -145,7 +146,7 @@ private fun reportProblem(holder: ProblemsHolder, element: KtElement) {
val firstChild = element.firstChild
holder.registerProblem(
element,
"Redundant qualifier name",
KotlinBundle.message("redundant.qualifier.name"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
TextRange.from(firstChild.startOffsetInParent, firstChild.textLength + 1),
RemoveRedundantQualifierNameQuickFix()
@@ -153,7 +154,7 @@ private fun reportProblem(holder: ProblemsHolder, element: KtElement) {
}
class RemoveRedundantQualifierNameQuickFix : LocalQuickFix {
override fun getName() = "Remove redundant qualifier name"
override fun getName() = KotlinBundle.message("remove.redundant.qualifier.name.quick.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -12,6 +12,7 @@ import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.isArrayOfMethod
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.endOffset
@@ -39,7 +40,7 @@ class RemoveRedundantSpreadOperatorInspection : AbstractKotlinInspection() {
val problemDescriptor = holder.manager.createProblemDescriptor(
argument,
TextRange(startOffset, endOffset),
"Remove redundant spread operator",
KotlinBundle.message("remove.redundant.spread.operator.quickfix.text"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
isOnTheFly,
RemoveRedundantSpreadOperatorQuickfix()
@@ -50,7 +51,7 @@ class RemoveRedundantSpreadOperatorInspection : AbstractKotlinInspection() {
}
class RemoveRedundantSpreadOperatorQuickfix : LocalQuickFix {
override fun getName() = "Remove redundant spread operator"
override fun getName() = KotlinBundle.message("remove.redundant.spread.operator.quickfix.text")
override fun getFamilyName() = name
@@ -9,6 +9,7 @@ import com.intellij.codeInspection.IntentionWrapper
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeIntention
import org.jetbrains.kotlin.idea.intentions.isSetterParameter
import org.jetbrains.kotlin.psi.parameterVisitor
@@ -23,7 +24,7 @@ class RemoveSetterParameterTypeInspection : AbstractKotlinInspection() {
?.takeIf { it.endOffset > it.startOffset } ?: return@parameterVisitor
holder.registerProblem(
typeReference,
"Redundant setter parameter type",
KotlinBundle.message("redundant.setter.parameter.type"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
IntentionWrapper(RemoveExplicitTypeIntention(), parameter.containingKtFile)
)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.inspections
import com.intellij.codeInsight.FileModificationService
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.isToString
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.canPlaceAfterSimpleNameEntry
@@ -22,7 +23,7 @@ class RemoveToStringInStringTemplateInspection : AbstractKotlinInspection(), Cle
holder.registerProblem(
selectorExpression,
"Redundant 'toString()' call in string template",
KotlinBundle.message("redundant.tostring.call.in.string.template"),
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
RemoveToStringFix()
)
@@ -30,7 +31,7 @@ class RemoveToStringInStringTemplateInspection : AbstractKotlinInspection(), Cle
}
class RemoveToStringFix : LocalQuickFix {
override fun getName() = "Remove 'toString()' call"
override fun getName() = KotlinBundle.message("remove.to.string.fix.text")
override fun getFamilyName() = name
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.inspections
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.intentions.resolvedToArrayType
import org.jetbrains.kotlin.lexer.KtTokens
@@ -55,14 +56,14 @@ class ReplaceArrayEqualityOpWithArraysEqualsInspection : AbstractApplicabilityBa
return rightResolvedCall?.resolvedToArrayType() == true && leftResolvedCall?.resolvedToArrayType() == true
}
override fun inspectionText(element: KtBinaryExpression) = "Dangerous array comparison"
override fun inspectionText(element: KtBinaryExpression) = KotlinBundle.message("dangerous.array.comparison")
override val defaultFixText: String
get() = "Replace with 'contentEquals'"
get() = KotlinBundle.message("replace.with.contentequals3")
override fun fixText(element: KtBinaryExpression): String = when (element.operationToken) {
KtTokens.EQEQ -> "Replace '==' with 'contentEquals'"
KtTokens.EXCLEQ -> "Replace '!=' with 'contentEquals'"
KtTokens.EQEQ -> KotlinBundle.message("replace.with.contentequals2")
KtTokens.EXCLEQ -> KotlinBundle.message("replace.with.contentequals")
else -> ""
}
}
@@ -13,6 +13,7 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.config.LanguageFeature.ArrayLiteralsInAnnotations
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.isArrayOfMethod
import org.jetbrains.kotlin.idea.project.languageVersionSettings
import org.jetbrains.kotlin.psi.*
@@ -44,14 +45,14 @@ class ReplaceArrayOfWithLiteralInspection : AbstractKotlinInspection() {
val calleeName = calleeExpression.getReferencedName()
holder.registerProblem(
calleeExpression,
"'$calleeName' call should be replaced with array literal [...]",
KotlinBundle.message("0.call.should.be.replaced.with.array.literal", calleeName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
ReplaceWithArrayLiteralFix()
)
})
private class ReplaceWithArrayLiteralFix : LocalQuickFix {
override fun getFamilyName() = "Replace with [...]"
override fun getFamilyName() = KotlinBundle.message("replace.with.array.literal.fix.family.name")
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val calleeExpression = descriptor.psiElement as KtExpression
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.actions.OptimizeImportsProcessor
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.CallableDescriptor
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
@@ -25,13 +26,13 @@ import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
class ReplaceAssertBooleanWithAssertEqualityInspection : AbstractApplicabilityBasedInspection<KtCallExpression>(
KtCallExpression::class.java
) {
override fun inspectionText(element: KtCallExpression) = "Replace assert boolean with assert equality"
override fun inspectionText(element: KtCallExpression) = KotlinBundle.message("replace.assert.boolean.with.assert.equality")
override val defaultFixText = "Replace assert boolean with assert equality"
override val defaultFixText = KotlinBundle.message("replace.assert.boolean.with.assert.equality")
override fun fixText(element: KtCallExpression): String {
val assertion = element.replaceableAssertion() ?: return defaultFixText
return "Replace with '$assertion'"
return KotlinBundle.message("replace.with.0", assertion)
}
override fun isApplicable(element: KtCallExpression): Boolean {
@@ -14,6 +14,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.getLastLambdaExpression
import org.jetbrains.kotlin.idea.inspections.AssociateFunction.*
@@ -70,7 +71,7 @@ class ReplaceAssociateFunctionInspection : AbstractKotlinInspection() {
}
holder.registerProblemWithoutOfflineInformation(
calleeExpression,
"Replace '${calleeExpression.text}' with '${associateFunction.name(isAssociateTo)}'",
KotlinBundle.message("replace.0.with.1", calleeExpression.text, associateFunction.name(isAssociateTo)),
isOnTheFly,
highlightType,
ReplaceAssociateFunctionFix(associateFunction, isAssociateTo)
@@ -85,7 +86,7 @@ class ReplaceAssociateFunctionInspection : AbstractKotlinInspection() {
private class ReplaceAssociateFunctionFix(private val function: AssociateFunction, private val hasDestination: Boolean) : LocalQuickFix {
private val functionName = function.name(hasDestination)
override fun getName() = "Replace with '$functionName'"
override fun getName() = KotlinBundle.message("replace.with.0", functionName)
override fun getFamilyName() = name
@@ -10,6 +10,7 @@ import com.intellij.codeInspection.ProblemDescriptor
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.inspections.collections.isCalling
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtCallExpression
@@ -22,7 +23,7 @@ class ReplaceCollectionCountWithSizeInspection : AbstractKotlinInspection() {
if (callExpression.isCount()) {
holder.registerProblem(
callExpression,
"Could be replaced with `size`",
KotlinBundle.message("could.be.replaced.with.size"),
ReplaceCollectionCountWithSizeQuickFix()
)
}
@@ -31,7 +32,7 @@ class ReplaceCollectionCountWithSizeInspection : AbstractKotlinInspection() {
}
class ReplaceCollectionCountWithSizeQuickFix : LocalQuickFix {
override fun getName() = "Replace 'count' with 'size'"
override fun getName() = KotlinBundle.message("replace.collection.count.with.size.quick.fix.text")
override fun getFamilyName() = name
@@ -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.config.LanguageFeature
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
@@ -42,12 +43,12 @@ class ReplaceGuardClauseWithFunctionCallInspection : AbstractApplicabilityBasedI
get() = "kotlin.$functionName"
}
override fun inspectionText(element: KtIfExpression) = "Replace guard clause with kotlin's function call"
override fun inspectionText(element: KtIfExpression) = KotlinBundle.message("replace.guard.clause.with.kotlin.s.function.call")
override val defaultFixText = "Replace with kotlin's function call"
override val defaultFixText = KotlinBundle.message("replace.with.kotlin.s.function.call")
override fun fixText(element: KtIfExpression) =
element.getKotlinFunction()?.let { "Replace with '${it.functionName}()' call" } ?: defaultFixText
element.getKotlinFunction()?.let { KotlinBundle.message("replace.with.0.call", it.functionName) } ?: defaultFixText
override fun inspectionHighlightRangeInElement(element: KtIfExpression) = element.ifKeyword.textRangeIn(element)

Some files were not shown because too many files have changed in this diff Show More