private static boolean isLoopOnlySideEffect(PsiElement e, @NotNull Set<PsiVariable> declaredVariables) {
      if (e instanceof PsiContinueStatement || e instanceof PsiBreakStatement || e instanceof PsiVariable) {
        return true;
      }

      PsiExpression operand = null;
      if (e instanceof PsiUnaryExpression) {
        operand = ((PsiUnaryExpression)e).getOperand();
      }
      else if (e instanceof PsiAssignmentExpression) {
        operand = ((PsiAssignmentExpression)e).getLExpression();
      }
      if (operand == null) return false;
      operand = PsiUtil.skipParenthesizedExprDown(operand);
      PsiReferenceExpression ref = tryCast(operand, PsiReferenceExpression.class);
      if (ref != null) return isDeclaredVariable(ref.resolve(), declaredVariables);
      PsiArrayAccessExpression arrayAccess = tryCast(operand, PsiArrayAccessExpression.class);
      if (arrayAccess == null) return true;
      return loopOnlyVariablesChanged(arrayAccess, declaredVariables);
    }
private static boolean isLoopOnlySideEffect(PsiElement e, @NotNull Set<PsiVariable> declaredVariables)