IDEA-142346

This commit is contained in:
Alexey Kudravtsev
2015-08-28 13:36:20 +03:00
parent 45f5694b28
commit 6d831ef91e
3 changed files with 46 additions and 3 deletions

View File

@@ -90,6 +90,10 @@ public class FindSuperElementsHelper {
if (superInterface == null) {
continue;
}
if (containingClass.isInheritor(superInterface, true)) {
// if containingClass implements the superInterface then it's not a sibling inheritance but a pretty boring the usual one
continue;
}
// calculate substitutor of containingClass --> inheritor
PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(containingClass, inheritor, PsiSubstitutor.EMPTY);
@@ -100,10 +104,11 @@ public class FindSuperElementsHelper {
final MethodSignature derivedSignature = method.getSignature(PsiSubstitutor.EMPTY);
boolean isOverridden = MethodSignatureUtil.isSubsignature(superSignature, derivedSignature);
if (isOverridden) {
result[0] = superMethod;
return false;
if (!isOverridden) {
continue;
}
result[0] = superMethod;
return false;
}
}
return true;

View File

@@ -0,0 +1,17 @@
package z;
interface FileType {
String getName();
}
abstract class LanguageFileType implements FileType {
}
abstract class OCBaseLanguageFileType extends LanguageFileType {
public String <caret>getName() {
return "";
}
}
public class XibFileType extends OCBaseLanguageFileType implements FileType {
}

View File

@@ -117,4 +117,25 @@ public class JavaGotoSuperTest extends LightDaemonAnalyzerTestCase {
checkResultByFile(getBasePath() + "SiblingInheritance.java");
}
public void testDoNotShowSiblingInheritanceLineMarkerIfSubclassImplementsTheSameInterfaceAsTheCurrentClass() throws Throwable {
configureByFile(getBasePath() + "DeceivingSiblingInheritance.java");
PsiJavaFile file = (PsiJavaFile)getFile();
PsiClass OCBaseLanguageFileType = JavaPsiFacade.getInstance(getProject()).findClass("z.OCBaseLanguageFileType", GlobalSearchScope.fileScope(file));
PsiMethod getName = OCBaseLanguageFileType.getMethods()[0];
assertEquals("getName", getName.getName());
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
List<LineMarkerInfo> inMyClass = ContainerUtil.filter(markers, info -> {
return OCBaseLanguageFileType.getTextRange().containsRange(info.startOffset, info.endOffset);
});
assertTrue(inMyClass.toString(), inMyClass.size() == 2);
LineMarkerInfo iMarker = findMarkerWithElement(inMyClass, getName.getNameIdentifier());
assertSame(MarkerType.OVERRIDING_METHOD.getNavigationHandler(), iMarker.getNavigationHandler());
LineMarkerInfo aMarker = findMarkerWithElement(inMyClass, OCBaseLanguageFileType.getNameIdentifier());
assertSame(MarkerType.SUBCLASSED_CLASS.getNavigationHandler(), aMarker.getNavigationHandler());
}
}