@@ -277,7 +277,8 @@ MatchingLinkResult _getMatchingLinkElement(
277277 }
278278 refModelElement = new ModelElement .from (searchElement, refLibrary);
279279 if (! refModelElement.isCanonical) {
280- refModelElement.warn (PackageWarning .noCanonicalFound);
280+ refModelElement.warn (PackageWarning .noCanonicalFound,
281+ referredFrom: element);
281282 // Don't warn about doc references because that's covered by the no
282283 // canonical library found message.
283284 return new MatchingLinkResult (null , null , warn: false );
@@ -405,17 +406,18 @@ Element _findRefElementInLibrary(
405406 _getResultsForClass (
406407 tryClass, codeRefChomped, results, codeRef, package);
407408 }
409+ results.remove (null );
408410 if (results.isNotEmpty) break ;
409411 }
410- // Sometimes documentation refers to classes that are further up the chain.
411- // Get those too.
412+
412413 if (results.isEmpty && realClass != null ) {
413414 for (Class superClass
414415 in realClass.superChain.map ((et) => et.element as Class )) {
415416 if (! tryClasses.contains (superClass)) {
416417 _getResultsForClass (
417418 superClass, codeRefChomped, results, codeRef, package);
418419 }
420+ results.remove (null );
419421 if (results.isNotEmpty) break ;
420422 }
421423 }
@@ -551,7 +553,8 @@ Element _findRefElementInLibrary(
551553 result = results.first.element;
552554 } else {
553555 element.warn (PackageWarning .ambiguousDocReference,
554- "[$codeRef ] => ${results .map ((r ) => "'${r .fullyQualifiedName }'" ).join (", " )}" );
556+ message:
557+ "[$codeRef ] => ${results .map ((r ) => "'${r .fullyQualifiedName }'" ).join (", " )}" );
555558 result = results.first.element;
556559 }
557560 return result;
@@ -575,8 +578,9 @@ void _getResultsForClass(Class tryClass, String codeRefChomped,
575578 } else {
576579 // TODO(jcollins-g): get rid of reimplementation of identifier resolution
577580 // or integrate into ModelElement in a simpler way.
578- List <Class > superChain = [];
579- superChain.add (tryClass);
581+ List <Class > superChain = [tryClass];
582+ superChain
583+ .addAll (tryClass.interfaces.map ((t) => t.returnElement as Class ));
580584 // This seems duplicitous with our caller, but the preferredClass
581585 // hint matters with findCanonicalModelElementFor.
582586 // TODO(jcollins-g): This makes our caller ~O(n^2) vs length of superChain.
@@ -625,6 +629,7 @@ void _getResultsForClass(Class tryClass, String codeRefChomped,
625629 }
626630 }
627631 }
632+ results.remove (null );
628633 if (results.isNotEmpty) break ;
629634 if (c.fullyQualifiedNameWithoutLibrary == codeRefChomped) {
630635 results.add (c);
@@ -637,9 +642,6 @@ void _getResultsForClass(Class tryClass, String codeRefChomped,
637642
638643String _linkDocReference (String codeRef, Documentable documentable,
639644 NodeList <CommentReference > commentRefs) {
640- // TODO(jcollins-g): Refactor so that doc operations work on the
641- // documented element.
642- documentable = documentable.overriddenDocumentedElement;
643645 MatchingLinkResult result;
644646 result = _getMatchingLinkElement (codeRef, documentable, commentRefs);
645647 final ModelElement linkedElement = result.element;
@@ -658,15 +660,16 @@ String _linkDocReference(String codeRef, Documentable documentable,
658660 }
659661 } else {
660662 if (result.warn) {
661- documentable.warn (PackageWarning .unresolvedDocReference, codeRef);
663+ documentable.warn (PackageWarning .unresolvedDocReference,
664+ message: codeRef, referredFrom: documentable.documentationFrom);
662665 }
663666 return '<code>${HTML_ESCAPE .convert (label )}</code>' ;
664667 }
665668}
666669
667670String _renderMarkdownToHtml (Documentable element) {
671+ NodeList <CommentReference > commentRefs = _getCommentRefs (element);
668672 md.Node _linkResolver (String name) {
669- NodeList <CommentReference > commentRefs = _getCommentRefs (element);
670673 return new md.Text (_linkDocReference (name, element, commentRefs));
671674 }
672675
@@ -700,7 +703,7 @@ void _showWarningsForGenericsOutsideSquareBracketsBlocks(
700703 postContext.replaceAll (new RegExp (r'\n.*$' , multiLine: true ), '' );
701704 String errorMessage = "$priorContext $postContext " ;
702705 // TODO(jcollins-g): allow for more specific error location inside comments
703- element.warn (PackageWarning .typeAsHtml, errorMessage);
706+ element.warn (PackageWarning .typeAsHtml, message : errorMessage);
704707 });
705708 }
706709}
0 commit comments