File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -117,9 +117,9 @@ class EnumField extends Field {
117117 return canonicalModelElement? .href;
118118 }
119119 assert (canonicalEnclosingContainer == enclosingElement);
120- // TODO(jcollins-g): EnumField should not depend on enclosingElement, but
121- // we sort of have to while we are half-converted to [FileStructure].
122- return '${ package . baseHref }${ enclosingElement . library . dirName }/ ${enclosingElement .fileName }' ;
120+ assert (canonicalLibrary != null );
121+ return '${ package . baseHref }${ canonicalLibrary !. dirName }/'
122+ ' ${enclosingElement .fileName }' ;
123123 }
124124
125125 @override
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import 'package:test/test.dart';
88import 'package:test_reflective_loader/test_reflective_loader.dart' ;
99
1010import 'dartdoc_test_base.dart' ;
11+ import 'src/test_descriptor_utils.dart' as d;
1112import 'src/utils.dart' ;
1213
1314void main () {
@@ -637,6 +638,23 @@ enum E {
637638 expect (oneValue.constantValue, equals (oneValue.renderedName));
638639 }
639640
641+ void test_value_linksToItsAnchor_inExportedLib () async {
642+ var library = (await bootPackageFromFiles ([
643+ d.file ('lib/src/library.dart' , '''
644+ enum E { one, two three }
645+ ''' ),
646+ d.file ('lib/enums.dart' , '''
647+ export 'src/library.dart';
648+ ''' ),
649+ ]))
650+ .libraries
651+ .named (libraryName);
652+ var oneValue =
653+ library.enums.named ('E' ).publicEnumValues.named ('one' ) as EnumField ;
654+ expect (oneValue.linkedName, '<a href="$linkPrefix /E.html#one">one</a>' );
655+ expect (oneValue.constantValue, equals (oneValue.renderedName));
656+ }
657+
640658 void test_values_haveIndices () async {
641659 var library = await bootPackageWithLibrary ('enum E { one, two, three }' );
642660 var oneValue =
Original file line number Diff line number Diff line change @@ -355,7 +355,16 @@ bool get classModifiersAllowed =>
355355 .allows (platformVersion);
356356
357357extension ModelElementIterableExtension <T extends ModelElement > on Iterable <T > {
358- T named (String name) => singleWhere ((e) => e.name == name);
358+ T named (String name) {
359+ var elements = where ((e) => e.name == name).toList ();
360+ if (elements.isEmpty) {
361+ throw StateError ("No $T elements named '$name '" );
362+ }
363+ if (elements.length > 1 ) {
364+ throw StateError ("Too many $T elements named '$name ': $elements " );
365+ }
366+ return elements.single;
367+ }
359368
360369 T displayNamed (String displayName) =>
361370 singleWhere ((e) => e.displayName == displayName);
You can’t perform that action at this time.
0 commit comments