Revert "remove enable.activity.preloading"

This reverts commit e71f60245ac299fe87d6cb4ddc5a8497d4802e61.

GitOrigin-RevId: d16abc361d569cc57430959783cf401ae5f2c0a5
This commit is contained in:
Vladimir Krivosheev
2024-03-24 17:50:22 +01:00
committed by intellij-monorepo-bot
parent f1b733c79f
commit d29341cd87
2 changed files with 37 additions and 2 deletions
@@ -1,11 +1,11 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.application
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.blockingContext
import org.jetbrains.annotations.ApiStatus.Internal
@Deprecated("Do not use")
@Deprecated("Use ApplicationInitializedListener (asyncScope)")
@Internal
abstract class PreloadingActivity {
open fun preload() {}
@@ -2,6 +2,7 @@
package com.intellij.platform.ide.bootstrap
import com.intellij.diagnostic.PerformanceWatcher
import com.intellij.diagnostic.PluginException
import com.intellij.history.LocalHistory
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.ide.util.PropertiesComponent
@@ -9,6 +10,9 @@ import com.intellij.openapi.application.PathMacros
import com.intellij.openapi.application.impl.ApplicationImpl
import com.intellij.openapi.application.impl.RawSwingDispatcher
import com.intellij.openapi.components.serviceAsync
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.extensions.PluginDescriptor
import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.projectRoots.ProjectJdkTable
import com.intellij.openapi.util.registry.RegistryManager
@@ -19,6 +23,7 @@ import com.intellij.platform.diagnostic.telemetry.impl.span
import com.intellij.platform.util.coroutines.childScope
import com.intellij.util.indexing.FileBasedIndex
import kotlinx.coroutines.*
import java.util.concurrent.CancellationException
fun CoroutineScope.preloadCriticalServices(
app: ApplicationImpl,
@@ -141,4 +146,34 @@ private fun CoroutineScope.postAppRegistered(app: ApplicationImpl,
}
}
}
if (!app.isHeadlessEnvironment && !app.isUnitTestMode && System.getProperty("enable.activity.preloading", "true").toBoolean()) {
asyncScope.launch(CoroutineName("preloadingActivity executing")) {
@Suppress("DEPRECATION")
val extensionPoint = app.extensionArea.getExtensionPoint<com.intellij.openapi.application.PreloadingActivity>("com.intellij.preloadingActivity")
@Suppress("DEPRECATION")
for (item in ExtensionPointName<com.intellij.openapi.application.PreloadingActivity>(extensionPoint.name).filterableLazySequence()) {
launch(CoroutineName(item.implementationClassName)) {
item.instance?.let {
executePreloadActivity(activity = it, descriptor = item.pluginDescriptor)
}
}
}
extensionPoint.reset()
}
}
}
@Suppress("DEPRECATION")
private suspend fun executePreloadActivity(activity: com.intellij.openapi.application.PreloadingActivity, descriptor: PluginDescriptor) {
try {
activity.execute()
}
catch (e: CancellationException) {
throw e
}
catch (e: Throwable) {
logger<com.intellij.openapi.application.PreloadingActivity>()
.error(PluginException("cannot execute preloading activity ${activity.javaClass.name}", e, descriptor.pluginId))
}
}