Java: enable "Record pattern can be used" by default at warning level (IDEA-359690)

and make it a cleanup tool.

GitOrigin-RevId: 3bb400491d44ab901660d900c6ce73e76bdf6261
This commit is contained in:
Bas Leijdekkers
2024-09-25 10:42:46 +02:00
committed by intellij-monorepo-bot
parent 7fbe663b37
commit d74484e368
3 changed files with 15 additions and 15 deletions

View File

@@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
public final class DeconstructionCanBeUsedInspection extends AbstractBaseJavaLocalInspectionTool {
public final class DeconstructionCanBeUsedInspection extends AbstractBaseJavaLocalInspectionTool implements CleanupLocalInspectionTool {
@Override
public @NotNull Set<@NotNull JavaFeature> requiredFeatures() {

View File

@@ -2761,10 +2761,10 @@
groupBundle="messages.InspectionsBundle" groupKey="group.names.language.level.specific.issues.and.migration.aids"
implementationClass="com.intellij.codeInspection.ForEachWithRecordPatternCanBeUsedInspection" cleanupTool="true"/>
<localInspection groupPathKey="group.path.names.java.language.level.specific.issues.and.migration.aids" language="JAVA"
shortName="DeconstructionCanBeUsed" enabledByDefault="false" level="INFORMATION"
shortName="DeconstructionCanBeUsed" enabledByDefault="true" level="WARNING"
bundle="messages.InspectionGadgetsBundle" key="inspection.deconstruction.can.be.used.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.language.level.specific.issues.and.migration.aids21"
implementationClass="com.intellij.codeInspection.DeconstructionCanBeUsedInspection" cleanupTool="false"/>
implementationClass="com.intellij.codeInspection.DeconstructionCanBeUsedInspection" cleanupTool="true"/>
<localInspection groupPath="Java" language="JAVA" shortName="CastCanBeReplacedWithVariable" enabledByDefault="true" level="INFORMATION"
bundle="messages.InspectionGadgetsBundle" key="inspection.cast.can.be.replaced.with.variable.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.verbose.or.redundant.code.constructs"

View File

@@ -3,23 +3,23 @@
Reports patterns that can be replaced with record patterns.
<p>Example:</p>
<pre><code>
record Point(int x, int y) {}
static void printSum(Object obj) {
if (obj instanceof Point p) {
int x = p.x();
int y = p.y();
System.out.println(x + y);
record Point(int x, int y) {
static void printSum(Object obj) {
if (obj instanceof Point p) {
int x = p.x();
int y = p.y();
System.out.println(x + y);
}
}
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
record Point(int x, int y) {}
static void printSum(Object obj) {
if (obj instanceof Point(int x, int y)) {
System.out.println(x + y);
record Point(int x, int y) {
static void printSum(Object obj) {
if (obj instanceof Point(int x, int y)) {
System.out.println(x + y);
}
}
}
</code></pre>