@@ -345,37 +345,41 @@ class _MarkdownCommentReference {
345
345
packageGraph = library.packageGraph;
346
346
}
347
347
348
- String __impliedDefaultConstructor;
349
- bool __impliedDefaultConstructorIsSet = false ;
348
+ String __impliedUnnamedConstructor;
350
349
351
- /// Returns the name of the implied default constructor if there is one, or
350
+ /// [_impliedUnnamedConstructor] is memoized in [__impliedUnnamedConstructor] ,
351
+ /// but even after it is initialized, it may be null. This bool represents the
352
+ /// initializiation state.
353
+ bool __impliedUnnamedConstructorIsSet = false ;
354
+
355
+ /// Returns the name of the implied unnamed constructor if there is one, or
352
356
/// null if not.
353
357
///
354
- /// Default constructors are a special case in dartdoc. If we look up a name
358
+ /// Unnamed constructors are a special case in dartdoc. If we look up a name
355
359
/// within a class of that class itself, the first thing we find is the
356
- /// default constructor. But we determine whether that's what they actually
360
+ /// unnamed constructor. But we determine whether that's what they actually
357
361
/// intended (vs. the enclosing class) by context -- whether they seem
358
362
/// to be calling it with () or have a 'new' in front of it, or
359
363
/// whether the name is repeated.
360
364
///
361
365
/// Similarly, referencing a class by itself might actually refer to its
362
- /// constructor based on these same heuristics.
366
+ /// unnamed constructor based on these same heuristics.
363
367
///
364
- /// With the name of the implied default constructor, other methods can
368
+ /// With the name of the implied unnamed constructor, other methods can
365
369
/// determine whether or not the constructor and/or class we resolved to
366
370
/// is actually matching the user's intent.
367
- String get _impliedDefaultConstructor {
368
- if (! __impliedDefaultConstructorIsSet ) {
369
- __impliedDefaultConstructorIsSet = true ;
371
+ String get _impliedUnnamedConstructor {
372
+ if (! __impliedUnnamedConstructorIsSet ) {
373
+ __impliedUnnamedConstructorIsSet = true ;
370
374
if (codeRef.contains (_constructorIndicationPattern) ||
371
375
(codeRefChompedParts.length >= 2 &&
372
376
codeRefChompedParts[codeRefChompedParts.length - 1 ] ==
373
377
codeRefChompedParts[codeRefChompedParts.length - 2 ])) {
374
378
// If the last two parts of the code reference are equal, this is probably a default constructor.
375
- __impliedDefaultConstructor = codeRefChompedParts.last;
379
+ __impliedUnnamedConstructor = codeRefChompedParts.last;
376
380
}
377
381
}
378
- return __impliedDefaultConstructor ;
382
+ return __impliedUnnamedConstructor ;
379
383
}
380
384
381
385
/// Calculate reference to a ModelElement.
@@ -593,18 +597,24 @@ class _MarkdownCommentReference {
593
597
}
594
598
}
595
599
596
- /// Transform members of [toConvert] that are classes to their default constructor,
597
- /// if a constructor is implied. If not, do the reverse conversion for default
598
- /// constructors.
600
+ /// Returns the unnamed constructor for class [toConvert] or the class for
601
+ /// constructor [toConvert] , or just [toConvert] , based on hueristics.
602
+ ///
603
+ /// * If an unnamed constructor is implied in the comment reference, and
604
+ /// [toConvert] is a class with the same name, the class's unnamed
605
+ /// constructor is returned.
606
+ /// * Otherwise, if [toConvert] is an unnamed constructor, its enclosing
607
+ /// class is returned.
608
+ /// * Othwerwise, [toConvert] is returned.
599
609
ModelElement _convertConstructors (ModelElement toConvert) {
600
- if (_impliedDefaultConstructor != null ) {
601
- if (toConvert is Class && toConvert.name == _impliedDefaultConstructor ) {
602
- return toConvert.defaultConstructor ;
610
+ if (_impliedUnnamedConstructor != null ) {
611
+ if (toConvert is Class && toConvert.name == _impliedUnnamedConstructor ) {
612
+ return toConvert.unnamedConstructor ;
603
613
}
604
614
return toConvert;
605
615
} else {
606
616
if (toConvert is Constructor &&
607
- (toConvert.enclosingElement as Class ).defaultConstructor ==
617
+ (toConvert.enclosingElement as Class ).unnamedConstructor ==
608
618
toConvert) {
609
619
return toConvert.enclosingElement;
610
620
}
0 commit comments