Editor (@NotNull Project project, DataContext context) { Editor editor = CommonDataKeys.EDITOR.getData(context); if (editor == null) { @Nullable FileEditor fileEditor = context.getData(PlatformDataKeys.LAST_ACTIVE_FILE_EDITOR); return fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null; } return editor; }