mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] Use JavaPsiSwitchUtil.isBooleanSwitchWithTrueAndFalse
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only) GitOrigin-RevId: bde4078ac2d09977730c7803a3565c9bbe683a06
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a7bdd63a2e
commit
b3b3fcf587
@@ -315,9 +315,18 @@ public final class JavaPsiSwitchUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasTrueAndFalse(@NotNull PsiSwitchBlock block) {
|
||||
/**
|
||||
* @param block block to check
|
||||
* @return true if this switch block is a boolean switch that contains both true and false branches.
|
||||
* All unrelated branches or duplicate branches are ignored.
|
||||
*/
|
||||
public static boolean isBooleanSwitchWithTrueAndFalse(@NotNull PsiSwitchBlock block) {
|
||||
PsiCodeBlock body = block.getBody();
|
||||
if (body == null) return false;
|
||||
PsiExpression selector = block.getExpression();
|
||||
if (selector == null) return false;
|
||||
PsiType selectorType = selector.getType();
|
||||
if (selectorType == null || getSwitchSelectorKind(selector.getType()) != SelectorKind.BOOLEAN) return false;
|
||||
|
||||
PsiConstantEvaluationHelper helper = JavaPsiFacade.getInstance(block.getProject()).getConstantEvaluationHelper();
|
||||
boolean hasTrue = false, hasFalse = false;
|
||||
|
||||
Reference in New Issue
Block a user