File tree Expand file tree Collapse file tree 4 files changed +38
-5
lines changed Expand file tree Collapse file tree 4 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -744,10 +744,14 @@ class _MarkdownCommentReference {
744
744
// [thing], a member of this class
745
745
_addCanonicalResult (modelElement, tryClass);
746
746
}
747
- membersToCheck = (c.allModelElementsByNamePart[codeRefChompedParts.last] ??
748
- < ModelElement > [])
749
- .map (_convertConstructors);
750
- membersToCheck.forEach ((m) => _addCanonicalResult (m, tryClass));
747
+ if (codeRefChompedParts.length < 2 ||
748
+ codeRefChompedParts[codeRefChompedParts.length - 2 ] == c.name) {
749
+ membersToCheck =
750
+ (c.allModelElementsByNamePart[codeRefChompedParts.last] ??
751
+ < ModelElement > [])
752
+ .map (_convertConstructors);
753
+ membersToCheck.forEach ((m) => _addCanonicalResult (m, tryClass));
754
+ }
751
755
results.remove (null );
752
756
if (results.isNotEmpty) return ;
753
757
if (c.fullyQualifiedNameWithoutLibrary == codeRefChomped) {
Original file line number Diff line number Diff line change @@ -1389,6 +1389,23 @@ void main() {
1389
1389
});
1390
1390
1391
1391
group ('Class edge cases' , () {
1392
+ test ('Factories from unrelated classes are linked correctly' , () {
1393
+ Class A = packageGraph.localPublicLibraries
1394
+ .firstWhere ((l) => l.name == 'unrelated_factories' )
1395
+ .allClasses
1396
+ .firstWhere ((c) => c.name == 'A' );
1397
+ Constructor fromMap =
1398
+ A .constructors.firstWhere ((c) => c.name == 'A.fromMap' );
1399
+ expect (fromMap.documentationAsHtml,
1400
+ contains (r'unrelated_factories/AB/AB.fromMap.html">AB.fromMap</a>' ));
1401
+ expect (fromMap.documentationAsHtml,
1402
+ contains (r'A/A.fromMap.html">fromMap</a>' ));
1403
+ expect (fromMap.documentationAsHtml,
1404
+ contains (r'unrelated_factories/AB-class.html">AB</a>' ));
1405
+ expect (fromMap.documentationAsHtml,
1406
+ contains (r'unrelated_factories/A-class.html">A</a>' ));
1407
+ });
1408
+
1392
1409
test ('Inherit from private class across private library to public library' ,
1393
1410
() {
1394
1411
Class GadgetExtender = packageGraph.localPublicLibraries
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import 'package:path/path.dart' as path;
17
17
/// The number of public libraries in testing/test_package, minus 2 for
18
18
/// the excluded libraries listed in the initializers for _testPackageGraphMemo
19
19
/// and minus 1 for the <nodoc> tag in the 'excluded' library.
20
- const int kTestPackagePublicLibraries = 16 ;
20
+ const int kTestPackagePublicLibraries = 17 ;
21
21
22
22
final RegExp quotables = RegExp (r'[ "\r\n\$]' );
23
23
final RegExp observatoryPortRegexp =
Original file line number Diff line number Diff line change
1
+ class A {
2
+ /// A link to [AB.fromMap] , [fromMap] , and [AB] and [A] .
3
+ factory A .fromMap (Map <String , dynamic > map) => A ._A ();
4
+
5
+ A ._A ();
6
+ }
7
+
8
+ class AB {
9
+ factory AB .fromMap (Map <String , dynamic > map) => AB ._AB ();
10
+
11
+ AB ._AB ();
12
+ }
You can’t perform that action at this time.
0 commit comments