override def load()

in ideaSupport/src/main/scala/org/jetbrains/sbtidea/download/plugin/serialization/XmlPluginIndexSerializer.scala [15:49]


  override def load(file: Path): Seq[(String, PluginInfo)] = {
    val buffer = new mutable.ArrayBuffer[(String, PluginInfo)]

    val content = new String(Files.readAllBytes(file), StandardCharsets.UTF_8)
    val xml = XML.loadString(content)

    val version = (xml \ "version").text.toInt
    if (version != IndexVersion) {
      throw new WrongIndexVersionException(version)
    }

    val plugins = xml \ "plugins" \ "plugin"
    plugins.foreach { plugin =>
      val id = (plugin \ "id").text
      val relativePath = (plugin \ "path").text

      // Parse downloadInfo if present
      val downloadInfo = (plugin \ "downloadInfo").headOption.map { infoNode =>
        val fileName = (infoNode \ "downloadedFileName").text
        val url = new java.net.URL((infoNode \ "downloadedUrl").text)
        val timeStr = (infoNode \ "downloadedTime").text
        val time = java.time.LocalDateTime.parse(timeStr)

        PluginInfo.PluginDownloadInfo(fileName, url, time)
      }

      // Get the descriptor XML node and convert it to a PluginDescriptor
      val descriptorNode = (plugin \ "descriptor").head
      val descriptor = PluginDescriptor.load(descriptorNode.asInstanceOf[Elem])

      buffer += id -> PluginInfo(Path.of(relativePath), descriptor, downloadInfo)
    }

    buffer
  }