Object (@NotNull final DataProvider dataProvider) { if (dataProvider.getData(CommonDataKeys.PSI_FILE.getName()) instanceof PsiJavaFile javaFile) { return new JavaAnalysisScope(javaFile); } Object psiTarget = dataProvider.getData(CommonDataKeys.PSI_ELEMENT.getName()); if (psiTarget instanceof PsiPackage pack) { PsiManager manager = pack.getManager(); if (!manager.isInProject(pack)) return null; PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(manager.getProject())); if (dirs.length == 0) return null; return new JavaAnalysisScope(pack, (Module)dataProvider.getData(PlatformCoreDataKeys.MODULE.getName())); } return null; }