From cd9b7156a6a1af4f86e5ccca785be54efd3e268e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 1 Aug 2019 13:06:39 +0200 Subject: [PATCH] cleanup GitOrigin-RevId: eb73190d1af092134e01a374b0f4e2730f3fd523 --- .../impl/PlatformComponentManagerImpl.kt | 77 ++++++++----------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/PlatformComponentManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/components/impl/PlatformComponentManagerImpl.kt index 3a54bd58c891..c256408a354f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/PlatformComponentManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/PlatformComponentManagerImpl.kt @@ -1,63 +1,52 @@ // Copyright 2000-2019 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.components.impl; +package com.intellij.openapi.components.impl -import com.intellij.diagnostic.LoadingPhase; -import com.intellij.ide.plugins.ContainerDescriptor; -import com.intellij.ide.plugins.IdeaPluginDescriptor; -import com.intellij.ide.plugins.IdeaPluginDescriptorImpl; -import com.intellij.ide.plugins.PluginManager; -import com.intellij.openapi.components.ComponentManager; -import com.intellij.openapi.components.PathMacroManager; -import com.intellij.openapi.components.ServiceDescriptor; -import com.intellij.openapi.components.ServiceKt; -import com.intellij.openapi.components.impl.stores.IComponentStore; -import com.intellij.openapi.extensions.PluginId; -import com.intellij.util.messages.MessageBusFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.diagnostic.LoadingPhase +import com.intellij.ide.plugins.ContainerDescriptor +import com.intellij.ide.plugins.IdeaPluginDescriptor +import com.intellij.ide.plugins.IdeaPluginDescriptorImpl +import com.intellij.ide.plugins.PluginManager +import com.intellij.openapi.components.ComponentManager +import com.intellij.openapi.components.PathMacroManager +import com.intellij.openapi.components.ServiceDescriptor +import com.intellij.openapi.components.impl.stores.IComponentStore +import com.intellij.openapi.components.stateStore +import com.intellij.openapi.extensions.PluginId +import com.intellij.util.messages.MessageBusFactory -public abstract class PlatformComponentManagerImpl extends ComponentManagerImpl { - private boolean myHandlingInitComponentError; +abstract class PlatformComponentManagerImpl : ComponentManagerImpl { + private var handlingInitComponentError = false - protected PlatformComponentManagerImpl(@Nullable ComponentManager parent) { - super(parent); - } + private val componentStore: IComponentStore + get() = this.stateStore - protected PlatformComponentManagerImpl(@Nullable ComponentManager parent, @NotNull String name) { - super(parent, name); - } + protected constructor(parent: ComponentManager?) : super(parent) - @Override - protected void handleInitComponentError(@NotNull Throwable t, String componentClassName, PluginId pluginId) { - if (!myHandlingInitComponentError) { - myHandlingInitComponentError = true; + protected constructor(parent: ComponentManager?, name: String) : super(parent, name) + + override fun handleInitComponentError(t: Throwable, componentClassName: String, pluginId: PluginId) { + if (!handlingInitComponentError) { + handlingInitComponentError = true try { - PluginManager.handleComponentError(t, componentClassName, pluginId); + PluginManager.handleComponentError(t, componentClassName, pluginId) } finally { - myHandlingInitComponentError = false; + handlingInitComponentError = false } } } - @Override - public void initializeComponent(@NotNull Object component, @Nullable ServiceDescriptor serviceDescriptor) { - if (serviceDescriptor == null || !(component instanceof PathMacroManager || component instanceof IComponentStore || component instanceof MessageBusFactory)) { - LoadingPhase.assertAtLeast(LoadingPhase.CONFIGURATION_STORE_INITIALIZED); - getComponentStore().initComponent(component, serviceDescriptor); + override fun initializeComponent(component: Any, serviceDescriptor: ServiceDescriptor?) { + if (serviceDescriptor == null || !(component is PathMacroManager || component is IComponentStore || component is MessageBusFactory)) { + LoadingPhase.assertAtLeast(LoadingPhase.CONFIGURATION_STORE_INITIALIZED) + componentStore.initComponent(component, serviceDescriptor) } } - @NotNull - protected IComponentStore getComponentStore() { - return ServiceKt.getStateStore(this); + override fun registerServices(pluginDescriptor: IdeaPluginDescriptor) { + ServiceManagerImpl.registerServices(getContainerDescriptor(pluginDescriptor as IdeaPluginDescriptorImpl).services, pluginDescriptor, + this) } - @Override - protected final void registerServices(@NotNull IdeaPluginDescriptor pluginDescriptor) { - ServiceManagerImpl.registerServices(getContainerDescriptor((IdeaPluginDescriptorImpl)pluginDescriptor).getServices(), pluginDescriptor, this); - } - - @NotNull - protected abstract ContainerDescriptor getContainerDescriptor(@NotNull IdeaPluginDescriptorImpl pluginDescriptor); + protected abstract fun getContainerDescriptor(pluginDescriptor: IdeaPluginDescriptorImpl): ContainerDescriptor }