[javadoc] perform automatic supertype search recursively for interfaces

#IDEA-358073

GitOrigin-RevId: efeda57e732374963dd97dbe32c8fc1d938c5916
This commit is contained in:
Louis Vignier
2024-09-30 19:36:37 +02:00
committed by intellij-monorepo-bot
parent 0e3bfab783
commit e2f88c73c2
2 changed files with 25 additions and 3 deletions

View File

@@ -468,18 +468,19 @@ public final class JavaPsiImplementationHelperImpl extends JavaPsiImplementation
// Check interfaces
var targetInInterface = Stream.concat(Stream.of(psiClass.getImplementsListTypes()), Stream.of(psiClass.getExtendsListTypes()))
.map(type -> type.resolve())
.map(resolvedType -> findTarget(resolvedType, method, docTag, explicitSuper))
.filter(Objects::nonNull)
.map(resolvedType -> findTargetRecursively(resolvedType, method, docTag, explicitSuper, true, visitedSet))
.filter(Objects::nonNull)
.findFirst();
return targetInInterface.orElse(null);
}
private static @Nullable PsiElement findTarget(@Nullable PsiClass psiClass,
private static @Nullable PsiElement findTarget(@NotNull PsiClass psiClass,
@NotNull PsiMethod method,
@Nullable PsiDocTag docTag,
@Nullable String explicitSuper) {
if (psiClass == null || explicitSuper != null && !explicitSuper.equals(psiClass.getName())) {
if (explicitSuper != null && !explicitSuper.equals(psiClass.getName())) {
return null;
}

View File

@@ -54,6 +54,27 @@ public class JavaInheritDocNavigationTest extends LightJavaCodeInsightFixtureTes
navigateAndCheckLine(1, "* B doc");
}
public void test_inherit_doc_interface() {
myFixture.configureByText("a.java", """
interface A {
/** A doc */
void foo() {};
}
interface B extends A {
/** B doc */
@Override void foo() {};
}
interface C extends B {
/** {@inherit<caret>Doc A} */
@Override void foo() {};
}
""");
navigateAndCheckLine(0, "/** A doc */");
}
public void test_inherit_doc_explicit_super() {
myFixture.configureByText("a.java", """
class A {