DataContext (@NotNull Project project, @NotNull Editor editor) { // There is a possible case that formatting is performed from project view and editor is not opened yet. The problem is that // its data context doesn't contain information about project then. So, we explicitly support that here (see IDEA-72791). Project editorProject = editor.getProject(); DataContext context = EditorUtil.getEditorDataContext(editor); if (editorProject != null) return context; return new DataContextWrapper(context) { @Override public @Nullable Object getRawCustomData(@NotNull String dataId) { if (PROJECT.is(dataId)) return project; return null; } }; }