boolean (@NotNull PsiExpression expression, boolean isAnd) { PsiLocalVariable local = ExpressionUtils.resolveLocalVariable(expression); if (local == null) return false; PsiExpression initializer = local.getInitializer(); if (!ExpressionUtils.isLiteral(initializer, isAnd)) return false; if (!(PsiUtil.getVariableCodeBlock(local, null) instanceof PsiCodeBlock block)) return false; PsiElement[] defs = DefUseUtil.getDefs(block, local, expression.getParent()); // boolean x = false; x|=something; return defs.length == 1 && defs[0] == local && VariableAccessUtils.getVariableReferences(local, block).stream().filter(PsiUtil::isAccessedForWriting).limit(2).count() > 1; }