ConditionState (PsiInstanceOfExpression expression, PsiExpression condition) { if (!(condition != null && PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class, PsiPrefixExpression.class, PsiPolyadicExpression.class) == condition.getParent())) { return ConditionState.UNKNOWN; } PsiElement current = expression.getParent(); boolean currentState = true; while (current != condition.getParent()) { if (current instanceof PsiParenthesizedExpression) { current = current.getParent(); continue; } if (current instanceof PsiPrefixExpression prefixExpression) { if (!prefixExpression.getOperationTokenType().equals(JavaTokenType.EXCL)) { return ConditionState.UNKNOWN; } currentState = !currentState; current = current.getParent(); continue; } if (current instanceof PsiPolyadicExpression polyadicExpression) { IElementType tokenType = polyadicExpression.getOperationTokenType(); if (tokenType.equals(JavaTokenType.ANDAND) && currentState) { current = current.getParent(); continue; } if (tokenType.equals(JavaTokenType.OROR) && !currentState) { current = current.getParent(); continue; } return ConditionState.UNKNOWN; } } return currentState ? ConditionState.TRUE : ConditionState.FALSE; }