diff --git a/openapi/src/com/intellij/ExtensionPoints.java b/openapi/src/com/intellij/ExtensionPoints.java new file mode 100644 index 000000000000..fe128ea6d4a0 --- /dev/null +++ b/openapi/src/com/intellij/ExtensionPoints.java @@ -0,0 +1,35 @@ +package com.intellij; + +/** + * Extension points provided by IDEA core are listed here. + */ +public interface ExtensionPoints { + /** + * This extension point should be used instead of former application-components, project-components, module-components. + * Extension declaration sample is as follows: + *
+   * <extensions xmlns="com.intellij">
+   *   <component area="IDEA_PROJECT">
+   *     <implementation>my.plugin.pagckage.MyProjectComponent</implementation>
+   *   </component>
+   * </extensions>
+   * 
+ * + * Possible registration areas are IDEA_PROJECT, MODULE_PROJECT which stand for ProjectComponent and ModuleComponent correspondingly. + * If area attribute is ommited the component will be registered in root area which corresponds to ApplicationComponent. + */ + String COMPONENT = "com.intellij.component"; + + /** + * This extension point allows a plugin vendor to provide the user ability to report fatal errors (aka exceptions) that happened in + * their plugin code. + * Extension declaration sample is as follows: + *
+   * <extensions xmlns="com.intellij">
+   *   <errorHandler implementation="my.plugin.package.MyErrorHandler"/>
+   * </extensions>
+   * 
+ * my.plugin.package.MyErrorHandler class must implement {@link com.intellij.openapi.diagnostic.ErrorReportSubmitter} abstract class. + */ + String ERROR_HANDLER = "com.intellij.errorHandler"; +} diff --git a/openapi/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java b/openapi/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java index 4b3165a6fece..110a2c052946 100644 --- a/openapi/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java +++ b/openapi/src/com/intellij/openapi/diagnostic/ErrorReportSubmitter.java @@ -6,24 +6,40 @@ import com.intellij.openapi.extensions.PluginDescriptor; import java.awt.*; /** - * Created by IntelliJ IDEA. - * User: max - * Date: Feb 17, 2005 - * Time: 9:11:44 PM - * To change this template use File | Settings | File Templates. + * This class should be extended by plugin vendor and provided by means of {@link com.intellij.ExtensionPoints#ERROR_HANDLER} if + * reporting errors that happened in plugin code to vendor is desirable. */ public abstract class ErrorReportSubmitter implements PluginAware { - public final static String ERROR_HANDLER_EXTENSION_POINT = "com.intellij.errorHandler"; private PluginDescriptor myPlugin; + /** + * Called by the framework. Allows to identify the plugin that provided this extension. + * @param plugin + */ public void setPluginDescriptor(PluginDescriptor plugin) { myPlugin = plugin; } + /** + * @return plugin that provided this particular extension + */ public PluginDescriptor getPluginDescriptor() { return myPlugin; } + /** + * @return "Report to vendor" action text to be used in Error Reporter user interface. For example: "Report to JetBrains". + */ public abstract String getReportActionText(); + + /** + * This method is called whenever fatal error (aka exception) in plugin code had happened and user decided to report this problem to + * plugin vendor. + * @param events sequence of the fatal error descriptors. Fatal errors that happened immediately one after another most probably caused + * by first one that happened so it's a common practice to submit only first one. Array passed is guaranteed to have at least one element. + * @param parentComponent one usually wants to show up a dialog asking user for additional details and probably authentication info. + * parentComponent parameter is passed so dialog that would come up would be properly aligned with its parent dialog (IDE Fatal Errors). + * @return submission result status. + */ public abstract SubmittedReportInfo submit(IdeaLoggingEvent[] events, Component parentComponent); } diff --git a/source/com/intellij/diagnostic/IdeErrorsDialog.java b/source/com/intellij/diagnostic/IdeErrorsDialog.java index d8f6b32f4934..9be5a0aa1fb9 100644 --- a/source/com/intellij/diagnostic/IdeErrorsDialog.java +++ b/source/com/intellij/diagnostic/IdeErrorsDialog.java @@ -8,6 +8,7 @@ package com.intellij.diagnostic; * @author kir, max */ +import com.intellij.ExtensionPoints; import com.intellij.ide.BrowserUtil; import com.intellij.ide.plugins.PluginManager; import com.intellij.ide.reporter.ScrData; @@ -467,7 +468,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene private ErrorReportSubmitter getSubmitter(final AbstractMessage logMessage) { final String pluginName = findPluginName(logMessage.getThrowable()); - final Object[] reporters = Extensions.getRootArea().getExtensionPoint(ErrorReportSubmitter.ERROR_HANDLER_EXTENSION_POINT) + final Object[] reporters = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.ERROR_HANDLER) .getExtensions(); ErrorReportSubmitter submitter = null; for (int i = 0; i < reporters.length; i++) { diff --git a/source/com/intellij/ide/plugins/PluginManager.java b/source/com/intellij/ide/plugins/PluginManager.java index 0c495cf00a6a..3ae4686dcbe7 100644 --- a/source/com/intellij/ide/plugins/PluginManager.java +++ b/source/com/intellij/ide/plugins/PluginManager.java @@ -1,5 +1,6 @@ package com.intellij.ide.plugins; +import com.intellij.ExtensionPoints; import com.intellij.diagnostic.ITNReporter; import com.intellij.ide.plugins.cl.IdeaClassLoader; import com.intellij.ide.plugins.cl.PluginClassLoader; @@ -40,7 +41,6 @@ import java.util.zip.ZipFile; public class PluginManager { //Logger is lasy-initialized in order not to use it outside the appClassLoader private static Logger ourLogger = null; - public static final String COMPONENT_EXTENSION_POINT = "com.intellij.component"; private static Logger getLogger() { if (ourLogger == null) { @@ -125,12 +125,12 @@ public class PluginManager { Extensions.registerAreaClass("IDEA_PROJECT", null); Extensions.registerAreaClass("IDEA_MODULE", "IDEA_PROJECT"); - Extensions.getRootArea().registerExtensionPoint(COMPONENT_EXTENSION_POINT, ComponentDescriptor.class.getName()); + Extensions.getRootArea().registerExtensionPoint(ExtensionPoints.COMPONENT, ComponentDescriptor.class.getName()); Extensions.getRootArea().getExtensionPoint(Extensions.AREA_LISTENER_EXTENSION_POINT).registerExtension(new AreaListener() { public void areaCreated(String areaClass, AreaInstance areaInstance) { if ("IDEA_PROJECT".equals(areaClass) || "IDEA_MODULE".equals(areaClass)) { - Extensions.getArea(areaInstance).registerExtensionPoint(COMPONENT_EXTENSION_POINT, ComponentDescriptor.class.getName()); + Extensions.getArea(areaInstance).registerExtensionPoint(ExtensionPoints.COMPONENT, ComponentDescriptor.class.getName()); } } @@ -138,8 +138,8 @@ public class PluginManager { } }, LoadingOrder.FIRST); - Extensions.getRootArea().registerExtensionPoint(ErrorReportSubmitter.ERROR_HANDLER_EXTENSION_POINT, ErrorReportSubmitter.class.getName()); - Extensions.getRootArea().getExtensionPoint(ErrorReportSubmitter.ERROR_HANDLER_EXTENSION_POINT).registerExtension(new ITNReporter()); + Extensions.getRootArea().registerExtensionPoint(ExtensionPoints.ERROR_HANDLER, ErrorReportSubmitter.class.getName()); + Extensions.getRootArea().getExtensionPoint(ExtensionPoints.ERROR_HANDLER).registerExtension(new ITNReporter()); } public static boolean shouldLoadPlugins() { diff --git a/source/com/intellij/openapi/components/impl/ComponentManagerImpl.java b/source/com/intellij/openapi/components/impl/ComponentManagerImpl.java index ba9dda782feb..569cf8652942 100644 --- a/source/com/intellij/openapi/components/impl/ComponentManagerImpl.java +++ b/source/com/intellij/openapi/components/impl/ComponentManagerImpl.java @@ -1,5 +1,6 @@ package com.intellij.openapi.components.impl; +import com.intellij.ExtensionPoints; import com.intellij.diagnostic.PluginException; import com.intellij.ide.plugins.ComponentDescriptor; import com.intellij.ide.plugins.PluginDescriptor; @@ -375,7 +376,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements if (ApplicationManagerEx.getApplicationEx().isUnitTestMode()) return; // TODO: quick and dirty. To make tests running. final ComponentDescriptor[] componentDescriptors = - (ComponentDescriptor[])extensionsArea.getExtensionPoint(PluginManager.COMPONENT_EXTENSION_POINT).getExtensions(); + (ComponentDescriptor[])extensionsArea.getExtensionPoint(ExtensionPoints.COMPONENT).getExtensions(); for (int i = 0; i < componentDescriptors.length; i++) { ComponentDescriptor descriptor = componentDescriptors[i]; final Map options = descriptor.getOptionsMap();