@@ -345,37 +345,41 @@ class _MarkdownCommentReference {
345345 packageGraph = library.packageGraph;
346346 }
347347
348- String __impliedDefaultConstructor;
349- bool __impliedDefaultConstructorIsSet = false ;
348+ String __impliedUnnamedConstructor;
350349
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
352356 /// null if not.
353357 ///
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
355359 /// 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
357361 /// intended (vs. the enclosing class) by context -- whether they seem
358362 /// to be calling it with () or have a 'new' in front of it, or
359363 /// whether the name is repeated.
360364 ///
361365 /// 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.
363367 ///
364- /// With the name of the implied default constructor, other methods can
368+ /// With the name of the implied unnamed constructor, other methods can
365369 /// determine whether or not the constructor and/or class we resolved to
366370 /// 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 ;
370374 if (codeRef.contains (_constructorIndicationPattern) ||
371375 (codeRefChompedParts.length >= 2 &&
372376 codeRefChompedParts[codeRefChompedParts.length - 1 ] ==
373377 codeRefChompedParts[codeRefChompedParts.length - 2 ])) {
374378 // 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;
376380 }
377381 }
378- return __impliedDefaultConstructor ;
382+ return __impliedUnnamedConstructor ;
379383 }
380384
381385 /// Calculate reference to a ModelElement.
@@ -593,18 +597,24 @@ class _MarkdownCommentReference {
593597 }
594598 }
595599
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.
599609 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 ;
603613 }
604614 return toConvert;
605615 } else {
606616 if (toConvert is Constructor &&
607- (toConvert.enclosingElement as Class ).defaultConstructor ==
617+ (toConvert.enclosingElement as Class ).unnamedConstructor ==
608618 toConvert) {
609619 return toConvert.enclosingElement;
610620 }
0 commit comments