void (final PsiElement el, final PsiElement replacement, ReplacementInfo replacementInfo) { final PsiElement lastChild = el.getLastChild(); if (lastChild instanceof PsiComment && replacementInfo.getVariableName(lastChild) == null && !(replacement.getLastChild() instanceof PsiComment)) { PsiElement firstElementAfterStatementEnd = lastChild; for(PsiElement curElement=firstElementAfterStatementEnd.getPrevSibling();curElement!=null;curElement = curElement.getPrevSibling()) { if (!(curElement instanceof PsiWhiteSpace) && !(curElement instanceof PsiComment)) break; firstElementAfterStatementEnd = curElement; } replacement.addRangeAfter(firstElementAfterStatementEnd,lastChild,replacement.getLastChild()); } final PsiElement firstChild = el.getFirstChild(); if (firstChild instanceof PsiComment && !(firstChild instanceof PsiDocCommentBase) && replacementInfo.getVariableName(firstChild) == null) { PsiElement lastElementBeforeStatementStart = firstChild; for(PsiElement curElement=lastElementBeforeStatementStart.getNextSibling();curElement!=null;curElement = curElement.getNextSibling()) { if (!(curElement instanceof PsiWhiteSpace) && !(curElement instanceof PsiComment)) break; lastElementBeforeStatementStart = curElement; } replacement.addRangeBefore(firstChild,lastElementBeforeStatementStart,replacement.getFirstChild()); } }