void (@NotNull FindModel model, @NotNull DataContext dataContext) { Project project = CommonDataKeys.PROJECT.getData(dataContext); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (editor == null) { EditorSearchSession session = EditorSearchSession.SESSION_KEY.getData(dataContext); if (session != null) editor = session.getEditor(); } PsiElement psiElement = null; if (project != null && editor == null && !DumbServiceImpl.getInstance(project).isDumb()) { try { psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataContext); } catch (IndexNotReadyException ignore) {} } String directoryName = null; if (psiElement instanceof PsiDirectory) { directoryName = ((PsiDirectory)psiElement).getVirtualFile().getPresentableUrl(); } if (directoryName == null && psiElement instanceof PsiDirectoryContainer) { PsiDirectory[] directories = ((PsiDirectoryContainer)psiElement).getDirectories(); directoryName = directories.length == 1 ? directories[0].getVirtualFile().getPresentableUrl():null; } if (directoryName == null) { VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext); if (virtualFile != null) { if (virtualFile.isDirectory()) { directoryName = virtualFile.getPresentableUrl(); } else { VirtualFile parent = virtualFile.getParent(); if (parent != null && parent.isDirectory()) { if (editor == null) { directoryName = parent.getPresentableUrl(); } else if (project != null) { FindInProjectSettings.getInstance(project).addDirectory(parent.getPresentableUrl()); } } } } } Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext); if (module != null) { model.setModuleName(module.getName()); model.setDirectoryName(null); model.setCustomScope(false); } if (model.getModuleName() == null || editor == null) { if (directoryName != null) { model.setDirectoryName(directoryName); model.setCustomScope(false); // to select "Directory: " radio button } } for (FindInProjectExtension extension : FindInProjectExtension.EP_NAME.getExtensionList()) { boolean success = extension.initModelFromContext(model, dataContext); if (success) break; } // set project scope if we have no other settings model.setProjectScope(model.getDirectoryName() == null && model.getModuleName() == null && !model.isCustomScope()); }