mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: report ClassNotFoundException thrown from implementations of AbstractExtensionPointBean to plugins
'AbstractExtensionPointBean::findClass' and 'instantiate' methods throws ClassNotFoundException which was usually wrapped to RuntimeException in the calling code, and therefore such exceptions were reported as core problems (IDEA-201589), and there were no simple way to find out which plugin caused the problem. Now 'findExtensionClass' and 'instantiateClass' methods are introduced, they throw ExtensionInitializationException instead which stores information about problematic plugin and this information is used by the error reporter. The old methods are deprecated and all their calls in IntelliJ sources are replaced by calls of the new methods. Also PluginException is now used to wrap other exceptions occurred during extensions' instantiations. GitOrigin-RevId: 664f254c505cd1bd690824d4e84f16da64ff8038
This commit is contained in:
committed by
intellij-monorepo-bot
parent
96f1c3a85e
commit
9a110f7d51
+5
-4
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -47,16 +48,16 @@ public class ErrorFixExtensionPoint extends AbstractExtensionPointBean {
|
||||
|
||||
IntentionAction instantiate(PsiElement context) {
|
||||
try {
|
||||
return findClass(implementationClass).asSubclass(IntentionAction.class).getConstructor(PsiElement.class).newInstance(context);
|
||||
return findExtensionClass(implementationClass).asSubclass(IntentionAction.class).getConstructor(PsiElement.class).newInstance(context);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
if(e.getCause() instanceof ProcessCanceledException) {
|
||||
throw ((ProcessCanceledException)e.getCause());
|
||||
}
|
||||
throw new RuntimeException("Error instantiating quick-fix " + implementationClass + " (error code: " + errorCode + ")", e.getCause());
|
||||
throw new PluginException("Error instantiating quick-fix " + implementationClass + " (error code: " + errorCode + ")", e.getCause(), getPluginId());
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
throw new RuntimeException("Error instantiating quick-fix " + implementationClass + " (error code: " + errorCode + ")", e);
|
||||
catch (InstantiationException | IllegalAccessException | NoSuchMethodException e) {
|
||||
throw new PluginException("Error instantiating quick-fix " + implementationClass + " (error code: " + errorCode + ")", e, getPluginId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,14 +191,9 @@ public class InspectionEP extends LanguageExtensionPoint implements InspectionPr
|
||||
|
||||
@NotNull
|
||||
public InspectionProfileEntry instantiateTool() {
|
||||
try {
|
||||
final InspectionProfileEntry entry = instantiate(implementationClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
entry.myNameProvider = this;
|
||||
return entry;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final InspectionProfileEntry entry = instantiateExtension(implementationClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
entry.myNameProvider = this;
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,17 +37,12 @@ public class JsonRpcDomainBean extends AbstractExtensionPointBean {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Object compute() {
|
||||
try {
|
||||
if (service == null) {
|
||||
Class<Object> aClass = findClass(implementation);
|
||||
return asInstance ? instantiate(aClass, ApplicationManager.getApplication().getPicoContainer()) : aClass;
|
||||
}
|
||||
else {
|
||||
return ServiceManager.getService(findClass(service));
|
||||
}
|
||||
if (service == null) {
|
||||
Class<Object> aClass = findExtensionClass(implementation);
|
||||
return asInstance ? instantiate(aClass, ApplicationManager.getApplication().getPicoContainer()) : aClass;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
else {
|
||||
return ServiceManager.getService(findExtensionClass(service));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-7
@@ -22,13 +22,7 @@ public class CustomLoadingExtensionPointBean extends AbstractExtensionPointBean
|
||||
instance = ExtensionInstantiator.instantiateWithPicoContainerOnlyIfNeeded(className, picoContainer, myPluginDescriptor);
|
||||
}
|
||||
else {
|
||||
ExtensionFactory factory;
|
||||
try {
|
||||
factory = instantiate(factoryClass, picoContainer);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new PluginException(e, myPluginDescriptor == null ? null : myPluginDescriptor.getPluginId());
|
||||
}
|
||||
ExtensionFactory factory = instantiateExtension(factoryClass, picoContainer);
|
||||
//noinspection unchecked
|
||||
instance = (T)factory.createInstance(factoryArgument, className);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FileTypeExtensionPoint<T> extends AbstractExtensionPointBean implem
|
||||
private final LazyInstance<T> myHandler = new LazyInstance<T>() {
|
||||
@Override
|
||||
protected Class<T> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ClassExtensionPoint<T> extends AbstractExtensionPointBean implement
|
||||
private final LazyInstance<T> myHandler = new LazyInstance<T>() {
|
||||
@Override
|
||||
protected Class<T> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ public class PsiReferenceProviderBean extends AbstractExtensionPointBean impleme
|
||||
|
||||
public PsiReferenceProvider instantiate() {
|
||||
try {
|
||||
return (PsiReferenceProvider)instantiate(className, ApplicationManager.getApplication().getPicoContainer());
|
||||
return (PsiReferenceProvider)instantiateClass(className, ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -76,11 +77,11 @@ public class StubElementTypeHolderEP extends AbstractExtensionPointBean {
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
findClass(holderClass);
|
||||
findExtensionClass(holderClass);
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
LOG.error(e);
|
||||
LOG.error(new PluginException(e, getPluginId()));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -91,12 +92,7 @@ public class StubElementTypeHolderEP extends AbstractExtensionPointBean {
|
||||
*/
|
||||
@Deprecated
|
||||
public void initialize() {
|
||||
try {
|
||||
findClass(holderClass);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
findClassNoExceptions(holderClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,8 +34,8 @@ public class KeyedLazyInstanceEP<T> extends AbstractExtensionPointBean implement
|
||||
|
||||
private final LazyInstance<T> myHandler = new LazyInstance<T>() {
|
||||
@Override
|
||||
protected Class<T> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
protected Class<T> getInstanceClass() {
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+31
-1
@@ -29,11 +29,29 @@ public abstract class AbstractExtensionPointBean implements PluginAware {
|
||||
return myPluginDescriptor == null ? null : myPluginDescriptor.getPluginId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #findExtensionClass(String)} instead. It'll throw {@link ExtensionInstantiationException} instead of
|
||||
* {@link ClassNotFoundException}, which contains information about the plugin which registers the problematic extension so error reporters
|
||||
* will be able to report such exception as a plugin problem, not core problem. Also it isn't a checked exception so you won't need to wrap
|
||||
* it to unchecked exception in your code.
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public final <T> Class<T> findClass(@NotNull String className) throws ClassNotFoundException {
|
||||
return findClass(className, myPluginDescriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final <T> Class<T> findExtensionClass(@NotNull String className) {
|
||||
try {
|
||||
return findClass(className, myPluginDescriptor);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new ExtensionInstantiationException(e, myPluginDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Class<T> findClass(@NotNull String className, @Nullable PluginDescriptor pluginDescriptor) throws ClassNotFoundException {
|
||||
ClassLoader classLoader = pluginDescriptor == null ? AbstractExtensionPointBean.class.getClassLoader() : pluginDescriptor.getPluginClassLoader();
|
||||
@@ -47,7 +65,7 @@ public abstract class AbstractExtensionPointBean implements PluginAware {
|
||||
return findClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
LOG.error("Problem loading class " + className + " from plugin " + myPluginDescriptor, e);
|
||||
LOG.error(new ExtensionInstantiationException(e, myPluginDescriptor));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -57,11 +75,23 @@ public abstract class AbstractExtensionPointBean implements PluginAware {
|
||||
return myPluginDescriptor == null ? getClass().getClassLoader() : myPluginDescriptor.getPluginClassLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #instantiateClass(String, PicoContainer)} instead. It'll throw {@link ExtensionInstantiationException} instead of
|
||||
* {@link ClassNotFoundException}, which contains information about the plugin which registers the problematic extension so error reporters
|
||||
* will be able to report such exception as a plugin problem, not core problem. Also it isn't a checked exception so you won't need to wrap
|
||||
* it to unchecked exception in your code.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public final <T> T instantiate(@NotNull String className, @NotNull PicoContainer container) throws ClassNotFoundException {
|
||||
return instantiate(findClass(className), container);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final <T> T instantiateClass(@NotNull String className, @NotNull PicoContainer container) {
|
||||
return instantiate(findExtensionClass(className), container);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T instantiate(@NotNull Class<T> aClass, @NotNull PicoContainer container) {
|
||||
return instantiate(aClass, container, true);
|
||||
|
||||
@@ -66,9 +66,9 @@ public abstract class KeyedExtensionFactory<T, KeyT> {
|
||||
}
|
||||
|
||||
try {
|
||||
return (T)epBean.instantiate(epBean.implementationClass, picoContainer);
|
||||
return (T)epBean.instantiateClass(epBean.implementationClass, picoContainer);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
catch (ProcessCanceledException | ExtensionInstantiationException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -94,10 +94,10 @@ public abstract class KeyedExtensionFactory<T, KeyT> {
|
||||
if (Comparing.strEqual(epBean.key, key, true)) {
|
||||
try {
|
||||
if (epBean.implementationClass != null) {
|
||||
result = epBean.instantiate(epBean.implementationClass, myPicoContainer);
|
||||
result = epBean.instantiateClass(epBean.implementationClass, myPicoContainer);
|
||||
}
|
||||
else {
|
||||
Object factory = epBean.instantiate(epBean.factoryClass, myPicoContainer);
|
||||
Object factory = epBean.instantiateClass(epBean.factoryClass, myPicoContainer);
|
||||
result = method.invoke(factory, args);
|
||||
}
|
||||
if (result != null) {
|
||||
@@ -109,6 +109,9 @@ public abstract class KeyedExtensionFactory<T, KeyT> {
|
||||
if (t instanceof ControlFlowException && t instanceof RuntimeException) throw (RuntimeException)t;
|
||||
throw new ExtensionInstantiationException(e, epBean.getPluginDescriptor());
|
||||
}
|
||||
catch (ExtensionInstantiationException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if (e instanceof ControlFlowException) {
|
||||
throw e;
|
||||
|
||||
@@ -28,13 +28,6 @@ public class ModuleBuilderFactory extends AbstractExtensionPointBean {
|
||||
public String builderClass;
|
||||
|
||||
public ModuleBuilder createBuilder() {
|
||||
try {
|
||||
return instantiate(builderClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return instantiateClass(builderClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.lang.cacheBuilder;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -44,12 +45,12 @@ public class CacheBuilderEP extends AbstractExtensionPointBean {
|
||||
try {
|
||||
Class<WordsScanner> aClass = myCachedClass;
|
||||
if (aClass == null) {
|
||||
myCachedClass = aClass = findClass(wordsScannerClass);
|
||||
myCachedClass = aClass = findExtensionClass(wordsScannerClass);
|
||||
}
|
||||
return aClass.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
LOG.error(new PluginException(e, getPluginId()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ModuleTypeEP extends AbstractExtensionPointBean {
|
||||
public ModuleType getModuleType() {
|
||||
if (myModuleType == null) {
|
||||
try {
|
||||
myModuleType = instantiate(implementationClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
myModuleType = instantiateClass(implementationClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -44,15 +44,10 @@ public class WeigherExtensionPoint extends AbstractExtensionPointBean implements
|
||||
@Override
|
||||
@NotNull
|
||||
protected final Weigher compute() {
|
||||
try {
|
||||
Class<Weigher> tClass = findClass(implementationClass);
|
||||
final Weigher weigher = ReflectionUtil.newInstance(tClass);
|
||||
weigher.setDebugName(id);
|
||||
return weigher;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Class<Weigher> tClass = findExtensionClass(implementationClass);
|
||||
final Weigher weigher = ReflectionUtil.newInstance(tClass);
|
||||
weigher.setDebugName(id);
|
||||
return weigher;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ public class CompletionDataEP extends AbstractExtensionPointBean {
|
||||
|
||||
private final LazyInstance<CompletionData> myHandler = new LazyInstance<CompletionData>() {
|
||||
@Override
|
||||
protected Class<CompletionData> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(className);
|
||||
protected Class<CompletionData> getInstanceClass() {
|
||||
return findExtensionClass(className);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ public class QuoteHandlerEP extends AbstractExtensionPointBean {
|
||||
|
||||
private final LazyInstance<QuoteHandler> myHandler = new LazyInstance<QuoteHandler>() {
|
||||
@Override
|
||||
protected Class<QuoteHandler> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(className);
|
||||
protected Class<QuoteHandler> getInstanceClass() {
|
||||
return findExtensionClass(className);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ public class CreateDirectoryCompletionContributorEP extends AbstractExtensionPoi
|
||||
|
||||
private final LazyInstance<CreateDirectoryCompletionContributor> myHandler = new LazyInstance<CreateDirectoryCompletionContributor>() {
|
||||
@Override
|
||||
protected Class<CreateDirectoryCompletionContributor> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
protected Class<CreateDirectoryCompletionContributor> getInstanceClass() {
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,13 +39,7 @@ public class PatternClassBean extends AbstractExtensionPointBean {
|
||||
}
|
||||
|
||||
public Class getPatternClass() {
|
||||
try {
|
||||
return findClass(className);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return null;
|
||||
return findClassNoExceptions(className);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public final class EditorActionHandlerBean extends AbstractExtensionPointBean {
|
||||
try {
|
||||
DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer());
|
||||
container.registerComponentInstance(originalHandler);
|
||||
myHandler = instantiate(implementationClass, container);
|
||||
myHandler = instantiateClass(implementationClass, container);
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class EditorTypedHandlerBean extends AbstractExtensionPointBean {
|
||||
try {
|
||||
DefaultPicoContainer container = new DefaultPicoContainer(ApplicationManager.getApplication().getPicoContainer());
|
||||
container.registerComponentInstance(originalHandler);
|
||||
myHandler = instantiate(implementationClass, container);
|
||||
myHandler = instantiateClass(implementationClass, container);
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.openapi.options;
|
||||
|
||||
import com.intellij.AbstractBundle;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -254,18 +255,18 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten
|
||||
protected ObjectProducer createProducer() {
|
||||
try {
|
||||
if (providerClass != null) {
|
||||
return new ProviderProducer(instantiate(providerClass, myPicoContainer));
|
||||
return new ProviderProducer(instantiateClass(providerClass, myPicoContainer));
|
||||
}
|
||||
if (instanceClass != null) {
|
||||
return new ClassProducer(myPicoContainer, findClass(instanceClass));
|
||||
return new ClassProducer(myPicoContainer, findExtensionClass(instanceClass));
|
||||
}
|
||||
if (implementationClass != null) {
|
||||
return new ClassProducer(myPicoContainer, findClass(implementationClass));
|
||||
return new ClassProducer(myPicoContainer, findExtensionClass(implementationClass));
|
||||
}
|
||||
throw new RuntimeException("configurable class name is not set");
|
||||
throw new PluginException("configurable class name is not set", getPluginId());
|
||||
}
|
||||
catch (AssertionError | Exception | LinkageError error) {
|
||||
LOG.error(error);
|
||||
LOG.error(new PluginException(error, getPluginId()));
|
||||
}
|
||||
return new ObjectProducer();
|
||||
}
|
||||
@@ -287,13 +288,13 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return instantiate(findClass(treeRendererClass), myPicoContainer);
|
||||
return instantiate(findExtensionClass(treeRendererClass), myPicoContainer);
|
||||
}
|
||||
catch (ProcessCanceledException exception) {
|
||||
throw exception;
|
||||
}
|
||||
catch (AssertionError | LinkageError | Exception e) {
|
||||
LOG.error(e);
|
||||
LOG.error(new PluginException(e, getPluginId()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -87,13 +87,7 @@ public class ToolWindowEP extends AbstractExtensionPointBean {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
myFactoryClass = findClass(factoryClass);
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
myFactoryClass = findClassNoExceptions(factoryClass);
|
||||
}
|
||||
return myFactoryClass;
|
||||
}
|
||||
@@ -102,7 +96,7 @@ public class ToolWindowEP extends AbstractExtensionPointBean {
|
||||
public Condition<Project> getCondition() {
|
||||
if (conditionClass != null) {
|
||||
try {
|
||||
return instantiate(conditionClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
return instantiateClass(conditionClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class LibraryDependentToolWindow extends ToolWindowEP {
|
||||
public LibrarySearchHelper getLibrarySearchHelper() {
|
||||
if (myLibrarySearchHelper == null) {
|
||||
try {
|
||||
myLibrarySearchHelper = instantiate(getLibrarySearchClass(), ApplicationManager.getApplication().getPicoContainer());
|
||||
myLibrarySearchHelper = instantiateClass(getLibrarySearchClass(), ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -45,19 +45,14 @@ public class MixinEP<T> extends AbstractExtensionPointBean {
|
||||
}
|
||||
throw new IllegalArgumentException(error);
|
||||
}
|
||||
try {
|
||||
return findClass(key);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return findExtensionClass(key);
|
||||
}
|
||||
};
|
||||
|
||||
private final LazyInstance<T> myHandler = new LazyInstance<T>() {
|
||||
@Override
|
||||
protected Class<T> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
protected Class<T> getInstanceClass() {
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ public class TooltipLinkHandlerEP extends AbstractExtensionPointBean {
|
||||
|
||||
private final LazyInstance<TooltipLinkHandler> myHandler = new LazyInstance<TooltipLinkHandler>() {
|
||||
@Override
|
||||
protected Class<TooltipLinkHandler> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(handlerClassName);
|
||||
protected Class<TooltipLinkHandler> getInstanceClass() {
|
||||
return findExtensionClass(handlerClassName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -62,8 +62,8 @@ public class FileTypeUsageCounterCollector {
|
||||
|
||||
private final LazyInstance<T> myHandler = new LazyInstance<T>() {
|
||||
@Override
|
||||
protected Class<T> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
protected Class<T> getInstanceClass() {
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+4
-4
@@ -442,16 +442,16 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
FileType fileType;
|
||||
try {
|
||||
if (fileTypeBean.fieldName != null) {
|
||||
final Class<Object> fileTypeBeanClass = fileTypeBean.findClass(fileTypeBean.implementationClass);
|
||||
final Class<Object> fileTypeBeanClass = fileTypeBean.findExtensionClass(fileTypeBean.implementationClass);
|
||||
final Field field = fileTypeBeanClass.getDeclaredField(fileTypeBean.fieldName);
|
||||
fileType = (FileType) field.get(null);
|
||||
}
|
||||
else {
|
||||
fileType = fileTypeBean.instantiate(fileTypeBean.implementationClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
fileType = fileTypeBean.instantiateClass(fileTypeBean.implementationClass, ApplicationManager.getApplication().getPicoContainer());
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
LOG.error(e);
|
||||
catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
LOG.error(new PluginException(e, fileTypeBean.getPluginId()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ public class SchemeExporterEP <S extends Scheme> extends AbstractExtensionPointB
|
||||
|
||||
private final LazyInstance<SchemeExporter<S>> myExporterInstance = new LazyInstance<SchemeExporter<S>>() {
|
||||
@Override
|
||||
protected Class<SchemeExporter<S>> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
protected Class<SchemeExporter<S>> getInstanceClass() {
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ public class SchemeImporterEP <S extends Scheme> extends AbstractExtensionPointB
|
||||
|
||||
private final LazyInstance<SchemeImporter<S>> myImporterInstance = new LazyInstance<SchemeImporter<S>>() {
|
||||
@Override
|
||||
protected Class<SchemeImporter<S>> getInstanceClass() throws ClassNotFoundException {
|
||||
return findClass(implementationClass);
|
||||
protected Class<SchemeImporter<S>> getInstanceClass() {
|
||||
return findExtensionClass(implementationClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.vcs.impl;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
|
||||
@@ -72,20 +73,20 @@ public class VcsEP extends AbstractExtensionPointBean {
|
||||
@Nullable
|
||||
private AbstractVcs getInstance(@NotNull Project project, @NotNull String vcsClass) {
|
||||
try {
|
||||
final Class<? extends AbstractVcs> foundClass = findClass(vcsClass);
|
||||
final Class<? extends AbstractVcs> foundClass = findExtensionClass(vcsClass);
|
||||
final Class<?>[] interfaces = foundClass.getInterfaces();
|
||||
for (Class<?> anInterface : interfaces) {
|
||||
if (BaseComponent.class.isAssignableFrom(anInterface)) {
|
||||
return project.getComponent(foundClass);
|
||||
}
|
||||
}
|
||||
return instantiate(vcsClass, project.getPicoContainer());
|
||||
return instantiateClass(vcsClass, project.getPicoContainer());
|
||||
}
|
||||
catch (ProcessCanceledException pce) {
|
||||
throw pce;
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
LOG.error(new PluginException(e, getPluginId()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,23 +62,26 @@ public class DomFileMetaData extends AbstractExtensionPointBean {
|
||||
DomFileDescription instance = lazyInstance;
|
||||
if (instance == null) {
|
||||
try {
|
||||
instance = instantiate(findClass(implementation), ApplicationManager.getApplication().getPicoContainer());
|
||||
instance = instantiate(findExtensionClass(implementation), ApplicationManager.getApplication().getPicoContainer());
|
||||
if (StringUtil.isEmpty(rootTagName)) {
|
||||
if (!instance.acceptsOtherRootTagNames()) {
|
||||
throw new PluginException(implementation + " should either specify a root tag name in XML, or return true from 'acceptsOtherRootTagNames'", getPluginId());
|
||||
throw new PluginException(
|
||||
implementation + " should either specify a root tag name in XML, or return true from 'acceptsOtherRootTagNames'",
|
||||
getPluginId());
|
||||
}
|
||||
}
|
||||
else if (!rootTagName.equals(instance.getRootTagName())) {
|
||||
throw new PluginException(implementation + " XML declaration should have " + instance.getRootTagName() + " root tag name", getPluginId());
|
||||
throw new PluginException(implementation + " XML declaration should have " + instance.getRootTagName() + " root tag name",
|
||||
getPluginId());
|
||||
}
|
||||
DomApplicationComponent.getInstance().initDescription(instance);
|
||||
lazyInstance = instance;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
catch (ProcessCanceledException | PluginException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new PluginException(e, getPluginId());
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
|
||||
@@ -48,11 +48,8 @@ public class DomExtenderEP extends AbstractExtensionPointBean {
|
||||
@NotNull final DomInvocationHandler handler,
|
||||
@Nullable DomExtensionsRegistrarImpl registrar) {
|
||||
if (myDomClass == null) {
|
||||
try {
|
||||
myDomClass = findClass(domClassName);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(new PluginException(e, getPluginId()));
|
||||
myDomClass = findClassNoExceptions(domClassName);
|
||||
if (myDomClass == null) {
|
||||
return registrar;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +61,7 @@ public class DomExtenderEP extends AbstractExtensionPointBean {
|
||||
|
||||
if (myExtender == null) {
|
||||
try {
|
||||
myExtender = instantiate(extenderClassName, project.getPicoContainer());
|
||||
myExtender = instantiateClass(extenderClassName, project.getPicoContainer());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(new PluginException(e, getPluginId()));
|
||||
|
||||
Reference in New Issue
Block a user