void (@NotNull ActionContext context, @NotNull PsiReferenceExpression exprToReplace, @NotNull ModPsiUpdater updater) { PsiClass resolvedExprClass = getResolvedExprClass(); if (resolvedExprClass == null) return; PsiExpression newExpr = JavaPsiFacade.getElementFactory(resolvedExprClass.getProject()) .createExpressionFromText("x instanceof " + resolvedExprClass.getName() + " " + myPatternVarName, resolvedExprClass); if (newExpr instanceof PsiInstanceOfExpression instanceOfExpression) { exprToReplace.replace(Objects.requireNonNull(instanceOfExpression.getPattern())); } }