When instantiating GlobalInspectionToolWrapper from GlobalInspectionTool, try to find its EP to retrieve more information (shortName/displayName/etc) from there, just like LocalInspectionTool does and to fix EA-400450 - PE: PluginManagerCore.createPluginException

GitOrigin-RevId: d4f756f59d32408e7a4fa07c1246ac13f2fd3667
This commit is contained in:
Alexey Kudravtsev
2021-11-02 11:46:58 +00:00
committed by intellij-monorepo-bot
parent 61e654235b
commit 9b0fad8655
6 changed files with 86 additions and 18 deletions
@@ -1,3 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems></problems>
<problems>
<problem>
<file>Test.java</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="Test" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
<problem>
<file>Test.java</file>
<line>2</line>
<entry_point TYPE="method" FQNAME="Test java.lang.Runnable foo(int i)" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>Test.java</file>
<line>4</line>
<entry_point TYPE="field" FQNAME="Test$1 myInt" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Field has no usages.</description>
</problem>
</problems>
@@ -1,2 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
<problems>
<problem>
<file>Test.java</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="Test" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
<problem>
<file>Test.java</file>
<line>2</line>
<entry_point TYPE="method" FQNAME="Test void foo(boolean b)" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>Test.java</file>
<line>6</line>
<entry_point TYPE="method" FQNAME="Test void foo(boolean b)" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -1,9 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="Test" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
<problem>
<file>Test.java</file>
<line>2</line>
<description>b</description>
<entry_point TYPE="method" FQNAME="Test void foo(boolean b)" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
<problem>
<file>Test.java</file>
<line>2</line>
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unused declaration</problem_class>
<description>Parameter &lt;code&gt;b&lt;/code&gt; is not used in either this method or any of its derived methods</description>
<highlighted_element>b</highlighted_element>
<language>JAVA</language>
<offset>26</offset>
<length>1</length>
</problem>
</problems>
@@ -1,3 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems></problems>
<problems>
<problem>
<file>Test.java</file>
<line>1</line>
<entry_point TYPE="class" FQNAME="Test" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>Class is not instantiated.</description>
</problem>
<problem>
<file>Test.java</file>
<line>2</line>
<entry_point TYPE="method" FQNAME="Test void foo(boolean b)" />
<problem_class id="unused" severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">unused declaration</problem_class>
<description>&lt;ul&gt;&lt;li&gt;Method owner class is never instantiated OR&lt;/li&gt;&lt;li&gt;An instantiation is not reachable from entry points.&lt;/li&gt;&lt;/ul&gt;</description>
</problem>
</problems>
@@ -2,7 +2,6 @@
package com.intellij.java.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.PossibleHeapPollutionVarargsInspection;
import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection;
import com.intellij.codeInspection.RedundantSuppressInspection;
@@ -13,22 +12,13 @@ import com.intellij.psi.impl.source.tree.injected.MyTestInjector;
import com.siyeh.ig.controlflow.FallthruInSwitchStatementInspection;
import com.siyeh.ig.inheritance.RefusedBequestInspection;
import com.siyeh.ig.jdk.AutoBoxingInspection;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
public class RemoveRedundantSuppressionTest extends LightQuickFixParameterizedTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
new MyTestInjector(getPsiManager()).injectAll(getTestRootDisposable());
enableInspectionTools(new RedundantSuppressInspection() {
@Nls(capitalization = Nls.Capitalization.Sentence)
@NotNull
@Override
public String getDisplayName() {
return InspectionsBundle.message("inspection.redundant.suppression.name");
}
},
enableInspectionTools(new RedundantSuppressInspection(),
new PossibleHeapPollutionVarargsInspection(),
new UncheckedWarningLocalInspection(),
new FallthruInSwitchStatementInspection(),
@@ -13,8 +13,8 @@ import org.jetbrains.annotations.Nullable;
public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalInspectionTool, InspectionEP> {
private static final Logger LOG = Logger.getInstance(GlobalInspectionToolWrapper.class);
public GlobalInspectionToolWrapper(@NotNull GlobalInspectionTool globalInspectionTool) {
super(globalInspectionTool, null);
public GlobalInspectionToolWrapper(@NotNull GlobalInspectionTool tool) {
super(tool, InspectionEP.GLOBAL_INSPECTION.getByKey(tool.getShortName(), GlobalInspectionToolWrapper.class, InspectionEP::getShortName));
}
public GlobalInspectionToolWrapper(@NotNull GlobalInspectionTool tool, @NotNull InspectionEP ep) {
@@ -22,7 +22,7 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalIns
}
public GlobalInspectionToolWrapper(@NotNull InspectionEP ep) {
super(null, ep);
super(ep);
}
private GlobalInspectionToolWrapper(@NotNull GlobalInspectionToolWrapper other) {