mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 13:20:53 +07:00
IDEA-142346
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user