Collection<PsiFileSystemItem> (@NotNull Project project) { return CachedValuesManager.getManager(project).getCachedValue(project, () -> { Collection<VirtualFile> pluginXmlFilesInProductionScope = DomService.getInstance().getDomFileCandidates(IdeaPlugin.class, PluginRelatedLocatorsUtils.getCandidatesScope(project)); ProjectFileIndex projectFileIndex = ProjectFileIndex.getInstance(project); Set<VirtualFile> pluginXmlRoots = new HashSet<>(); for (VirtualFile pluginXml : pluginXmlFilesInProductionScope) { VirtualFile sourceRoot = projectFileIndex.getSourceRootForFile(pluginXml); if (sourceRoot != null) { pluginXmlRoots.add(sourceRoot); } else { VirtualFile classRoot = projectFileIndex.getClassRootForFile(pluginXml); ContainerUtil.addIfNotNull(pluginXmlRoots, classRoot); } } PsiManager psiManager = PsiManager.getInstance(project); List<PsiFileSystemItem> rootsPsiFileSystemItems = pluginXmlRoots.stream() .map(virtualFile -> psiManager.findDirectory(virtualFile)) .filter(Objects::nonNull) .collect(Collectors.toList()); return CachedValueProvider.Result.create(rootsPsiFileSystemItems, PsiModificationTracker.MODIFICATION_COUNT); }); }