mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-144571 (False positive inspection "Abstract class may be interface" on non-static inner class)
This commit is contained in:
+9
@@ -29,6 +29,8 @@ import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.memory.InnerClassReferenceVisitor;
|
||||
import com.siyeh.ig.psiutils.ClassUtils;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -210,6 +212,13 @@ public class ClassMayBeInterfaceInspection extends BaseInspection {
|
||||
if (!mayBeInterface(aClass)) {
|
||||
return;
|
||||
}
|
||||
if (ClassUtils.isInnerClass(aClass)) {
|
||||
final InnerClassReferenceVisitor visitor = new InnerClassReferenceVisitor(aClass);
|
||||
aClass.accept(visitor);
|
||||
if (!visitor.canInnerClassBeStatic()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
registerClassError(aClass);
|
||||
}
|
||||
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package com.siyeh.igtest.classlayout;
|
||||
|
||||
public abstract class ClassMayBeInterfaceInspection
|
||||
{
|
||||
public static final int foo = 1;
|
||||
|
||||
public abstract void bar();
|
||||
}
|
||||
+11
@@ -46,6 +46,17 @@ public class ClassMayBeInterfaceInspectionTest extends LightInspectionTestCase {
|
||||
" public class A {}\n" +
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testMethodCantBeDefault() {
|
||||
doTest("class Issue {\n" +
|
||||
" public abstract class Inner {\n" +
|
||||
" public Issue getParent() {\n" +
|
||||
" return Issue.this;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
final ClassMayBeInterfaceInspection inspection = new ClassMayBeInterfaceInspection();
|
||||
|
||||
Reference in New Issue
Block a user