Skip to content

Fix crash on invalid prefix imports. #1899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,8 @@ class Library extends ModelElement with Categorization, TopLevelContainer {
_prefixToLibrary = {};
// It is possible to have overlapping prefixes.
for (ImportElement i in (element as LibraryElement).imports) {
if (i.prefix?.name != null) {
// Ignore invalid imports.
if (i.prefix?.name != null && i.importedLibrary != null) {
_prefixToLibrary.putIfAbsent(i.prefix?.name, () => new Set());
_prefixToLibrary[i.prefix?.name].add(
new ModelElement.from(i.importedLibrary, library, packageGraph));
Expand Down
3 changes: 3 additions & 0 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ library fake;

import 'dart:async';
import 'dart:collection';
// Make sure dartdoc ignores invalid prefixes imports (#1896)
// ignore: uri_does_not_exist
import 'dart:json' as invalidPrefix;
import 'package:meta/meta.dart' show Required;
import 'csspub.dart' as css;
import 'csspub.dart' as renamedLib2;
Expand Down