@@ -154,9 +154,8 @@ final RegExp _hide_schemes = new RegExp('^(http|https)://');
154
154
155
155
class MatchingLinkResult {
156
156
final ModelElement element;
157
- final String label;
158
157
final bool warn;
159
- MatchingLinkResult (this .element, this .label, {this .warn: true });
158
+ MatchingLinkResult (this .element, {this .warn: true });
160
159
}
161
160
162
161
class IterableBlockParser extends md.BlockParser {
@@ -244,13 +243,12 @@ MatchingLinkResult _getMatchingLinkElement(
244
243
// By debugging inspection, it seems correct to not warn when we don't have
245
244
// CommentReferences; there's actually nothing that needs resolving in
246
245
// that case.
247
- if (commentRefs == null )
248
- return new MatchingLinkResult (null , null , warn: false );
246
+ if (commentRefs == null ) return new MatchingLinkResult (null , warn: false );
249
247
250
248
if (! codeRef.contains (isConstructor) &&
251
249
codeRef.contains (notARealDocReference)) {
252
250
// Don't waste our time on things we won't ever find.
253
- return new MatchingLinkResult (null , null , warn: false );
251
+ return new MatchingLinkResult (null , warn: false );
254
252
}
255
253
256
254
ModelElement refModelElement;
@@ -283,20 +281,20 @@ MatchingLinkResult _getMatchingLinkElement(
283
281
// TODO(jcollins-g): remove squelching of non-canonical warnings here
284
282
// once we no longer process full markdown for
285
283
// oneLineDocs (#1417)
286
- return new MatchingLinkResult (null , null , warn: element.isCanonical);
284
+ return new MatchingLinkResult (null , warn: element.isCanonical);
287
285
}
288
286
289
287
// Ignore all parameters.
290
288
if (refModelElement is Parameter || refModelElement is TypeParameter )
291
- return new MatchingLinkResult (null , null , warn: false );
289
+ return new MatchingLinkResult (null , warn: false );
292
290
293
291
// There have been places in the code which helpfully cache entities
294
292
// regardless of what package they are associated with. This assert
295
293
// will protect us from reintroducing that.
296
294
assert (refModelElement == null ||
297
295
refModelElement.packageGraph == element.packageGraph);
298
296
if (refModelElement != null ) {
299
- return new MatchingLinkResult (refModelElement, null );
297
+ return new MatchingLinkResult (refModelElement);
300
298
}
301
299
// From this point on, we haven't been able to find a canonical ModelElement.
302
300
if (! refModelElement.isCanonical) {
@@ -306,15 +304,15 @@ MatchingLinkResult _getMatchingLinkElement(
306
304
}
307
305
// Don't warn about doc references because that's covered by the no
308
306
// canonical library found message.
309
- return new MatchingLinkResult (null , null , warn: false );
307
+ return new MatchingLinkResult (null , warn: false );
310
308
}
311
309
// We should never get here unless there's a bug in findCanonicalModelElementFor.
312
310
// findCanonicalModelElementFor(searchElement, preferredClass: preferredClass)
313
311
// should only return null if ModelElement.from(searchElement, refLibrary)
314
312
// would return a non-canonical element. However, outside of checked mode,
315
313
// at least we have a canonical element, so proceed.
316
314
assert (false );
317
- return new MatchingLinkResult (refModelElement, null );
315
+ return new MatchingLinkResult (refModelElement);
318
316
}
319
317
320
318
/// Given a set of commentRefs, return the one whose name matches the codeRef.
@@ -725,7 +723,6 @@ String _linkDocReference(
725
723
MatchingLinkResult result;
726
724
result = _getMatchingLinkElement (codeRef, warnable, commentRefs);
727
725
final ModelElement linkedElement = result.element;
728
- final String label = result.label ?? codeRef;
729
726
if (linkedElement != null ) {
730
727
var classContent = '' ;
731
728
if (linkedElement.isDeprecated) {
@@ -734,16 +731,16 @@ String _linkDocReference(
734
731
// This would be linkedElement.linkedName, but link bodies are slightly
735
732
// different for doc references.
736
733
if (linkedElement.href == null ) {
737
- return '<code>${htmlEscape .convert (label )}</code>' ;
734
+ return '<code>${htmlEscape .convert (codeRef )}</code>' ;
738
735
} else {
739
- return '<a ${classContent }href="${linkedElement .href }">$label </a>' ;
736
+ return '<a ${classContent }href="${linkedElement .href }">${ htmlEscape . convert ( codeRef )} </a>' ;
740
737
}
741
738
} else {
742
739
if (result.warn) {
743
740
warnable.warn (PackageWarning .unresolvedDocReference,
744
741
message: codeRef, referredFrom: warnable.documentationFrom);
745
742
}
746
- return '<code>${htmlEscape .convert (label )}</code>' ;
743
+ return '<code>${htmlEscape .convert (codeRef )}</code>' ;
747
744
}
748
745
}
749
746
0 commit comments