Merge remote-tracking branch 'origin/master' into prendota/plugin-manager-new-protocol
authorIvan Chirkov <Ivan.Chirkov@jetbrains.com>
Fri, 17 Apr 2020 10:40:43 +0000 (12:40 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 22 Apr 2020 07:31:06 +0000 (07:31 +0000)
# Conflicts:
# community/platform/platform-impl/src/com/intellij/ide/plugins/PluginNode.java
# community/platform/platform-impl/src/com/intellij/ide/plugins/newui/MyPluginModel.java
# community/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.kt

GitOrigin-RevId: 5ee8edd3161b27355cc491fc6cb7e83f2df89f4d

1  2 
platform/platform-api/resources/messages/IdeBundle.properties
platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurable.java
platform/platform-impl/src/com/intellij/ide/plugins/PluginNode.java
platform/platform-impl/src/com/intellij/ide/plugins/marketplace/PluginRepositoryObjects.kt
platform/platform-impl/src/com/intellij/ide/plugins/newui/ListPluginComponent.java
platform/platform-impl/src/com/intellij/ide/plugins/newui/MyPluginModel.java
platform/platform-impl/src/com/intellij/ide/plugins/newui/PluginDetailsPageComponent.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.kt
platform/platform-tests/testSrc/com/intellij/openapi/updateSettings/UpdatePluginsFromCustomRepositoryTest.java

index b2c1db106bad8d6585702f6795c0d57371e45c0d,12bb5c6fa4a338ac7f2a73d6f31bafbc15da620d..24a4ed183e16a95aa1d311d5b0e4be29bebb16b8
@@@ -1008,8 -998,28 +998,19 @@@ public abstract class MyPluginModel ext
      return message;
    }
  
 -  protected List<IdeaPluginDescriptor> getAllRepoPlugins() {
 -    try {
 -      List<IdeaPluginDescriptor> list = RepositoryHelper.loadCachedPlugins();
 -      if (list != null) {
 -        return list;
 -      }
 -    }
 -    catch (IOException ignored) {
 -    }
 -    return Collections.emptyList();
 -  }
+   @Nullable
+   private static Set<PluginId> filterRequiredPlugins(@Nullable Set<PluginId> requiredPlugins) {
+     if (ContainerUtil.isEmpty(requiredPlugins)) {
+       return requiredPlugins;
+     }
+     return requiredPlugins.stream().filter(id -> {
+       IdeaPluginDescriptor plugin = findPlugin(id);
+       return plugin == null || !plugin.isEnabled() ;
+     }).collect(Collectors.toSet());
+   }
 +  @NotNull
 +  abstract protected Collection<IdeaPluginDescriptor> getCustomRepoPlugins();
  
    @NotNull
    private List<IdeaPluginDescriptor> dependent(@NotNull IdeaPluginDescriptor rootDescriptor) {
index fce92ae3d7d2bcb63fde1b12e96437e89fc72d7e,d9298a306012821ff81d3306746ada2e5c1cff91..3a8241438be0ebc6e46745fc9ae9b2a86b4d3aa3
@@@ -209,25 -210,15 +209,29 @@@ object UpdateChecker 
      return HttpRequests.request(updateUrl).connect { UpdatesInfo(JDOMUtil.load(it.reader)) }
    }
  
 -  private fun checkPluginsUpdate(indicator: ProgressIndicator?,
 -                                 incompatiblePlugins: MutableCollection<IdeaPluginDescriptor>?,
 -                                 buildNumber: BuildNumber?): Collection<PluginDownloader>? {
 +  private data class CheckPluginsUpdateResult(
 +    val availableUpdates: Collection<PluginDownloader>?,
 +    val customRepositoryPlugins: Collection<IdeaPluginDescriptor>,
 +    val incompatiblePlugins: Collection<IdeaPluginDescriptor>?
 +  )
 +
 +  private val EMPTY_CHECK_UPDATE_RESULT = CheckPluginsUpdateResult(null, emptyList(), null)
 +
 +  /**
 +   * Checks for plugin updates for current build if `build` is not provided.
 +   *
 +   * Checks for plugin updates for provided `build` and calculates plugins that don't have updates and would be incompatible with provided build.
 +   */
+   /**
+    * If [buildNumber] is null, returns new versions of plugins compatible with the current IDE version. If not null, returns
+    * new versions of plugins compatible with the specified build.
+    */
 +  private fun checkPluginsUpdate(
 +    indicator: ProgressIndicator?,
 +    newBuildNumber: BuildNumber? = null
 +  ): CheckPluginsUpdateResult {
      val updateable = collectUpdateablePlugins()
 -    if (updateable.isEmpty()) return null
 +    if (updateable.isEmpty()) return EMPTY_CHECK_UPDATE_RESULT
  
      val toUpdate = mutableMapOf<PluginId, PluginDownloader>()
  
      toUpdate: MutableMap<PluginId, PluginDownloader>,
      buildNumber: BuildNumber?,
      state: InstalledPluginsState,
 -    incompatiblePlugins: MutableCollection<IdeaPluginDescriptor>?,
      indicator: ProgressIndicator?
    ) {
-     val marketplacePlugins = MarketplaceRequests.getMarketplacePlugins(indicator)
-     val idsToUpdate = updateable.map { it.key.idString }.filter { it in marketplacePlugins }
 -    val marketplacePluginIds = PluginsMetaLoader.getMarketplacePlugins(indicator)
++    val marketplacePluginIds = MarketplaceRequests.getMarketplacePlugins(indicator)
+     val idsToUpdate = updateable.map { it.key.idString }.filter { it in marketplacePluginIds }
 -    val updates = PluginsMetaLoader.getLastCompatiblePluginUpdate(idsToUpdate, buildNumber)
 +    val updates = MarketplaceRequests.getLastCompatiblePluginUpdate(idsToUpdate, buildNumber)
      for ((id, descriptor) in updateable) {
        val lastUpdate = updates.find { it.pluginId == id.idString } ?: continue
        val isOutdated = descriptor == null || VersionComparatorUtil.compare(lastUpdate.version, descriptor.version) > 0