diff --git a/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java b/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java index 0e7de93d3185..bbbf5888486f 100644 --- a/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java +++ b/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,6 +120,7 @@ public abstract class BaseJavaLocalInspectionTool extends LocalInspectionTool i } public boolean isSuppressedFor(final PsiElement element) { - return SuppressManager.getInstance().isSuppressedFor(element, getID()) || SuppressManager.getInstance().isSuppressedFor(element, getAlternativeID()); + final SuppressManager manager = SuppressManager.getInstance(); + return manager.isSuppressedFor(element, getID()) || manager.isSuppressedFor(element, getAlternativeID()); } } diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java index 7e111ae56fd2..1d09e3d976ab 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionEP.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,10 @@ import java.util.ResourceBundle; /** * @author Dmitry Avdeev - * Date: 9/27/11 + * @since 27.09.2011 * @see LocalInspectionEP */ -public class InspectionEP extends LanguageExtensionPoint { +public class InspectionEP extends LanguageExtensionPoint implements InspectionProfileEntry.DefaultNameProvider { /** @see GlobalInspectionTool */ public final static ExtensionPointName GLOBAL_INSPECTION = ExtensionPointName.create("com.intellij.globalInspection"); @@ -138,7 +138,9 @@ public class InspectionEP extends LanguageExtensionPoint { public InspectionProfileEntry instantiateTool() { try { - return instantiate(implementationClass, ApplicationManager.getApplication().getPicoContainer()); + final InspectionProfileEntry entry = instantiate(implementationClass, ApplicationManager.getApplication().getPicoContainer()); + entry.myNameProvider = this; + return entry; } catch (ClassNotFoundException e) { throw new RuntimeException(e); diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index 2d235798a7ab..3a85dfabe162 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import java.util.Set; /** * @author anna - * Date: 28-Nov-2005 + * @since 28-Nov-2005 */ public abstract class InspectionProfileEntry { public static final String GENERAL_GROUP_NAME = InspectionsBundle.message("inspection.general.tools.group.name"); @@ -52,6 +52,14 @@ public abstract class InspectionProfileEntry { private static final Object BLACK_LIST_LOCK = new Object(); private Boolean myUseNewSerializer = null; + interface DefaultNameProvider { + @Nullable String getShortName(); + @Nullable String getDisplayName(); + @Nullable String getGroupDisplayName(); + } + + protected volatile DefaultNameProvider myNameProvider = null; + /** * @see InspectionEP#groupDisplayName * @see InspectionEP#groupKey @@ -59,6 +67,12 @@ public abstract class InspectionProfileEntry { */ @Nls @NotNull public String getGroupDisplayName() { + if (myNameProvider != null) { + final String name = myNameProvider.getGroupDisplayName(); + if (name != null) { + return name; + } + } LOG.error(getClass() + ": group display name should be overridden or configured via XML " + getClass()); return ""; } @@ -82,6 +96,12 @@ public abstract class InspectionProfileEntry { */ @Nls @NotNull public String getDisplayName() { + if (myNameProvider != null) { + final String name = myNameProvider.getDisplayName(); + if (name != null) { + return name; + } + } LOG.error(getClass() + ": display name should be overridden or configured via XML " + getClass()); return ""; } @@ -93,6 +113,12 @@ public abstract class InspectionProfileEntry { */ @NonNls @NotNull public String getShortName() { + if (myNameProvider != null) { + final String name = myNameProvider.getShortName(); + if (name != null) { + return name; + } + } return getShortName(getClass().getSimpleName()); } diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionEP.java b/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionEP.java index 3db0a1679800..27da039d374d 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionEP.java +++ b/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionEP.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,13 @@ package com.intellij.codeInspection; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.util.xmlb.annotations.Attribute; +import org.jetbrains.annotations.Nullable; /** * @author Dmitry Avdeev - * Date: 9/28/11 + * @since 28.09.2011 */ -public class LocalInspectionEP extends InspectionEP { +public class LocalInspectionEP extends InspectionEP implements LocalInspectionTool.LocalDefaultNameProvider { public final static ExtensionPointName LOCAL_INSPECTION = ExtensionPointName.create("com.intellij.localInspection"); @@ -37,4 +38,16 @@ public class LocalInspectionEP extends InspectionEP { @Attribute("unfair") public boolean unfair; + + @Nullable + @Override + public String getID() { + return id; + } + + @Nullable + @Override + public String getAlternativeID() { + return alternativeId; + } } diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionTool.java b/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionTool.java index 7ab3148747a2..3423b7112281 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionTool.java +++ b/platform/lang-api/src/com/intellij/codeInspection/LocalInspectionTool.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,10 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.codeInspection; import com.intellij.openapi.diagnostic.Logger; @@ -31,10 +27,19 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +/** + * @author max + */ public abstract class LocalInspectionTool extends InspectionProfileEntry { public static final LocalInspectionTool[] EMPTY_ARRAY = new LocalInspectionTool[0]; + private static final Logger LOG = Logger.getInstance("#" + LocalInspectionTool.class.getName()); + interface LocalDefaultNameProvider extends DefaultNameProvider { + @Nullable String getID(); + @Nullable String getAlternativeID(); + } + /** * Pattern used for inspection ID validation. */ @@ -56,12 +61,21 @@ public abstract class LocalInspectionTool extends InspectionProfileEntry { @NonNls @NotNull public String getID() { + if (myNameProvider instanceof LocalDefaultNameProvider) { + final String id = ((LocalDefaultNameProvider)myNameProvider).getID(); + if (id != null) { + return id; + } + } return getShortName(); } @NonNls @Nullable public String getAlternativeID() { + if (myNameProvider instanceof LocalDefaultNameProvider) { + return ((LocalDefaultNameProvider)myNameProvider).getAlternativeID(); + } return null; }