From 60bd9a9c9bc3c6bdff5b2a6d3484b231618397f6 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 5 Apr 2021 22:18:58 +0200 Subject: [PATCH] =?UTF-8?q?convert=20DeployToServerConfigurationTypesRegis?= =?UTF-8?q?trar=20/=20WebpMetadata=20/=20LibraryKindLoader=20from=20applic?= =?UTF-8?q?ationInitializedListener=20to=20applicationService=20=E2=80=94?= =?UTF-8?q?=20it=20takes=20relatively=20a=20lot=20of=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitOrigin-RevId: 0494efaab588400fabcbe21f135f84a35d656124 --- .../impl/libraries/LibraryKindLoader.java | 8 +++----- .../src/META-INF/LangExtensions.xml | 2 +- .../impl/src/META-INF/RemoteServers.xml | 5 +++-- ...oyToServerConfigurationTypesRegistrar.java | 20 ++++++++++++------- plugins/webp/resources/META-INF/plugin.xml | 2 +- .../tools/adtui/webp/WebpMetadata.java | 10 +++++----- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryKindLoader.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryKindLoader.java index beffb5748c12..ae2d0482660b 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryKindLoader.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryKindLoader.java @@ -1,7 +1,6 @@ -// Copyright 2000-2020 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. +// 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.roots.impl.libraries; -import com.intellij.ide.ApplicationInitializedListener; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.extensions.ExtensionPointListener; import com.intellij.openapi.extensions.PluginDescriptor; @@ -16,9 +15,8 @@ import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; -final class LibraryKindLoader implements ApplicationInitializedListener { - @Override - public void componentsInitialized() { +final class LibraryKindLoader { + private LibraryKindLoader() { //todo[nik] this is temporary workaround for IDEA-98118: we need to initialize all library types to ensure that their kinds are created and registered in LibraryKind.ourAllKinds //In order to properly fix the problem we should extract all UI-related methods from LibraryType to a separate class and move LibraryType to intellij.platform.projectModel.impl module LibraryType.EP_NAME.getExtensionList(); diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 46ace62f286e..13c6e8846f2f 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -1323,7 +1323,7 @@ - + diff --git a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml index fbc4af5ee03e..f0c9a5d647e3 100644 --- a/platform/remote-servers/impl/src/META-INF/RemoteServers.xml +++ b/platform/remote-servers/impl/src/META-INF/RemoteServers.xml @@ -37,8 +37,9 @@ serviceImplementation="com.intellij.remoteServer.impl.configuration.deployment.DeploymentConfigurationManagerImpl"/> - + diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationTypesRegistrar.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationTypesRegistrar.java index b5effaa1be6f..6bc30b00ef88 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationTypesRegistrar.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationTypesRegistrar.java @@ -2,21 +2,27 @@ package com.intellij.remoteServer.impl.configuration.deployment; import com.intellij.execution.configurations.ConfigurationType; -import com.intellij.ide.ApplicationInitializedListener; import com.intellij.openapi.extensions.ExtensionPointListener; import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.openapi.extensions.impl.ExtensionPointImpl; import com.intellij.remoteServer.ServerType; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public final class DeployToServerConfigurationTypesRegistrar implements ApplicationInitializedListener { - @Override - public void componentsInitialized() { +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +// sync preloaded service and not as an ApplicationInitializedListener because it takes relatively a lot of time +public final class DeployToServerConfigurationTypesRegistrar { + private DeployToServerConfigurationTypesRegistrar() { //todo[nik] improve this: configuration types should be loaded lazily - getConfigurationTypesExtPoint() - .registerExtensions(ContainerUtil.map(ServerType.EP_NAME.getExtensionList(), type -> new DeployToServerConfigurationType(type))); + Collection> collection = ServerType.EP_NAME.getExtensionList(); + List list = new ArrayList<>(collection.size()); + for (ServerType t : collection) { + list.add(new DeployToServerConfigurationType(t)); + } + getConfigurationTypesExtPoint().registerExtensions(list); ServerType.EP_NAME.addExtensionPointListener(new ExtensionPointListener<>() { @Override diff --git a/plugins/webp/resources/META-INF/plugin.xml b/plugins/webp/resources/META-INF/plugin.xml index 8e4089a42876..610915fe2fc7 100644 --- a/plugins/webp/resources/META-INF/plugin.xml +++ b/plugins/webp/resources/META-INF/plugin.xml @@ -8,6 +8,6 @@ ]]> - + \ No newline at end of file diff --git a/plugins/webp/src/com/android/tools/adtui/webp/WebpMetadata.java b/plugins/webp/src/com/android/tools/adtui/webp/WebpMetadata.java index 445ea329d726..fef1fa9f61f1 100644 --- a/plugins/webp/src/com/android/tools/adtui/webp/WebpMetadata.java +++ b/plugins/webp/src/com/android/tools/adtui/webp/WebpMetadata.java @@ -15,7 +15,6 @@ */ package com.android.tools.adtui.webp; -import com.intellij.ide.ApplicationInitializedListener; import org.w3c.dom.Node; import javax.imageio.metadata.IIOInvalidTreeException; @@ -25,7 +24,7 @@ import javax.imageio.spi.IIORegistry; import javax.imageio.spi.ImageReaderSpi; import javax.imageio.spi.ImageWriterSpi; -public final class WebpMetadata extends IIOMetadata implements ApplicationInitializedListener { +public final class WebpMetadata extends IIOMetadata { public static final String WEBP_FORMAT_LOWER_CASE = "webp"; public static final String WEBP_FORMAT_UPPER_CASE = "WEBP"; public static final String[] WEBP_FORMAT_NAMES = new String[] {WEBP_FORMAT_UPPER_CASE, WEBP_FORMAT_LOWER_CASE}; @@ -36,9 +35,10 @@ public final class WebpMetadata extends IIOMetadata implements ApplicationInitia public static final float DEFAULT_ENCODING_QUALITY = 0.75f; public static final boolean DEFAULT_LOSSLESS = true; - @Override - public void componentsInitialized() { - ensureWebpRegistered(); + static final class WebpMetadataRegistrar { + private WebpMetadataRegistrar() { + ensureWebpRegistered(); + } } /**