diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MarkerInterfaceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MarkerInterfaceInspection.java index 4b65470c012f..989405f0c338 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MarkerInterfaceInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/MarkerInterfaceInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,7 @@ */ package com.siyeh.ig.classlayout; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiClassType; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiMethod; +import com.intellij.psi.*; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -26,17 +23,20 @@ import org.jetbrains.annotations.NotNull; public class MarkerInterfaceInspection extends BaseInspection { + @Override @NotNull public String getDisplayName() { return InspectionGadgetsBundle.message("marker.interface.display.name"); } + @Override @NotNull protected String buildErrorString(Object... infos) { return InspectionGadgetsBundle.message( "marker.interface.problem.descriptor"); } + @Override public BaseInspectionVisitor buildVisitor() { return new MarkerInterfaceVisitor(); } @@ -45,7 +45,6 @@ public class MarkerInterfaceInspection extends BaseInspection { @Override public void visitClass(@NotNull PsiClass aClass) { - // no call to super, so that it doesn't drill down to inner classes if (!aClass.isInterface() || aClass.isAnnotationType()) { return; } @@ -57,9 +56,22 @@ public class MarkerInterfaceInspection extends BaseInspection { if (methods.length != 0) { return; } - final PsiClassType[] extendsList = aClass.getExtendsListTypes(); - if (extendsList.length > 1) { - return; + final PsiReferenceList extendsList = aClass.getExtendsList(); + if (extendsList != null) { + final PsiJavaCodeReferenceElement[] referenceElements = extendsList.getReferenceElements(); + if (referenceElements.length > 0) { + if (referenceElements.length > 1) { + return; + } + final PsiReferenceParameterList parameterList = referenceElements[0].getParameterList(); + if (parameterList == null) { + return; + } + final PsiTypeElement[] typeParameterElements = parameterList.getTypeParameterElements(); + if (typeParameterElements.length != 0) { + return; + } + } } registerClassError(aClass); } diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html index 502650107988..37abc13b9278 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html @@ -2,7 +2,8 @@
This inspection reports "marker" interfaces which have no methods or fields. Such interfaces may be confusing, and normally indicate a design failure. -Interfaces which extend two or more other interfaces will not be reported by +Interfaces which extend two or more other interfaces or or interfaces +which specialize the generic type of their superinterface will not be reported by this inspection.
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/MarkerInterface.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/MarkerInterface.java
deleted file mode 100644
index 69bf2830166c..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/MarkerInterface.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.siyeh.igtest.classlayout;
-
-public interface MarkerInterface {
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/marker_interface/MarkerInterface.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/marker_interface/MarkerInterface.java
new file mode 100644
index 000000000000..baa443e8f28c
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/classlayout/marker_interface/MarkerInterface.java
@@ -0,0 +1,6 @@
+package com.siyeh.igtest.classlayout.marker_interface;
+
+public interface MarkerInterface {
+}
+interface X