mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] SwitchStatementWithTooFewBranches: description updated, serialization fixed
GitOrigin-RevId: 456b695eebd902ca48cb6fb2102b1450d9aa7902
This commit is contained in:
committed by
intellij-monorepo-bot
parent
39a4c61fad
commit
83e613fa2f
+7
-3
@@ -20,9 +20,7 @@ import com.intellij.codeInsight.daemon.impl.quickfix.UnwrapSwitchLabelFix;
|
||||
import com.intellij.codeInspection.CommonQuickFixBundle;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.SetInspectionOptionFix;
|
||||
import com.intellij.codeInspection.ui.InspectionOptionsPanel;
|
||||
import com.intellij.codeInspection.ui.SingleIntegerFieldOptionsPanel;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -33,7 +31,7 @@ import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.DelegatingFix;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.SwitchUtils;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -94,6 +92,12 @@ public class SwitchStatementWithTooFewBranchesInspection extends BaseInspection
|
||||
return fixes.toArray(InspectionGadgetsFix.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSettings(@NotNull Element node) {
|
||||
defaultWriteSettings(node, "ignorePatternSwitch");
|
||||
writeBooleanOption(node, "ignorePatternSwitch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new MinimumSwitchBranchesVisitor();
|
||||
|
||||
+9
@@ -21,5 +21,14 @@ and
|
||||
<!-- tooltip end -->
|
||||
<p>Configure the inspection:</p>
|
||||
<p>Use the <b>Minimum number of branches</b> field to specify the minimum expected number of <code>case</code> labels.</p>
|
||||
<p>Use the <b>Do not report pattern switch statements</b> option to avoid reporting switch statements and expressions that
|
||||
have pattern branches. E.g.:</p>
|
||||
<pre><code>
|
||||
String result = switch(obj) {
|
||||
case String str -> str.trim();
|
||||
default -> "none";
|
||||
};
|
||||
</code></pre>
|
||||
<p>It might be preferred to keep the switch even with a single pattern branch, rather than using the <code>instanceof</code> statement.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user