@@ -44,12 +44,13 @@ class PackageGraph {
44
44
/// span packages.
45
45
void addLibraryToGraph (DartDocResolvedLibrary resolvedLibrary) {
46
46
assert (! allLibrariesAdded);
47
- var element = resolvedLibrary.element;
48
- var packageMeta = packageMetaProvider.fromElement (element, config.sdkDir);
47
+ var libraryElement = resolvedLibrary.element;
48
+ var packageMeta =
49
+ packageMetaProvider.fromElement (libraryElement, config.sdkDir);
49
50
var lib = Library .fromLibraryResult (
50
51
resolvedLibrary, this , Package .fromPackageMeta (packageMeta, this ));
51
52
packageMap[packageMeta.name].libraries.add (lib);
52
- allLibraries[element ] = lib;
53
+ allLibraries[libraryElement.source.fullName ] = lib;
53
54
}
54
55
55
56
/// Call during initialization to add a library possibly containing
@@ -203,7 +204,13 @@ class PackageGraph {
203
204
}
204
205
205
206
// All library objects related to this package; a superset of _libraries.
206
- final Map <LibraryElement , Library > allLibraries = {};
207
+ // Keyed by [LibraryElement.Source.fullName] to resolve multiple URIs
208
+ // referring to the same location to the same [Library]. This isn't how
209
+ // Dart works internally, but Dartdoc pretends to avoid documenting or
210
+ // duplicating data structures for the same "library" on disk based
211
+ // on how it is referenced. We can't use [Source] as a key since because
212
+ // of differences in the [TimestampedData] timestamps.
213
+ final allLibraries = < String , Library > {};
207
214
208
215
/// Keep track of warnings
209
216
PackageWarningCounter _packageWarningCounter;
@@ -869,32 +876,28 @@ class PackageGraph {
869
876
/// set of canonical Libraries).
870
877
Library findButDoNotCreateLibraryFor (Element e) {
871
878
// This is just a cache to avoid creating lots of libraries over and over.
872
- if (allLibraries.containsKey (e.library)) {
873
- return allLibraries[e.library];
874
- }
875
- return null ;
879
+ return allLibraries[e.library? .source? .fullName];
876
880
}
877
881
878
882
/// This is used when we might need a Library object that isn't actually
879
883
/// a documentation entry point (for elements that have no Library within the
880
884
/// set of canonical Libraries).
881
885
Library findOrCreateLibraryFor (DartDocResolvedLibrary resolvedLibrary) {
882
- final elementLibrary = resolvedLibrary.library;
883
- // This is just a cache to avoid creating lots of libraries over and over.
884
- if (allLibraries.containsKey (elementLibrary)) {
885
- return allLibraries[elementLibrary];
886
- }
886
+ final libraryElement = resolvedLibrary.library;
887
887
// can be null if e is for dynamic
888
- if (elementLibrary == null ) {
888
+ if (libraryElement == null ) {
889
889
return null ;
890
890
}
891
- var foundLibrary = Library .fromLibraryResult (
891
+ var foundLibrary = findButDoNotCreateLibraryFor (libraryElement);
892
+ if (foundLibrary != null ) return foundLibrary;
893
+
894
+ foundLibrary = Library .fromLibraryResult (
892
895
resolvedLibrary,
893
896
this ,
894
897
Package .fromPackageMeta (
895
- packageMetaProvider.fromElement (elementLibrary , config.sdkDir),
898
+ packageMetaProvider.fromElement (libraryElement , config.sdkDir),
896
899
packageGraph));
897
- allLibraries[elementLibrary ] = foundLibrary;
900
+ allLibraries[libraryElement.source.fullName ] = foundLibrary;
898
901
return foundLibrary;
899
902
}
900
903
0 commit comments