Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26156,6 +26156,7 @@ const _invisibleGetters = {
'libraryCount',
'libraryExports',
'libraryExports2',
'localLibraries',
'localPackages',
'localPublicLibraries',
'name',
Expand Down
14 changes: 9 additions & 5 deletions lib/src/model/model_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,15 @@ abstract class ModelElement
// This is not accurate if we are still constructing the Package.
assert(packageGraph.allLibrariesAdded);

var definingLibraryIsLocalPublic =
packageGraph.localPublicLibraries.contains(library);
var possibleCanonicalLibrary = definingLibraryIsLocalPublic
? library
: canonicalLibraryCandidate(this);
var isLocalLibrary = packageGraph.localLibraries.contains(library);
if (!isLocalLibrary && !config.linkToRemote) {
return null;
}

var definingLibraryIsPublic =
packageGraph.publicLibraries.contains(library);
var possibleCanonicalLibrary =
definingLibraryIsPublic ? library : canonicalLibraryCandidate(this);

if (possibleCanonicalLibrary != null) return possibleCanonicalLibrary;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,15 @@ class PackageGraph with CommentReferable, Nameable {
return libraries.wherePublic.toSet();
}();

late final List<Library> _localLibraries = () {
late final List<Library> localLibraries = () {
assert(allLibrariesAdded);
return localPackages.expand((p) => p.libraries).toList(growable: false)
..sort();
}();

late final Set<Library> localPublicLibraries = () {
assert(allLibrariesAdded);
return _localLibraries.wherePublic.toSet();
return localLibraries.wherePublic.toSet();
}();

/// The String name representing the `Object` type.
Expand Down
11 changes: 11 additions & 0 deletions test/packages_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ library bar;
.writeAsStringSync('''
/// Documentation comment.
library one;
export 'some_other_lib.dart' show Exported;
class One {}
''');
Expand All @@ -276,6 +277,10 @@ library script;
class Script {}
''');
packageOneRoot
.getChildAssumingFolder('lib')
.getChildAssumingFile('some_other_lib.dart')
.writeAsStringSync('''class Exported {}''');

packageTwoRoot =
utils.writePackage('two', resourceProvider, packageConfigProvider);
Expand Down Expand Up @@ -316,6 +321,12 @@ dartdoc:
expect(packageOne.documentedWhere, equals(DocumentLocation.remote));
expect(classOne.href,
equals('https://mypub.topdomain/one/0.0.1/one/One-class.html'));
// Validate that canonicalization takes place for remote packages.
var exported = libraryOne.classes.named('Exported');
expect(
exported.href,
equals(
'https://mypub.topdomain/one/0.0.1/some_other_lib/Exported-class.html'));
});

test(
Expand Down
Loading