All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jetbrains.pluginverifier.repository.PluginInfo.kt Maven / Gradle / Ivy

/*
 * Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 */

package com.jetbrains.pluginverifier.repository

import com.jetbrains.plugin.structure.intellij.version.IdeVersion

/**
 * Identifier of a plugin within the [PluginRepository].
 */
abstract class PluginInfo(
  /**
   * Unique plugin ID, which may be equal
   * to name if ID is not specified.
   */
  val pluginId: String,

  /**
   * Plugin name.
   */
  val pluginName: String,

  /**
   * Plugin version.
   */
  val version: String,

  /**
   * "since" compatibility range.
   */
  val sinceBuild: IdeVersion?,

  /**
   * "until" compatibility range.
   */
  val untilBuild: IdeVersion?,

  /**
   * Vendor of the plugin.
   */
  val vendor: String?
) {

  /**
   * Checks whether this plugin is compatible with [ideVersion].
   */
  fun isCompatibleWith(ideVersion: IdeVersion) =
    (sinceBuild == null || sinceBuild <= ideVersion) && (untilBuild == null || ideVersion <= untilBuild)

  val presentableSinceUntilRange: String
    get() {
      val sinceCode = sinceBuild?.asStringWithoutProductCode()
      val untilCode = untilBuild?.asStringWithoutProductCode()
      if (sinceCode != null) {
        if (untilCode != null) {
          return "$sinceCode — $untilCode"
        }
        return "$sinceCode+"
      }
      if (untilCode != null) {
        return "1.0 — $untilCode"
      }
      return "all"
    }

  open val presentableName
    get() = "$pluginId $version"

  final override fun toString() = presentableName
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy