diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspectionMerger.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspectionMerger.java
index 5092410f419e..75be9546415b 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspectionMerger.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspectionMerger.java
@@ -15,12 +15,12 @@
*/
package com.intellij.codeInspection.deadCode;
-import com.intellij.codeInspection.ex.InspectionElementsMerger;
+import com.intellij.codeInspection.ex.InspectionElementsMergerBase;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;
-public class UnusedDeclarationInspectionMerger extends InspectionElementsMerger {
+public class UnusedDeclarationInspectionMerger extends InspectionElementsMergerBase {
private static final String UNUSED_SYMBOL = "UNUSED_SYMBOL";
private static final String UNUSED_DECLARATION = "UnusedDeclaration";
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
index 7a5002f50a7d..85b9202d71fd 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
@@ -360,6 +360,22 @@ public class InspectionProfileTest extends LightIdeaTestCase {
"");
}
+ public void testMergedMisspelledInspections() throws Exception {
+ checkMergedNoChanges("\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "");
+ checkMergedNoChanges("\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "");
+ }
+
public void testDisabledUnusedDeclarationWithChanges() throws Exception {
checkMergedNoChanges("\n" +
" \n" +
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
index 31677af37d92..c37f23c03d38 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
@@ -16,9 +16,11 @@
package com.intellij.codeInspection;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
+import com.intellij.codeInspection.ex.InspectionElementsMerger;
import com.intellij.lang.Language;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
@@ -81,6 +83,18 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool {
return true;
}
}
+
+ final InspectionElementsMerger merger = InspectionElementsMerger.getMerger(getShortName());
+ if (merger != null) {
+ for (String sourceToolId : merger.getSourceToolNames()) {
+ for (InspectionSuppressor suppressor : suppressors) {
+ if (isSuppressed(sourceToolId, suppressor, element)) {
+ return true;
+ }
+ }
+ }
+ }
+
return false;
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionElementsMerger.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionElementsMerger.java
new file mode 100644
index 000000000000..b4c321ba41f9
--- /dev/null
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionElementsMerger.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection.ex;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.extensions.Extensions;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * Merges multiple inspections settings {@link #getSourceToolNames()} into another one {@link #getMergedToolName()}
+ *
+ * {@see com.intellij.codeInspection.ex.InspectionElementsMergerBase} to provide more fine control over xml
+ */
+public abstract class InspectionElementsMerger {
+ public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.inspectionElementsMerger");
+ private static Map ourMergers;
+
+ @Nullable
+ public synchronized static InspectionElementsMerger getMerger(String shortName) {
+ if (ourMergers == null) {
+ ourMergers = new HashMap<>();
+ for (InspectionElementsMerger merger : Extensions.getExtensions(EP_NAME)) {
+ ourMergers.put(merger.getMergedToolName(), merger);
+ }
+ }
+ return ourMergers.get(shortName);
+ }
+
+ public abstract String getMergedToolName();
+ public abstract String[] getSourceToolNames();
+}
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionElementsMerger.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionElementsMergerBase.java
similarity index 90%
rename from platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionElementsMerger.java
rename to platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionElementsMergerBase.java
index 910df0c1ba36..991a41de47be 100644
--- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionElementsMerger.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionElementsMergerBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -16,21 +16,14 @@
package com.intellij.codeInspection.ex;
import com.intellij.lang.annotation.HighlightSeverity;
-import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;
import java.util.*;
-/**
- * Merges multiple inspections settings {@link #getSourceToolNames()} into another one {@link #getMergedToolName()}
- */
-public abstract class InspectionElementsMerger {
- public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.inspectionElementsMerger");
- protected abstract String getMergedToolName();
- protected abstract String[] getSourceToolNames();
+public abstract class InspectionElementsMergerBase extends InspectionElementsMerger {
/**
* serialize old inspection settings as they could appear in old profiles
@@ -158,4 +151,22 @@ public abstract class InspectionElementsMerger {
}
}
}
+
+ public static class InspectionElementsMergerDelegate extends InspectionElementsMergerBase {
+ private final InspectionElementsMerger myMerger;
+
+ public InspectionElementsMergerDelegate(InspectionElementsMerger merger) {
+ myMerger = merger;
+ }
+
+ @Override
+ public String getMergedToolName() {
+ return myMerger.getMergedToolName();
+ }
+
+ @Override
+ public String[] getSourceToolNames() {
+ return myMerger.getSourceToolNames();
+ }
+ }
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
index 185825abc85c..6c8ab275e5a9 100644
--- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
@@ -71,7 +71,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
public static final String DEFAULT_PROFILE_NAME = "Default";
@TestOnly
public static boolean INIT_INSPECTIONS = false;
- private static Map ourMergers;
private final InspectionToolRegistrar myRegistrar;
@NotNull
private final Map myUninstalledInspectionsSettings;
@@ -120,17 +119,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
myUninstalledInspectionsSettings = new TreeMap();
}
- @NotNull
- private static synchronized Map getMergers() {
- if (ourMergers == null) {
- ourMergers = new LinkedHashMap();
- for (InspectionElementsMerger merger : Extensions.getExtensions(InspectionElementsMerger.EP_NAME)) {
- ourMergers.put(merger.getMergedToolName(), merger);
- }
- }
- return ourMergers;
- }
-
@NotNull
public static InspectionProfileImpl createSimple(@NotNull String name,
@NotNull final Project project,
@@ -338,9 +326,9 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
private void markSettingsMerged(String toolName, Element element) {
//add marker if already merged but result is now default (-> empty node)
- final String mergedName = InspectionElementsMerger.getMergedMarkerName(toolName);
+ final String mergedName = InspectionElementsMergerBase.getMergedMarkerName(toolName);
if (!myUninstalledInspectionsSettings.containsKey(mergedName)) {
- final InspectionElementsMerger merger = getMergers().get(toolName);
+ final InspectionElementsMergerBase merger = getMerger(toolName);
if (merger != null && merger.markSettingsMerged(myUninstalledInspectionsSettings)) {
element.addContent(new Element(INSPECTION_TOOL_TAG).setAttribute(CLASS_TAG, mergedName));
}
@@ -349,7 +337,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
private boolean areSettingsMerged(String toolName, Element inspectionElement) {
//skip merged settings as they could be restored from already provided data
- final InspectionElementsMerger merger = getMergers().get(toolName);
+ final InspectionElementsMergerBase merger = getMerger(toolName);
return merger != null && merger.areSettingsMerged(myUninstalledInspectionsSettings, inspectionElement);
}
@@ -619,8 +607,8 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
if (element != null) {
toolsList.readExternal(element, this, dependencies);
}
- else if (!myUninstalledInspectionsSettings.containsKey(InspectionElementsMerger.getMergedMarkerName(shortName))) {
- final InspectionElementsMerger merger = getMergers().get(shortName);
+ else if (!myUninstalledInspectionsSettings.containsKey(InspectionElementsMergerBase.getMergedMarkerName(shortName))) {
+ final InspectionElementsMergerBase merger = getMerger(shortName);
if (merger != null) {
final Element merged = merger.merge(myUninstalledInspectionsSettings);
if (merged != null) {
@@ -635,6 +623,25 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
myTools.put(shortName, toolsList);
}
+ @Nullable
+ private static InspectionElementsMergerBase getMerger(String shortName) {
+ final InspectionElementsMerger merger = InspectionElementsMerger.getMerger(shortName);
+ if (merger instanceof InspectionElementsMergerBase) {
+ return (InspectionElementsMergerBase)merger;
+ }
+ return merger != null ? new InspectionElementsMergerBase() {
+ @Override
+ public String getMergedToolName() {
+ return merger.getMergedToolName();
+ }
+
+ @Override
+ public String[] getSourceToolNames() {
+ return merger.getSourceToolNames();
+ }
+ } : null;
+ }
+
@Nullable
@Transient
public String[] getScopesOrder() {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
index a92efd6b7282..3d44b1829183 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
@@ -3,6 +3,7 @@
+
-
-
-
-
-
-
+ level="WARNING" implementationClass="com.siyeh.ig.naming.MisspelledMethodNameInspection"/>