IJPL-219 log error if deprecated method is used

GitOrigin-RevId: 3f83bd8d8a135a2979184d3ee98e27527ce3c294
This commit is contained in:
Vladimir Krivosheev
2023-09-03 23:39:35 +00:00
committed by intellij-monorepo-bot
parent 3b4a0933dd
commit a5b535685e
@@ -1,6 +1,9 @@
// 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.ide
import com.intellij.diagnostic.PluginException
import com.intellij.ide.plugins.cl.PluginAwareClassLoader
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.progress.blockingContext
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.annotations.ApiStatus
@@ -19,18 +22,27 @@ interface ApplicationInitializedListener {
* Write actions and time-consuming activities are forbidden because it directly affects application start time.
*/
suspend fun execute(asyncScope: CoroutineScope) {
val aClass = this::class.java
val message = "Override `execute` (class=$aClass)"
val classLoader = aClass.classLoader
if (classLoader is PluginAwareClassLoader) {
logger<ApplicationInitializedListener>().error(PluginException(message, classLoader.pluginId))
}
else {
logger<ApplicationInitializedListener>().error(message)
}
blockingContext {
@Suppress("DEPRECATION")
componentsInitialized()
}
}
@Deprecated("Use {@link #execute()}", ReplaceWith("execute()"))
@Deprecated("Use [execute]", ReplaceWith("execute()"))
fun componentsInitialized() {
}
}
@Deprecated("Consider avoiding using of ApplicationInitializedListener")
@Deprecated("Consider avoiding using of ApplicationInitializedListener", level = DeprecationLevel.ERROR)
abstract class ApplicationInitializedListenerJavaShim : ApplicationInitializedListener {
final override suspend fun execute(asyncScope: CoroutineScope) {
blockingContext {