mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
[java-inspections] SwitchStatementWithTooFewBranches: provide quick-fix "Unwrap 'switch'" in case default label element
IDEA-274278 GitOrigin-RevId: 97c04cf69e8bffbc1be2d2fd1f6dfae05bd6c986
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3a9a706530
commit
c6016b645e
@@ -0,0 +1,6 @@
|
||||
// "Unwrap 'switch'" "true"
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
int answer = 42;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Unwrap 'switch'" "true"
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
int answer = sw<caret>itch (obj) {
|
||||
case default -> 42;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class SwitchStatementWithTooFewBranchesInspection extends BaseInspection
|
||||
PsiStatement[] statements = body.getStatements();
|
||||
if (statements.length == 1 && statements[0] instanceof PsiSwitchLabeledRuleStatement) {
|
||||
PsiSwitchLabeledRuleStatement statement = (PsiSwitchLabeledRuleStatement)statements[0];
|
||||
fixIsAvailable = statement.isDefaultCase() && statement.getBody() instanceof PsiExpressionStatement;
|
||||
fixIsAvailable = SwitchUtils.isDefaultLabel(statement) && statement.getBody() instanceof PsiExpressionStatement;
|
||||
}
|
||||
else {
|
||||
fixIsAvailable = false;
|
||||
|
||||
Reference in New Issue
Block a user