mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c1497e2eb6
commit
281a94447f
@@ -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> 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<T> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user