void (@NotNull PsiElement element, @NotNull TextRange range) { PsiPolyadicExpression expression = ObjectUtils.tryCast(element, PsiPolyadicExpression.class); if (expression == null) return; PsiExpression[] allOperands = expression.getOperands(); List<PsiExpression> operands = ContainerUtil.filter(allOperands, op -> range.contains(op.getTextRangeInParent())); if (operands.size() < 2) return; PsiExpression firstOperand = operands.get(0); PsiExpression lastOperand = operands.get(operands.size() - 1); RangeConstraint constraint = extractConstraint(firstOperand); if (constraint == null) return; CommentTracker ct = new CommentTracker(); ct.markUnchanged(constraint.myExpression); PsiElement[] allChildren = expression.getChildren(); PsiElement lastInPrefix = firstOperand.getPrevSibling(); String fullReplacement = ""; if (lastInPrefix != null) { fullReplacement += ct.rangeText(allChildren[0], lastInPrefix); } fullReplacement += myReplacement; PsiElement firstInSuffix = lastOperand.getNextSibling(); if (firstInSuffix != null) { PsiElement lastInSuffix = allChildren[allChildren.length - 1]; fullReplacement += ct.rangeText(firstInSuffix, lastInSuffix); } ct.replaceAndRestoreComments(expression, fullReplacement); }