@@ -277,7 +277,8 @@ MatchingLinkResult _getMatchingLinkElement(
277
277
}
278
278
refModelElement = new ModelElement .from (searchElement, refLibrary);
279
279
if (! refModelElement.isCanonical) {
280
- refModelElement.warn (PackageWarning .noCanonicalFound);
280
+ refModelElement.warn (PackageWarning .noCanonicalFound,
281
+ referredFrom: element);
281
282
// Don't warn about doc references because that's covered by the no
282
283
// canonical library found message.
283
284
return new MatchingLinkResult (null , null , warn: false );
@@ -405,17 +406,18 @@ Element _findRefElementInLibrary(
405
406
_getResultsForClass (
406
407
tryClass, codeRefChomped, results, codeRef, package);
407
408
}
409
+ results.remove (null );
408
410
if (results.isNotEmpty) break ;
409
411
}
410
- // Sometimes documentation refers to classes that are further up the chain.
411
- // Get those too.
412
+
412
413
if (results.isEmpty && realClass != null ) {
413
414
for (Class superClass
414
415
in realClass.superChain.map ((et) => et.element as Class )) {
415
416
if (! tryClasses.contains (superClass)) {
416
417
_getResultsForClass (
417
418
superClass, codeRefChomped, results, codeRef, package);
418
419
}
420
+ results.remove (null );
419
421
if (results.isNotEmpty) break ;
420
422
}
421
423
}
@@ -551,7 +553,8 @@ Element _findRefElementInLibrary(
551
553
result = results.first.element;
552
554
} else {
553
555
element.warn (PackageWarning .ambiguousDocReference,
554
- "[$codeRef ] => ${results .map ((r ) => "'${r .fullyQualifiedName }'" ).join (", " )}" );
556
+ message:
557
+ "[$codeRef ] => ${results .map ((r ) => "'${r .fullyQualifiedName }'" ).join (", " )}" );
555
558
result = results.first.element;
556
559
}
557
560
return result;
@@ -575,8 +578,9 @@ void _getResultsForClass(Class tryClass, String codeRefChomped,
575
578
} else {
576
579
// TODO(jcollins-g): get rid of reimplementation of identifier resolution
577
580
// 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 ));
580
584
// This seems duplicitous with our caller, but the preferredClass
581
585
// hint matters with findCanonicalModelElementFor.
582
586
// TODO(jcollins-g): This makes our caller ~O(n^2) vs length of superChain.
@@ -625,6 +629,7 @@ void _getResultsForClass(Class tryClass, String codeRefChomped,
625
629
}
626
630
}
627
631
}
632
+ results.remove (null );
628
633
if (results.isNotEmpty) break ;
629
634
if (c.fullyQualifiedNameWithoutLibrary == codeRefChomped) {
630
635
results.add (c);
@@ -637,9 +642,6 @@ void _getResultsForClass(Class tryClass, String codeRefChomped,
637
642
638
643
String _linkDocReference (String codeRef, Documentable documentable,
639
644
NodeList <CommentReference > commentRefs) {
640
- // TODO(jcollins-g): Refactor so that doc operations work on the
641
- // documented element.
642
- documentable = documentable.overriddenDocumentedElement;
643
645
MatchingLinkResult result;
644
646
result = _getMatchingLinkElement (codeRef, documentable, commentRefs);
645
647
final ModelElement linkedElement = result.element;
@@ -658,15 +660,16 @@ String _linkDocReference(String codeRef, Documentable documentable,
658
660
}
659
661
} else {
660
662
if (result.warn) {
661
- documentable.warn (PackageWarning .unresolvedDocReference, codeRef);
663
+ documentable.warn (PackageWarning .unresolvedDocReference,
664
+ message: codeRef, referredFrom: documentable.documentationFrom);
662
665
}
663
666
return '<code>${HTML_ESCAPE .convert (label )}</code>' ;
664
667
}
665
668
}
666
669
667
670
String _renderMarkdownToHtml (Documentable element) {
671
+ NodeList <CommentReference > commentRefs = _getCommentRefs (element);
668
672
md.Node _linkResolver (String name) {
669
- NodeList <CommentReference > commentRefs = _getCommentRefs (element);
670
673
return new md.Text (_linkDocReference (name, element, commentRefs));
671
674
}
672
675
@@ -700,7 +703,7 @@ void _showWarningsForGenericsOutsideSquareBracketsBlocks(
700
703
postContext.replaceAll (new RegExp (r'\n.*$' , multiLine: true ), '' );
701
704
String errorMessage = "$priorContext $postContext " ;
702
705
// TODO(jcollins-g): allow for more specific error location inside comments
703
- element.warn (PackageWarning .typeAsHtml, errorMessage);
706
+ element.warn (PackageWarning .typeAsHtml, message : errorMessage);
704
707
});
705
708
}
706
709
}
0 commit comments