From 281a94447fa7c65fc83c893c06ad9179ce9c8648 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 1 Aug 2019 14:45:06 +0300 Subject: [PATCH] cleanup: use ExtensionInstantiationException in ExtensionInstantiator for consistency Followup to 664f254c5: while PluginException is available in the class, it looks more consistent to use ExtensionInstantiationException here. GitOrigin-RevId: b7e2d0f9eb4c49a85336d7b158428296b73bf4b2 --- .../intellij/util/ExtensionInstantiator.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/platform/core-api/src/com/intellij/util/ExtensionInstantiator.java b/platform/core-api/src/com/intellij/util/ExtensionInstantiator.java index ef38874f4be8..9378738d0d66 100644 --- a/platform/core-api/src/com/intellij/util/ExtensionInstantiator.java +++ b/platform/core-api/src/com/intellij/util/ExtensionInstantiator.java @@ -1,14 +1,10 @@ // 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.util; -import com.intellij.diagnostic.PluginException; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.extensions.AbstractExtensionPointBean; -import com.intellij.openapi.extensions.ExtensionNotApplicableException; -import com.intellij.openapi.extensions.PluginDescriptor; -import com.intellij.openapi.extensions.PluginId; +import com.intellij.openapi.extensions.*; import com.intellij.openapi.progress.ProcessCanceledException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,9 +20,8 @@ public final class ExtensionInstantiator { public static T instantiateWithPicoContainerOnlyIfNeeded(@Nullable String className, @NotNull PicoContainer picoContainer, @Nullable PluginDescriptor pluginDescriptor) { - PluginId pluginId = pluginDescriptor == null ? null : pluginDescriptor.getPluginId(); if (className == null) { - throw new PluginException("implementation class is not specified", pluginId); + throw new ExtensionInstantiationException("implementation class is not specified", pluginDescriptor); } Class clazz; @@ -34,7 +29,7 @@ public final class ExtensionInstantiator { clazz = AbstractExtensionPointBean.findClass(className, pluginDescriptor); } catch (ClassNotFoundException e) { - throw new PluginException(e, pluginId); + throw new ExtensionInstantiationException(e, pluginDescriptor); } try { @@ -45,7 +40,7 @@ public final class ExtensionInstantiator { } catch (Throwable e) { if (e.getCause() instanceof NoSuchMethodException) { - PluginException exception = new PluginException("Bean extension class constructor must not have parameters: " + className, pluginId); + Exception exception = new ExtensionInstantiationException("Bean extension class constructor must not have parameters: " + className, pluginDescriptor); Application app = ApplicationManager.getApplication(); if (app != null && app.isUnitTestMode()) { LOG.error(exception); @@ -55,7 +50,7 @@ public final class ExtensionInstantiator { } } else { - throw new PluginException(e, pluginId); + throw new ExtensionInstantiationException(e, pluginDescriptor); } } @@ -66,7 +61,7 @@ public final class ExtensionInstantiator { throw e; } catch (Throwable e) { - throw new PluginException(e, pluginId); + throw new ExtensionInstantiationException(e, pluginDescriptor); } } }