Skip to content

Commit

Permalink
Resolve @inheritTag to most direct parent declaring a doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Apr 10, 2024
1 parent 54b96c8 commit 3f28f21
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,18 @@ public IJavaElement[] codeSelect(int offset, int length) throws JavaModelExcepti
if (typeBinding.getSuperclass() != null) {
types.add(typeBinding.getSuperclass());
}
var overridenMethods = types.stream().flatMap(type -> Arrays.stream(type.getDeclaredMethods()))
.filter(m -> methodBinding.overrides(m)) // should resolve to the 1st parent method which has doc
.map(IMethodBinding::getJavaElement)
.filter(Objects::nonNull)
.distinct()
.findFirst()
.map(element -> new IJavaElement[] { element });
if (overridenMethods.isPresent()) {
return overridenMethods.get();
while (!types.isEmpty()) {
ITypeBinding type = types.remove(0);
for (IMethodBinding m : Arrays.stream(type.getDeclaredMethods()).filter(methodBinding::overrides).toList()) {
if (m.getJavaElement() instanceof IMethod methodElement && methodElement.getJavadocRange() != null) {
return new IJavaElement[] { methodElement };
} else {
types.addAll(Arrays.asList(type.getInterfaces()));
if (type.getSuperclass() != null) {
types.add(type.getSuperclass());
}
}
}
}
}
IJavaElement element = methodBinding.getJavaElement();
Expand Down

0 comments on commit 3f28f21

Please sign in to comment.