boolean calculateSideEffect(@Nullable PsiExpression e) {
    if (e instanceof PsiParenthesizedExpression paren) {
      return mayHaveSideEffect(paren.getExpression());
    }
    if (e instanceof PsiUnaryExpression) {
      return PsiUtil.isIncrementDecrementOperation(e) || mayHaveSideEffect(((PsiUnaryExpression)e).getOperand());
    }
    if (e instanceof PsiPolyadicExpression polyadic) {
      return ContainerUtil.exists(polyadic.getOperands(), this::mayHaveSideEffect);
    }
    if (e instanceof PsiConditionalExpression conditional) {
      return mayHaveSideEffect(conditional.getCondition()) ||
             mayHaveSideEffect(conditional.getThenExpression()) ||
             mayHaveSideEffect(conditional.getElseExpression());
    }
    if (e instanceof PsiMethodCallExpression call) {
      return calculateCallSideEffect(call);
    }
    if (e instanceof PsiReferenceExpression ref) {
      return calculateReferenceSideEffect(ref);
    }
    if (e instanceof PsiInstanceOfExpression instanceOf) {
      return mayHaveSideEffect(instanceOf.getOperand());
    }
    if (e instanceof PsiArrayAccessExpression access) {
      PsiExpression array = access.getArrayExpression();
      return mayHaveSideEffect(array) ||
             mayHaveSideEffect(access.getIndexExpression()) ||
             !CommonDataflow.getDfType(array).isLocal();
    }
    if (e instanceof PsiLambdaExpression) {
      return false; // lambda itself (unless called) has no side effect
    }
    if (e instanceof PsiNewExpression newExpression) {
      return calculateNewSideEffect(newExpression);
    }
    return true;
  }
boolean calculateSideEffect(@Nullable PsiExpression e)