@@ -320,37 +320,41 @@ class _MarkdownCommentReference {
320
320
packageGraph = library.packageGraph;
321
321
}
322
322
323
- String __impliedDefaultConstructor;
324
- bool __impliedDefaultConstructorIsSet = false ;
323
+ String __impliedUnnamedConstructor;
325
324
326
- /// Returns the name of the implied default constructor if there is one, or
325
+ /// [_impliedUnnamedConstructor] is memoized in [__impliedUnnamedConstructor] ,
326
+ /// but even after it is initialized, it may be null. This bool represents the
327
+ /// initializiation state.
328
+ bool __impliedUnnamedConstructorIsSet = false ;
329
+
330
+ /// Returns the name of the implied unnamed constructor if there is one, or
327
331
/// null if not.
328
332
///
329
- /// Default constructors are a special case in dartdoc. If we look up a name
333
+ /// Unnamed constructors are a special case in dartdoc. If we look up a name
330
334
/// within a class of that class itself, the first thing we find is the
331
- /// default constructor. But we determine whether that's what they actually
335
+ /// unnamed constructor. But we determine whether that's what they actually
332
336
/// intended (vs. the enclosing class) by context -- whether they seem
333
337
/// to be calling it with () or have a 'new' in front of it, or
334
338
/// whether the name is repeated.
335
339
///
336
340
/// Similarly, referencing a class by itself might actually refer to its
337
- /// constructor based on these same heuristics.
341
+ /// unnamed constructor based on these same heuristics.
338
342
///
339
- /// With the name of the implied default constructor, other methods can
343
+ /// With the name of the implied unnamed constructor, other methods can
340
344
/// determine whether or not the constructor and/or class we resolved to
341
345
/// is actually matching the user's intent.
342
- String get _impliedDefaultConstructor {
343
- if (! __impliedDefaultConstructorIsSet ) {
344
- __impliedDefaultConstructorIsSet = true ;
346
+ String get _impliedUnnamedConstructor {
347
+ if (! __impliedUnnamedConstructorIsSet ) {
348
+ __impliedUnnamedConstructorIsSet = true ;
345
349
if (codeRef.contains (isConstructor) ||
346
350
(codeRefChompedParts.length >= 2 &&
347
351
codeRefChompedParts[codeRefChompedParts.length - 1 ] ==
348
352
codeRefChompedParts[codeRefChompedParts.length - 2 ])) {
349
353
// If the last two parts of the code reference are equal, this is probably a default constructor.
350
- __impliedDefaultConstructor = codeRefChompedParts.last;
354
+ __impliedUnnamedConstructor = codeRefChompedParts.last;
351
355
}
352
356
}
353
- return __impliedDefaultConstructor ;
357
+ return __impliedUnnamedConstructor ;
354
358
}
355
359
356
360
/// Calculate reference to a ModelElement.
@@ -563,18 +567,24 @@ class _MarkdownCommentReference {
563
567
}
564
568
}
565
569
566
- /// Transform members of [toConvert] that are classes to their default constructor,
567
- /// if a constructor is implied. If not, do the reverse conversion for default
568
- /// constructors.
570
+ /// Returns the unnamed constructor for class [toConvert] or the class for
571
+ /// constructor [toConvert] , or just [toConvert] , based on hueristics.
572
+ ///
573
+ /// * If an unnamed constructor is implied in the comment reference, and
574
+ /// [toConvert] is a class with the same name, the class's unnamed
575
+ /// constructor is returned.
576
+ /// * Otherwise, if [toConvert] is an unnamed constructor, its enclosing
577
+ /// class is returned.
578
+ /// * Othwerwise, [toConvert] is returned.
569
579
ModelElement _convertConstructors (ModelElement toConvert) {
570
- if (_impliedDefaultConstructor != null ) {
571
- if (toConvert is Class && toConvert.name == _impliedDefaultConstructor ) {
572
- return toConvert.defaultConstructor ;
580
+ if (_impliedUnnamedConstructor != null ) {
581
+ if (toConvert is Class && toConvert.name == _impliedUnnamedConstructor ) {
582
+ return toConvert.unnamedConstructor ;
573
583
}
574
584
return toConvert;
575
585
} else {
576
586
if (toConvert is Constructor &&
577
- (toConvert.enclosingElement as Class ).defaultConstructor ==
587
+ (toConvert.enclosingElement as Class ).unnamedConstructor ==
578
588
toConvert) {
579
589
return toConvert.enclosingElement;
580
590
}
0 commit comments