void (Project project, Collection<PsiMethod> overridingMethods, ExternalAnnotationsManager annotationsManager, Map<PsiMethod, ExternalAnnotationsManager.AnnotationPlace> annotationPlaces) { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); Map<VirtualFile, ExternalAnnotationsManager.AnnotationPlace> sourceRoots = new HashMap<>(); for (PsiMethod overridingMethod : overridingMethods) { ExternalAnnotationsManager.AnnotationPlace annotationPlace = annotationPlaces.get(overridingMethod); if (annotationPlace == ExternalAnnotationsManager.AnnotationPlace.NEED_ASK_USER) { //ask once per source root VirtualFile virtualFile = PsiUtilCore.getVirtualFile(overridingMethod); VirtualFile sourceRoot = virtualFile != null ? fileIndex.getSourceRootForFile(virtualFile) : null; if (sourceRoot != null) { annotationPlaces .put(overridingMethod, sourceRoots.computeIfAbsent(sourceRoot, __ -> annotationsManager.chooseAnnotationsPlace(overridingMethod))); } } } }