mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ComparableImplementedButEqualsNotOverriddenInspection: don't add javadoc to anonymous classes, there's no place for it
GitOrigin-RevId: 30c105c2be29efc6f882c7074dcfac170a6b21cb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ca68642d92
commit
76d9195dc8
@@ -24,5 +24,6 @@
|
||||
<orderEntry type="module" module-name="intellij.java" />
|
||||
<orderEntry type="module" module-name="intellij.jvm.analysis.impl" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.ui" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+11
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.bugs;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -39,6 +40,10 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseInspection {
|
||||
@VisibleForTesting
|
||||
static final String ADD_NOTE_FIX_NAME = "Add 'ordering inconsistent with equals' JavaDoc note";
|
||||
@VisibleForTesting
|
||||
static final String GENERATE_EQUALS_FIX_NAME = "Generate 'equals()' method";
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -55,6 +60,10 @@ public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseI
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
if (infos[0] instanceof PsiAnonymousClass) {
|
||||
return new InspectionGadgetsFix[] {new GenerateEqualsMethodFix()};
|
||||
}
|
||||
|
||||
return new InspectionGadgetsFix[] {
|
||||
new GenerateEqualsMethodFix(),
|
||||
new AddNoteFix()
|
||||
@@ -66,7 +75,7 @@ public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseI
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Generate 'equals()' method";
|
||||
return GENERATE_EQUALS_FIX_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +106,7 @@ public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseI
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add 'ordering inconsistent with equals' JavaDoc note";
|
||||
return ADD_NOTE_FIX_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
abstract class A implements Comparable<A> {
|
||||
{
|
||||
new <warning descr="Class 'A' implements 'java.lang.Comparable' but does not override 'equals()'"><caret>A</warning>() {
|
||||
public int compareTo(A a){
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+6
@@ -31,6 +31,12 @@ public class ComparableImplementedButEqualsNotOverriddenInspectionTest extends L
|
||||
public void testAbstractClass3() { doTest(); }
|
||||
public void testNote() { doTest(); }
|
||||
|
||||
public void testNoFixForAnonymousClass() {
|
||||
doTest();
|
||||
assertNotNull(myFixture.findSingleIntention(ComparableImplementedButEqualsNotOverriddenInspection.GENERATE_EQUALS_FIX_NAME));
|
||||
assertEmpty(myFixture.filterAvailableIntentions(ComparableImplementedButEqualsNotOverriddenInspection.ADD_NOTE_FIX_NAME));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
|
||||
Reference in New Issue
Block a user