void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiPolyadicExpression polyadicExpression = PsiTreeUtil.getParentOfType(element, PsiPolyadicExpression.class); if (polyadicExpression == null) return; PsiElement[] children = polyadicExpression.getChildren(); // We know that at least one operand is present after current, so we just remove everything till the next operand int start = IntStreamEx.ofIndices(children, child -> PsiTreeUtil.isAncestor(child, element, false)).findFirst().orElse(-1); if (start == -1) return; int end = IntStreamEx.range(start + 1, children.length).findFirst(idx -> children[idx] instanceof PsiExpression).orElse(-1); if (end == -1) return; CommentTracker ct = new CommentTracker(); String replacement = IntStreamEx.range(0, start).append(IntStreamEx.range(end, children.length)).elements(children) .map(ct::text).joining(); ct.replaceAndRestoreComments(polyadicExpression, replacement); }