[platform] UpdateChecker: external updates API

GitOrigin-RevId: 52dccfcb68fb02e01b99fca46ae71380813450ff
This commit is contained in:
Roman Shevchenko
2021-03-22 13:34:53 +00:00
committed by intellij-monorepo-bot
parent 6dfd55de7c
commit bcbc4d56c4
3 changed files with 14 additions and 52 deletions
@@ -1,42 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.updateSettings.impl;
import com.intellij.ide.externalComponents.ExternalComponentSource;
import com.intellij.ide.externalComponents.UpdatableExternalComponent;
import java.util.Collection;
/**
* Represents one external update request, consisting of a collection of components for which updates will be requested from one source.
*/
public class ExternalUpdate {
private final Collection<UpdatableExternalComponent> myComponents;
private final ExternalComponentSource mySource;
public ExternalUpdate(Collection<UpdatableExternalComponent> components, ExternalComponentSource source) {
myComponents = components;
mySource = source;
}
public Collection<UpdatableExternalComponent> getComponents() {
return myComponents;
}
public ExternalComponentSource getSource() {
return mySource;
}
}
@@ -1,6 +1,8 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.updateSettings.impl
import com.intellij.ide.externalComponents.ExternalComponentSource
import com.intellij.ide.externalComponents.UpdatableExternalComponent
import com.intellij.ide.plugins.IdeaPluginDescriptor
import com.intellij.openapi.util.BuildNumber
@@ -42,3 +44,8 @@ data class PluginUpdates(
val disabled: Collection<PluginDownloader>,
val incompatible: Collection<IdeaPluginDescriptor>,
)
data class ExternalUpdate(
val source: ExternalComponentSource,
val components: Collection<UpdatableExternalComponent>
)
@@ -1,7 +1,6 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.updateSettings.impl
import com.google.common.annotations.VisibleForTesting
import com.intellij.ide.IdeBundle
import com.intellij.ide.externalComponents.ExternalComponentManager
import com.intellij.ide.plugins.*
@@ -148,8 +147,9 @@ object UpdateChecker {
return
}
indicator?.text = IdeBundle.message("updates.external.progress")
val externalUpdates = try {
checkExternalUpdates(showDialog, updateSettings, indicator)
findExternalUpdates(showDialog, updateSettings, indicator)
}
catch (e: IOException) {
showErrorMessage(showDialog, IdeBundle.message("updates.error.connection.failed", e.message))
@@ -387,13 +387,10 @@ object UpdateChecker {
return updateable
}
@VisibleForTesting
fun checkExternalUpdates(manualCheck: Boolean,
updateSettings: UpdateSettings,
indicator: ProgressIndicator?): Collection<ExternalUpdate> {
@JvmStatic
fun findExternalUpdates(manualCheck: Boolean, updateSettings: UpdateSettings, indicator: ProgressIndicator?): Collection<ExternalUpdate> {
val result = arrayListOf<ExternalUpdate>()
val manager = ExternalComponentManager.getInstance()
indicator?.text = IdeBundle.message("updates.external.progress")
for (source in ExternalComponentManager.getComponentSources()) {
indicator?.checkCanceled()
@@ -401,7 +398,7 @@ object UpdateChecker {
val siteResult = source.getAvailableVersions(indicator, updateSettings)
.filter { it.isUpdateFor(manager.findExistingComponentMatching(it, source)) }
if (siteResult.isNotEmpty()) {
result += ExternalUpdate(siteResult, source)
result += ExternalUpdate(source, siteResult)
}
}
catch (e: Exception) {
@@ -491,7 +488,7 @@ object UpdateChecker {
checkForUpdateResult: CheckForUpdateResult,
pluginUpdates: PluginUpdates,
customRepoPlugins: Collection<IdeaPluginDescriptor>,
externalUpdates: Collection<ExternalUpdate>?,
externalUpdates: Collection<ExternalUpdate>,
showSettingsLink: Boolean,
showDialog: Boolean,
showNotification: Boolean) {
@@ -571,7 +568,7 @@ object UpdateChecker {
}
}
if (externalUpdates != null && !externalUpdates.isEmpty()) {
if (externalUpdates.isNotEmpty()) {
updateFound = true
ourShownNotifications.remove(NotificationUniqueType.EXTERNAL)?.forEach { it.expire() }