String (@NotNull final Editor editor) { String text = ReadAction.compute(() -> editor.getSelectionModel().getSelectedText()); if (text == null) { text = editor.getDocument().getText(); } if (StringUtil.isEmptyOrSpaces(text)) { return null; } return text; }