Skip to content

Commit

Permalink
Do not crash when documenting an export with '//' (#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins authored Jul 8, 2020
1 parent 95214ad commit ed8ac3c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/src/model/class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@ class Class extends Container
return __inheritedElements = <ExecutableElement>[];
}

if (definingLibrary == null) {
// [definingLibrary] may be null if [element] has been imported or
// exported with a non-normalized URI, like "src//a.dart".
// TODO(srawlins): It would be nice to allow references from such
// libraries, but for now, PackageGraph.allLibraries is a Map with
// LibraryElement keys, which include [Element.location] in their
// `==` calculation; I think we should not key off of Elements.
return __inheritedElements = <ExecutableElement>[];
}

var inheritance = definingLibrary.inheritanceManager;
var cmap = inheritance.getInheritedConcreteMap2(element);
var imap = inheritance.getInheritedMap2(element);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/model/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ class Library extends ModelElement with Categorization, TopLevelContainer {
if (_modelElementsNameMap == null) {
_modelElementsNameMap = <String, Set<ModelElement>>{};
allModelElements.forEach((ModelElement modelElement) {
// [definingLibrary] may be null if [element] has been imported or
// exported with a non-normalized URI, like "src//a.dart".
if (modelElement.definingLibrary == null) return;
_modelElementsNameMap.putIfAbsent(
modelElement.fullyQualifiedNameWithoutLibrary, () => {});
_modelElementsNameMap[modelElement.fullyQualifiedNameWithoutLibrary]
Expand Down
3 changes: 2 additions & 1 deletion lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ abstract class ModelElement extends Canonicalization
// just shortcut them out.
if (!utils.hasPublicName(element)) {
_canonicalLibrary = null;
} else if (!packageGraph.localPublicLibraries.contains(definingLibrary)) {
} else if (definingLibrary != null &&
!packageGraph.localPublicLibraries.contains(definingLibrary)) {
var candidateLibraries = definingLibrary.exportedInLibraries
?.where((l) =>
l.isPublic &&
Expand Down

0 comments on commit ed8ac3c

Please sign in to comment.