void (@NotNull Editor editor, @NotNull PsiFile file, @NotNull MoveInfo info, boolean down) { super.afterMove(editor, file, info, down); Document document = editor.getDocument(); if (moveEnumConstant) { CharSequence cs = document.getCharsSequence(); int end1 = findNearestNonWhitespace(cs, info.range1.getEndOffset()); char c1 = cs.charAt(end1); int end2 = findNearestNonWhitespace(cs, info.range2.getEndOffset()); char c2 = cs.charAt(end2); if (c1 == c2 || (c1 != ',' && c2 != ',')) return; if (c1 == ';' || c2 == ';') { // Replace comma with semicolon and vice versa document.replaceString(end1, end1 + 1, String.valueOf(c2)); document.replaceString(end2, end2 + 1, String.valueOf(c1)); } else if (c1 == ',') { // Move comma from the end of range1 to the end of range2 document.deleteString(end1, end1 + 1); document.insertString(end2 + 1, ","); } else { // Move comma from the end of range2 to the end of range1 document.deleteString(end2, end2 + 1); document.insertString(end1 + 1, ","); } } if (moveIntoBlock || moveOutOfBlock) { if (down) { if (moveIntoBlock) { document.deleteString(info.range1.getEndOffset(), info.range2.getStartOffset()); } else { int offset = info.range1.getEndOffset(); document.insertString(offset, "\n"); CaretModel caretModel = editor.getCaretModel(); if (document.getCharsSequence().charAt(caretModel.getOffset() - 1) == '\n') caretModel.moveToOffset(offset + 1); } } else { if (moveIntoBlock) { document.deleteString(info.range2.getEndOffset(), info.range1.getStartOffset()); } else { document.insertString(info.range2.getEndOffset(), "\n"); } } } }