From dcdbb638faddbded22ec187e38c01a6d4ea8b309 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 31 Jan 2019 16:02:01 +0300 Subject: [PATCH] diagnostic: introduce PluginException.createByClass and logPluginError methods and use them in code This simplifies code and also allow using these methods from intellij.platform.core module. --- .../library/DownloadableLibraryType.java | 4 +-- .../impl/JsonSchemaServiceImpl.java | 4 +-- .../src/ComponentStoreImpl.kt | 4 +-- .../src/StorageBaseEx.kt | 4 +-- .../intellij/diagnostic/PluginException.java | 19 +++++++++++- .../diagnostic/PluginProblemReporter.java | 29 +++++++++++++++++++ .../diagnostic/PluginProblemReporterImpl.java | 14 +++++++++ .../ide/plugins/PluginManagerCore.java | 3 +- .../components/impl/ComponentManagerImpl.java | 2 +- .../psi/impl/DocumentCommitThread.java | 6 ++-- .../source/tree/LazyParseableElement.java | 4 +-- .../daemon/impl/ExternalToolPass.java | 4 +-- .../daemon/impl/LocalInspectionsPass.java | 4 +-- .../actions/GotoDeclarationAction.java | 6 ++-- .../RunnerAndConfigurationSettingsImpl.kt | 3 +- .../com/intellij/formatting/RangesAssert.java | 4 +-- .../PsiElementFromSelectionsRule.java | 4 +-- .../ContributorsBasedGotoByModel.java | 4 +-- .../module/impl/ModuleTypeManagerImpl.java | 3 +- .../impl/PushedFilePropertiesUpdaterImpl.java | 4 +-- .../intellij/psi/stubs/StubVersionMap.java | 6 ++-- .../intellij/configurationStore/storeUtil.kt | 3 +- .../src/META-INF/PlatformExtensions.xml | 2 ++ .../psi/impl/PyReferenceExpressionImpl.java | 4 +-- 24 files changed, 102 insertions(+), 42 deletions(-) create mode 100644 platform/core-api/src/com/intellij/diagnostic/PluginProblemReporter.java create mode 100644 platform/core-impl/src/com/intellij/diagnostic/PluginProblemReporterImpl.java diff --git a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java index eee1695e9594..d612f2ee5ac0 100644 --- a/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java +++ b/java/idea-ui/src/com/intellij/framework/library/DownloadableLibraryType.java @@ -15,7 +15,7 @@ */ package com.intellij.framework.library; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.libraries.*; import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent; @@ -117,7 +117,7 @@ public abstract class DownloadableLibraryType extends LibraryType(private val component: Persisten throw e } catch (e: Throwable) { - LOG.error(PluginManagerCore.createPluginException("Cannot get state after load", e, component.javaClass)) + PluginException.logPluginError(LOG, "Cannot get state after load", e, component.javaClass) null } diff --git a/platform/core-api/src/com/intellij/diagnostic/PluginException.java b/platform/core-api/src/com/intellij/diagnostic/PluginException.java index b42adae40822..4e2d5bf288d4 100644 --- a/platform/core-api/src/com/intellij/diagnostic/PluginException.java +++ b/platform/core-api/src/com/intellij/diagnostic/PluginException.java @@ -15,6 +15,7 @@ */ package com.intellij.diagnostic; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; @@ -25,7 +26,7 @@ import org.jetbrains.annotations.Nullable; * some contract of IntelliJ Platform. If such exceptions are thrown or logged via {@link com.intellij.openapi.diagnostic.Logger#error(Throwable)} * method and reported to JetBrains by user, they may be automatically attributed to corresponding plugins. * - *

If the problem is caused by a class, use {@link com.intellij.ide.plugins.PluginManagerCore#createPluginException} to create + *

If the problem is caused by a class, use {@link #createByClass} to create * an instance. If the problem is caused by an extension, implement {@link com.intellij.openapi.extensions.PluginAware} in its extension class * to get the plugin ID. */ @@ -58,4 +59,20 @@ public class PluginException extends RuntimeException { String message = super.getMessage(); return myPluginId != null ? StringUtil.notNullize(message) + " [Plugin: " + myPluginId + "]" : message; } + + /** + * Creates an exception caused by a problem in a plugin's code. + * @param pluginClass a problematic class which caused the error + */ + public static PluginException createByClass(@NotNull String errorMessage, @Nullable Throwable cause, @NotNull Class pluginClass) { + return PluginProblemReporter.getInstance().createPluginExceptionByClass(errorMessage, cause, pluginClass); + } + + /** + * Log an error caused by a problem in a plugin's code. + * @param pluginClass a problematic class which caused the error + */ + public static void logPluginError(@NotNull Logger logger, @NotNull String errorMessage, @Nullable Throwable cause, @NotNull Class pluginClass) { + logger.error(createByClass(errorMessage, cause, pluginClass)); + } } diff --git a/platform/core-api/src/com/intellij/diagnostic/PluginProblemReporter.java b/platform/core-api/src/com/intellij/diagnostic/PluginProblemReporter.java new file mode 100644 index 000000000000..38b58bccb6e9 --- /dev/null +++ b/platform/core-api/src/com/intellij/diagnostic/PluginProblemReporter.java @@ -0,0 +1,29 @@ +// 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.diagnostic; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.components.ServiceManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +interface PluginProblemReporter { + static PluginProblemReporter getInstance() { + if (ApplicationManager.getApplication() == null) { + //if the application isn't initialized yet return silly implementation which reports all plugins problems as platform ones + return new PluginProblemReporter() { + @NotNull + @Override + public PluginException createPluginExceptionByClass(@NotNull String errorMessage, + @Nullable Throwable cause, + @NotNull Class pluginClass) { + return new PluginException(errorMessage, cause, null); + } + }; + } + + return ServiceManager.getService(PluginProblemReporter.class); + } + + @NotNull + PluginException createPluginExceptionByClass(@NotNull String errorMessage, @Nullable Throwable cause, @NotNull Class pluginClass); +} diff --git a/platform/core-impl/src/com/intellij/diagnostic/PluginProblemReporterImpl.java b/platform/core-impl/src/com/intellij/diagnostic/PluginProblemReporterImpl.java new file mode 100644 index 000000000000..d2413d068e92 --- /dev/null +++ b/platform/core-impl/src/com/intellij/diagnostic/PluginProblemReporterImpl.java @@ -0,0 +1,14 @@ +// 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.diagnostic; + +import com.intellij.ide.plugins.PluginManagerCore; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +class PluginProblemReporterImpl implements PluginProblemReporter { + @NotNull + @Override + public PluginException createPluginExceptionByClass(@NotNull String errorMessage, @Nullable Throwable cause, @NotNull Class pluginClass) { + return PluginManagerCore.createPluginException(errorMessage, cause, pluginClass); + } +} diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java index fffac90d13ad..764eeec0ac9d 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java @@ -342,8 +342,7 @@ public class PluginManagerCore { } /** - * Creates an exception caused by a problem in a plugin's code. - * @param pluginClass a problematic class which caused the error + * This is an internal method, use {@link PluginException#createByClass(String, Throwable, Class)} instead. */ @NotNull public static PluginException createPluginException(@NotNull String errorMessage, @Nullable Throwable cause, diff --git a/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java b/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java index 359d7812b5a5..97c7315d58e6 100644 --- a/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java @@ -409,7 +409,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements // component may have been already loaded by PicoContainer, so fire error only if components are really different if (!instance.equals(loadedComponent)) { String errorMessage = "Component name collision: " + componentName + " " + (loadedComponent == null ? "null" : loadedComponent.getClass()) + " and " + instance.getClass(); - LOG.error(PluginManagerCore.createPluginException(errorMessage, null, instance.getClass())); + PluginException.logPluginError(LOG, errorMessage, null, instance.getClass()); } } else { diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java index 461f5cdcf52d..05b381567a87 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitThread.java @@ -2,7 +2,7 @@ package com.intellij.psi.impl; import com.google.common.annotations.VisibleForTesting; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.lang.FileASTNode; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.*; @@ -717,7 +717,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi "; file name:" + file.getName() + "; type:" + file.getFileType() + "; lang:" + file.getLanguage(); - LOG.error(PluginManagerCore.createPluginException(errorMessage, null, file.getLanguage().getClass())); + PluginException.logPluginError(LOG, errorMessage, null, file.getLanguage().getClass()); file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE); try { @@ -727,7 +727,7 @@ public class DocumentCommitThread implements Runnable, Disposable, DocumentCommi diffLog.doActualPsiChange(file); if (oldFileNode.getTextLength() != document.getTextLength()) { - LOG.error(PluginManagerCore.createPluginException("PSI is broken beyond repair in: " + file, null, file.getLanguage().getClass())); + PluginException.logPluginError(LOG, "PSI is broken beyond repair in: " + file, null, file.getLanguage().getClass()); } } finally { diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java index 2f4eae945a40..ab0cd73e7dcc 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java @@ -19,7 +19,7 @@ */ package com.intellij.psi.impl.source.tree; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.LogUtil; @@ -223,7 +223,7 @@ public class LazyParseableElement extends CompositeElement { child = child.getTreeNext(); } if (length != text.length()) { - LOG.error("Text mismatch in " + LogUtil.objectAndClass(getElementType()), PluginManagerCore.createPluginException("Text mismatch", null, getElementType().getClass()), + LOG.error("Text mismatch in " + LogUtil.objectAndClass(getElementType()), PluginException.createByClass("Text mismatch", null, getElementType().getClass()), new Attachment("code.txt", text.toString())); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java index 436bca2ae9b6..23a3910defeb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java @@ -7,7 +7,6 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.diagnostic.PluginException; -import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.lang.ExternalLanguageAnnotators; import com.intellij.lang.Language; import com.intellij.lang.annotation.Annotation; @@ -241,8 +240,7 @@ public class ExternalToolPass extends ProgressableTextEditorHighlightingPass { String path = file != null ? file.getPath() : root.getName(); final PluginException pluginException = - PluginManagerCore.createPluginException("annotator: " + annotator + " (" + annotator.getClass() + ")", - t, annotator.getClass()); + PluginException.createByClass("annotator: " + annotator + " (" + annotator.getClass() + ")", t, annotator.getClass()); LOG.error("ExternalToolPass: ", pluginException, new Attachment("root_path.txt", path)); } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 9155fd46c7b2..1f088e7fc594 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -13,7 +13,7 @@ import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.*; import com.intellij.codeInspection.ui.InspectionToolPresentation; import com.intellij.concurrency.JobLauncher; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.injected.editor.DocumentWindow; import com.intellij.lang.Language; import com.intellij.lang.annotation.HighlightSeverity; @@ -542,7 +542,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass "' (" + tool.getClass() + ") was invoked for. Message: '" + descriptor + "'.\nElement' containing file: " + context + "\nInspection invoked for file: " + myContext + "\n"; - LOG.error(PluginManagerCore.createPluginException(errorMessage, null, tool.getClass())); + PluginException.logPluginError(LOG, errorMessage, null, tool.getClass()); } boolean isInjected = myInspectInjectedPsi && file != getFile(); if (!isInjected) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java index a0a5fe1577f2..e34d7f847bc2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java @@ -8,9 +8,9 @@ import com.intellij.codeInsight.TargetElementUtil; import com.intellij.codeInsight.actions.BaseCodeInsightAction; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.navigation.NavigationUtil; +import com.intellij.diagnostic.PluginException; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.find.actions.ShowUsagesAction; -import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.ide.util.DefaultPsiElementCellRenderer; import com.intellij.ide.util.EditSourceUtil; import com.intellij.injected.editor.EditorWindow; @@ -344,9 +344,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code private static boolean assertNotNullElements(@NotNull PsiElement[] result, Class clazz) { for (PsiElement element : result) { if (element == null) { - LOG.error(PluginManagerCore.createPluginException( + PluginException.logPluginError(LOG, "Null target element is returned by 'getGotoDeclarationTargets' in " + clazz.getName(), null, clazz - )); + ); return false; } } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.kt b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.kt index e0fc06a87128..a25e90eff7e7 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.kt +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.kt @@ -4,6 +4,7 @@ package com.intellij.execution.impl import com.intellij.configurationStore.SerializableScheme import com.intellij.configurationStore.deserializeAndLoadState import com.intellij.configurationStore.serializeStateInto +import com.intellij.diagnostic.PluginException import com.intellij.execution.ExecutionBundle import com.intellij.execution.Executor import com.intellij.execution.ExecutorRegistry @@ -508,7 +509,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(val manager: return settings.getOrPut(runner) { createSettings(runner) } } catch (e: AbstractMethodError) { - RunManagerImpl.LOG.error(PluginManagerCore.createPluginException("Update failed for: ${configuration.type.displayName}, runner: ${runner.runnerId}", e, runner.javaClass)) + PluginException.logPluginError(RunManagerImpl.LOG, "Update failed for: ${configuration.type.displayName}, runner: ${runner.runnerId}", e, runner.javaClass) return null } } diff --git a/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java b/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java index 58649d0224a6..6ffb7370c9c9 100644 --- a/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java +++ b/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java @@ -2,7 +2,7 @@ package com.intellij.formatting; import com.intellij.diagnostic.AttachmentFactory; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.lang.Language; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; @@ -55,7 +55,7 @@ class RangesAssert { buffer.append('\n'); } - Throwable t = problematicLanguageClass != null ? PluginManagerCore.createPluginException("", null, problematicLanguageClass) : null; + Throwable t = problematicLanguageClass != null ? PluginException.createByClass("", null, problematicLanguageClass) : null; LOG.error(messageBuffer.toString(), t, AttachmentFactory.createContext(buffer)); } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/ide/impl/dataRules/PsiElementFromSelectionsRule.java b/platform/lang-impl/src/com/intellij/ide/impl/dataRules/PsiElementFromSelectionsRule.java index 852a23454ac6..d61fd3717f19 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/dataRules/PsiElementFromSelectionsRule.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/dataRules/PsiElementFromSelectionsRule.java @@ -16,7 +16,7 @@ package com.intellij.ide.impl.dataRules; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.diagnostic.Logger; @@ -34,7 +34,7 @@ public class PsiElementFromSelectionsRule implements GetDataRule { if (!(data instanceof Object[])) { String errorMessage = "Value for data key 'PlatformDataKeys.SELECTED_ITEMS' must be of type Object[], but " + data.getClass() + " is returned by " + dataProvider.getClass(); - LOG.error(PluginManagerCore.createPluginException(errorMessage, null, dataProvider.getClass())); + PluginException.logPluginError(LOG, errorMessage, null, dataProvider.getClass()); return null; } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java index 7b6a982b6256..fff54a28d50d 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java @@ -2,7 +2,7 @@ package com.intellij.ide.util.gotoByName; import com.intellij.concurrency.JobLauncher; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.ide.util.NavigationItemListCellRenderer; import com.intellij.navigation.ChooseByNameContributor; import com.intellij.navigation.ChooseByNameContributorEx; @@ -191,7 +191,7 @@ public abstract class ContributorsBasedGotoByModel implements ChooseByNameModelE for (NavigationItem item : itemsByName) { canceled.checkCanceled(); if (item == null) { - LOG.error(PluginManagerCore.createPluginException("null item from contributor " + contributor + " for name " + name, null, contributor.getClass())); + PluginException.logPluginError(LOG, "null item from contributor " + contributor + " for name " + name, null, contributor.getClass()); continue; } diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java index a563e3727011..10b5658f1249 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleTypeManagerImpl.java @@ -2,7 +2,6 @@ package com.intellij.openapi.module.impl; import com.intellij.diagnostic.PluginException; -import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.*; @@ -33,7 +32,7 @@ public class ModuleTypeManagerImpl extends ModuleTypeManager { public void registerModuleType(ModuleType type, boolean classpathProvider) { for (ModuleType oldType : myModuleTypes.keySet()) { if (oldType.getId().equals(type.getId())) { - LOG.error(PluginManagerCore.createPluginException("Trying to register a module type that clashes with existing one. Old=" + oldType + ", new = " + type, null, type.getClass())); + PluginException.logPluginError(LOG, "Trying to register a module type that clashes with existing one. Old=" + oldType + ", new = " + type, null, type.getClass()); return; } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java index da778d79f69f..de51df4c8bdb 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdaterImpl.java @@ -6,7 +6,7 @@ package com.intellij.openapi.roots.impl; import com.intellij.ProjectTopics; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.openapi.application.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; @@ -318,7 +318,7 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater } } catch (AbstractMethodError ame) { // acceptsDirectory is missed - if (pusher != null) throw PluginManagerCore.createPluginException("Failed to apply pusher " + pusher.getClass(), ame, pusher.getClass()); + if (pusher != null) throw PluginException.createByClass("Failed to apply pusher " + pusher.getClass(), ame, pusher.getClass()); throw ame; } } diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubVersionMap.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubVersionMap.java index 84a0161b3bbd..c8b9ff6abb43 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubVersionMap.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubVersionMap.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.stubs; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.lang.Language; import com.intellij.lang.LanguageParserDefinitions; import com.intellij.lang.ParserDefinition; @@ -227,8 +227,8 @@ class StubVersionMap { IStubFileElementType elementType = (IStubFileElementType)owner; if (elementType.getLanguage() instanceof TemplateLanguage && elementType.getStubVersion() < IStubFileElementType.getTemplateStubVersion()) { - LOG.error(PluginManagerCore.createPluginException(elementType.getLanguage() + " stub version should call super.getStubVersion()", - null, elementType.getClass())); + PluginException.logPluginError(LOG, elementType.getLanguage() + " stub version should call super.getStubVersion()", + null, elementType.getClass()); } return elementType.getStubVersion(); } else { diff --git a/platform/platform-impl/src/com/intellij/configurationStore/storeUtil.kt b/platform/platform-impl/src/com/intellij/configurationStore/storeUtil.kt index 8aeb5ca909f2..34c4295d2263 100644 --- a/platform/platform-impl/src/com/intellij/configurationStore/storeUtil.kt +++ b/platform/platform-impl/src/com/intellij/configurationStore/storeUtil.kt @@ -2,6 +2,7 @@ package com.intellij.configurationStore import com.intellij.diagnostic.IdeErrorsDialog +import com.intellij.diagnostic.PluginException import com.intellij.ide.SaveAndSyncHandler import com.intellij.ide.SaveAndSyncHandlerImpl import com.intellij.ide.plugins.PluginManagerCore @@ -127,7 +128,7 @@ fun getStateSpec(persistentStateComponent: PersistentStateComponent): Sta fun getStateSpecOrError(componentClass: Class>): State { return getStateSpec(componentClass) - ?: throw PluginManagerCore.createPluginException("No @State annotation found in $componentClass", null, componentClass) + ?: throw PluginException.createByClass("No @State annotation found in $componentClass", null, componentClass) } fun getStateSpec(originalClass: Class<*>): State? { diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 3d338624b9c3..cbc7ba45f2e9 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -352,6 +352,8 @@ + diff --git a/python/src/com/jetbrains/python/psi/impl/PyReferenceExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyReferenceExpressionImpl.java index 4709754f8dd6..38bab08cec6c 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyReferenceExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyReferenceExpressionImpl.java @@ -2,7 +2,7 @@ package com.jetbrains.python.psi.impl; import com.intellij.codeInsight.controlflow.Instruction; -import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.diagnostic.PluginException; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Ref; @@ -385,7 +385,7 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere } } catch (AbstractMethodError e) { - LOG.info(PluginManagerCore.createPluginException("Failed to get expression type via " + provider.getClass(), e, provider.getClass())); + LOG.info(PluginException.createByClass("Failed to get expression type via " + provider.getClass(), e, provider.getClass())); } } return null;