@Override
  public @Nullable Presentation getPresentation(@NotNull ActionContext context) {
    if (!BaseIntentionAction.canModify(context.file())) return null;
    PsiInstanceOfExpression instanceOfExpression = getInstanceOfExpressionAtCaret(context.file(), context.offset());
    if (instanceOfExpression == null) return null;
    PsiTypeElement checkType = instanceOfExpression.getCheckType();
    if (checkType == null || instanceOfExpression.getPattern() != null) return null;
    PsiExpression operand = instanceOfExpression.getOperand();
    PsiType operandType = operand.getType();
    if (TypeConversionUtil.isPrimitiveAndNotNull(operandType)) return null;
    PsiType type = checkType.getType();
    PsiStatement statement = PsiTreeUtil.getParentOfType(instanceOfExpression, PsiStatement.class);
    boolean insideIf = statement instanceof PsiIfStatement ifStatement
                       && PsiTreeUtil.isAncestor(ifStatement.getCondition(), instanceOfExpression, false);
    boolean insideWhile = statement instanceof PsiWhileStatement whileStatement
                          && PsiTreeUtil.isAncestor(whileStatement.getCondition(), instanceOfExpression, false);

    if (!insideIf && !insideWhile) return null;
    if (isAlreadyCastedTo(type, instanceOfExpression, statement)) return null;
    String castTo = type.getPresentableText();
    return Presentation.of(JavaBundle.message("cast.to.0", castTo));
  }
@Override
  public @Nullable Presentation getPresentation(@NotNull ActionContext context)