void (@NotNull PsiElement element) { if (element instanceof PsiWhiteSpace) { element = element.getPrevSibling(); } if (!(element instanceof PsiJavaToken token)) { return; } CommentTracker tracker = new CommentTracker(); final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)element.getParent(); final StringBuilder newExpression = new StringBuilder(); PsiExpression[] operands = polyadicExpression.getOperands(); for (int i = 0; i < operands.length; i++) { PsiExpression operand = operands[i]; if (polyadicExpression.getTokenBeforeOperand(operand) == token) { PsiExpression prev = operands[i - 1]; PsiElement nextSibling = polyadicExpression.getFirstChild(); while (nextSibling != prev) { newExpression.append(tracker.text(nextSibling)); nextSibling = nextSibling.getNextSibling(); } merge((PsiLiteralExpression)prev, (PsiLiteralExpression)operand, newExpression); nextSibling = operand.getNextSibling(); while (nextSibling != null) { newExpression.append(tracker.text(nextSibling)); nextSibling = nextSibling.getNextSibling(); } break; } } PsiReplacementUtil.replaceExpression(polyadicExpression, newExpression.toString(), tracker); }