void (PsiClass replacementClass, PsiElement element, PsiElement anchor) { final PsiElement replacementSibling = anchor.getPrevSibling(); if (replacementSibling instanceof PsiWhiteSpace) { replacementSibling.delete(); } final PsiElement prevSibling = element.getPrevSibling(); if (prevSibling instanceof PsiWhiteSpace || PsiUtil.isJavaToken(prevSibling, JavaTokenType.COMMA)) { final PsiElement prevPrevSibling = prevSibling.getPrevSibling(); if (PsiUtil.isJavaToken(prevPrevSibling, JavaTokenType.COMMA)) { replacementClass.addBefore(prevPrevSibling, anchor); } replacementClass.addBefore(prevSibling, anchor); } replacementClass.addBefore(element, anchor); final PsiElement nextSibling = element.getNextSibling(); if (nextSibling instanceof PsiWhiteSpace) { replacementClass.addBefore(nextSibling, anchor); } }