protected static void moveAtNewLineIfNeeded(@NotNull Editor editor) {
    Document document = editor.getDocument();
    Caret caret = editor.getCaretModel().getPrimaryCaret();
    int line = caret.getLogicalPosition().line;

    if (DocumentUtil.isLineEmpty(document, line)) return;

    int lineEndOffset = DocumentUtil.getLineEndOffset(caret.getOffset(), document);
    caret.moveToOffset(lineEndOffset);

    EditorActionHandler actionHandler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
    actionHandler.execute(editor, caret, EditorUtil.getEditorDataContext(editor));
  }
protected static void moveAtNewLineIfNeeded(@NotNull Editor editor)