void (Project project, Collection<? extends JpsModuleSourceRootPropertiesSerializer<?>> registeredSerializers) { if (registeredSerializers.isEmpty()) { return; } Map<String, JpsModuleSourceRootPropertiesSerializer<?>> serializers = new HashMap<>(); for (JpsModuleSourceRootPropertiesSerializer<?> ser : registeredSerializers) { serializers.put(ser.getTypeId(), ser); } for (Module module : ModuleManager.getInstance(project).getModules()) { Map<SourceFolder, Pair<JpsModuleSourceRootPropertiesSerializer<?>, Element>> foldersToUpdate = new HashMap<>(); for (ContentEntry contentEntry : ModuleRootManager.getInstance(module).getContentEntries()) { for (SourceFolder folder : contentEntry.getSourceFolders()) { if (folder.getRootType() instanceof UnknownSourceRootType type) { JpsModuleSourceRootPropertiesSerializer<?> serializer = serializers.get(type.getUnknownTypeId()); if (serializer != null) { UnknownSourceRootTypeProperties<?> properties = folder.getJpsElement().getProperties(type); Object data = properties != null ? properties.getPropertiesData() : null; foldersToUpdate.put(folder, new Pair<>(serializer, data instanceof Element ? (Element)data : null)); } } } } if (!foldersToUpdate.isEmpty()) { ModuleRootModificationUtil.updateModel(module, model -> { for (ContentEntry contentEntry : model.getContentEntries()) { for (SourceFolder folder : contentEntry.getSourceFolders()) { Pair<JpsModuleSourceRootPropertiesSerializer<?>, Element> pair = foldersToUpdate.get(folder); if (pair != null) { changeType(folder, pair.first, pair.second); } } } }); } } }