mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
Java: introduce another visitSwitchBlock() method
GitOrigin-RevId: 97f3edcab34837c124e1426d97a6d6590e67a053
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7e0038ce14
commit
9eb3b6bb58
@@ -213,27 +213,26 @@ public class EqualsWhichDoesntCheckParameterClassInspection extends BaseInspecti
|
||||
@Override
|
||||
public void visitSwitchExpression(@NotNull PsiSwitchExpression expression) {
|
||||
super.visitSwitchExpression(expression);
|
||||
if (isParameterReference(expression.getExpression()) && checksTypeOfExpression(expression)) {
|
||||
makeChecked();
|
||||
}
|
||||
visitSwitchBlock(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) {
|
||||
super.visitSwitchStatement(statement);
|
||||
if (isParameterReference(statement.getExpression()) && checksTypeOfExpression(statement)) {
|
||||
makeChecked();
|
||||
}
|
||||
visitSwitchBlock(statement);
|
||||
}
|
||||
|
||||
private static boolean checksTypeOfExpression(@NotNull PsiSwitchBlock switchBlock) {
|
||||
private void visitSwitchBlock(@NotNull PsiSwitchBlock switchBlock) {
|
||||
if (!isParameterReference(switchBlock.getExpression())) return;
|
||||
PsiCodeBlock body = switchBlock.getBody();
|
||||
return body != null && PsiTreeUtil.getChildrenOfTypeAsList(body, PsiSwitchLabelStatementBase.class)
|
||||
if (body == null) return;
|
||||
boolean checksType = PsiTreeUtil.getChildrenOfTypeAsList(body, PsiSwitchLabelStatementBase.class)
|
||||
.stream()
|
||||
.map(PsiSwitchLabelStatementBase::getCaseLabelElementList)
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(list -> Arrays.stream(list.getElements()))
|
||||
.anyMatch(element -> element instanceof PsiTypeTestPattern);
|
||||
if (checksType) makeChecked();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user