File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import 'package:dartdoc/src/model/model.dart';
13
13
/// Like [Parameter] , it doesn't have doc pages, but participates in lookups.
14
14
/// Forwards to its referenced library if referred to directly.
15
15
class Prefix extends ModelElement with HasNoPage {
16
-
17
16
@override
18
17
final PrefixElement2 element;
19
18
@@ -27,15 +26,21 @@ class Prefix extends ModelElement with HasNoPage {
27
26
// TODO(jcollins-g): consider connecting PrefixElement to the imported library
28
27
// in analyzer?
29
28
late final Library associatedLibrary =
30
- getModelForElement (_getImportedLibraryElement () ! ) as Library ;
29
+ getModelForElement (_importedLibraryElement ) as Library ;
31
30
32
- LibraryElement2 ? _getImportedLibraryElement () {
31
+ LibraryElement2 get _importedLibraryElement {
33
32
final importLists =
34
33
library.element.fragments.map ((fragment) => fragment.libraryImports2);
35
- return importLists
34
+ var libraryImport = importLists
36
35
.expand ((import) => import)
37
- .firstWhere ((i) => i.prefix2? .element == element)
38
- .importedLibrary2;
36
+ .firstWhere ((i) => i.prefix2? .element == element);
37
+ var importedLibrary = libraryImport.importedLibrary2;
38
+ if (importedLibrary == null ) {
39
+ throw StateError (
40
+ 'Unexpected null LibraryElement2 for imported library at '
41
+ '${libraryImport .uri }' );
42
+ }
43
+ return importedLibrary;
39
44
}
40
45
41
46
@override
You can’t perform that action at this time.
0 commit comments