mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
platform: reword constructor injection messages (add reason why; tune its tone)
GitOrigin-RevId: 302b3d4d1da2036c453ef768b765838440429f4c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
baed10e426
commit
1b7a7d4875
@@ -42,7 +42,7 @@ internal class ConstructorParameterResolver {
|
||||
|
||||
if (isLightService(expectedType)) {
|
||||
throw PluginException(
|
||||
"Do not use constructor injection for light services (requestorClass=$requestorClass, requestedService=$expectedType)", pluginId
|
||||
"Constructor injection for light services is not supported (requestorClass=$requestorClass, requestedService=$expectedType)", pluginId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ internal class ConstructorParameterResolver {
|
||||
|
||||
private fun handleUnsatisfiedDependency(componentManager: ComponentManagerImpl, requestorClass: Class<*>, expectedType: Class<*>, pluginId: PluginId): Any? {
|
||||
val extension = componentManager.extensionArea.findExtensionByClass(expectedType) ?: return null
|
||||
val message = "Do not use constructor injection to get extension instance (requestorClass=${requestorClass.name}, extensionClass=${expectedType.name})"
|
||||
val message = doNotUseConstructorInjectionsMessage("requestorClass=${requestorClass.name}, extensionClass=${expectedType.name}")
|
||||
val app = componentManager.getApplication()
|
||||
@Suppress("SpellCheckingInspection")
|
||||
if (app != null && app.isUnitTestMode && pluginId.idString != "org.jetbrains.kotlin" && pluginId.idString != "Lombook Plugin") {
|
||||
|
||||
@@ -71,11 +71,12 @@ internal fun <T> instantiateUsingPicoContainer(aClass: Class<*>,
|
||||
if (!isErrorLogged && !ComponentManager::class.java.isAssignableFrom(parameterType)) {
|
||||
isErrorLogged = true
|
||||
// a special unit test
|
||||
val message = doNotUseConstructorInjectionsMessage("requestorClass=${aClass.name})")
|
||||
if (componentManager.getApplication() == null) {
|
||||
LOG.warn("Do not use constructor injection (requestorClass=${aClass.name})")
|
||||
LOG.warn(message)
|
||||
}
|
||||
else {
|
||||
LOG.error("Do not use constructor injection (requestorClass=${aClass.name})")
|
||||
LOG.error(message)
|
||||
}
|
||||
}
|
||||
parameterResolver.resolveInstance(componentManager = componentManager,
|
||||
|
||||
@@ -48,4 +48,8 @@ fun throwAlreadyDisposedError(serviceDescription: String, componentManager: Comp
|
||||
|
||||
internal fun isLightService(serviceClass: Class<*>): Boolean {
|
||||
return Modifier.isFinal(serviceClass.modifiers) && serviceClass.isAnnotationPresent(Service::class.java)
|
||||
}
|
||||
|
||||
internal fun doNotUseConstructorInjectionsMessage(where: String): String {
|
||||
return "Please, do not use constructor injection: it slows down initialization and may lead to performance problems ($where)"
|
||||
}
|
||||
Reference in New Issue
Block a user