void (@NotNull ActionContext context, @NotNull PsiTypeElement conjunct, @NotNull ModPsiUpdater updater) { PsiTypeElement[] conjList = PsiTreeUtil.getChildrenOfType(conjunct.getParent(), PsiTypeElement.class); if (conjList == null) return; final PsiTypeCastExpression castExpression = PsiTreeUtil.getParentOfType(conjunct, PsiTypeCastExpression.class); if (castExpression == null) return; final PsiTypeElement castType = castExpression.getCastType(); if (castType == null) return; final PsiType type = castType.getType(); if (!(type instanceof PsiIntersectionType)) return; final String typeText = StreamEx.of(conjList).without(conjunct).map(PsiElement::getText).joining(" & "); Project project = context.project(); final PsiTypeCastExpression newCastExpr = (PsiTypeCastExpression)JavaPsiFacade.getElementFactory(project).createExpressionFromText("(" + typeText + ")a", castType); CodeStyleManager.getInstance(project).reformat(castType.replace(Objects.requireNonNull(newCastExpr.getCastType()))); }