@@ -500,31 +500,36 @@ public ReferenceTree getType(DocTree dtree) {
500500 }
501501
502502 public DocTreePath getDocTreePath (DocTree dtree ) {
503- if (dcTree == null && element instanceof ExecutableElement ee ) {
504- return getInheritedDocTreePath (dtree , ee );
503+ if (dcTree == null ) {
504+ // Element does not have a doc comment.
505+ return getInheritedDocTreePath (dtree );
505506 }
506- if (path == null || dcTree == null || dtree == null ) {
507+ if (path == null || dtree == null ) {
507508 return null ;
508509 }
509510 DocTreePath dtPath = DocTreePath .getPath (path , dcTree , dtree );
510- if (dtPath == null && element instanceof ExecutableElement ee ) {
511- // The overriding element has a doc tree, but it doesn't contain what we're looking for.
512- return getInheritedDocTreePath (dtree , ee );
513- }
514- return dtPath ;
511+ // Doc tree isn't in current element's comment, it must be inherited.
512+ return dtPath == null ? getInheritedDocTreePath (dtree ) : dtPath ;
515513 }
516514
517- private DocTreePath getInheritedDocTreePath (DocTree dtree , ExecutableElement ee ) {
515+ private DocTreePath getInheritedDocTreePath (DocTree dtree ) {
518516 Utils utils = configuration .utils ;
519- var docFinder = utils .docFinder ();
520- Optional <ExecutableElement > inheritedDoc = docFinder .search (ee ,
521- (m -> {
522- Optional <ExecutableElement > optional = utils .getFullBody (m ).isEmpty () ? Optional .empty () : Optional .of (m );
523- return Result .fromOptional (optional );
524- })).toOptional ();
525- return inheritedDoc .isEmpty () || inheritedDoc .get ().equals (ee )
526- ? null
527- : utils .getCommentHelper (inheritedDoc .get ()).getDocTreePath (dtree );
517+ if (element instanceof ExecutableElement ee ) {
518+ var docFinder = utils .docFinder ();
519+ Optional <ExecutableElement > inheritedDoc = docFinder .search (ee ,
520+ (m -> {
521+ Optional <ExecutableElement > optional = utils .getFullBody (m ).isEmpty () ? Optional .empty () : Optional .of (m );
522+ return Result .fromOptional (optional );
523+ })).toOptional ();
524+ return inheritedDoc .isEmpty () || inheritedDoc .get ().equals (ee )
525+ ? null
526+ : utils .getCommentHelper (inheritedDoc .get ()).getDocTreePath (dtree );
527+ } else if (element instanceof TypeElement te
528+ && te .getEnclosingElement () instanceof TypeElement enclType ) {
529+ // Block tags can be inherited from enclosing types.
530+ return utils .getCommentHelper (enclType ).getDocTreePath (dtree );
531+ }
532+ return null ;
528533 }
529534
530535 /**
0 commit comments