Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
13 changes: 6 additions & 7 deletions test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,7 @@ void main() async {

group('Class', () {
late final List<Class> classes;
late final Class Apple, B, Cat, Dog, F, Dep, SpecialList;
late final Class Apple, B, Cat, Dog, F, Helper, SpecialList;
late final Class ExtendingClass, CatString;

setUpAll(() {
Expand All @@ -1844,7 +1844,7 @@ void main() async {
Cat = classes.named('Cat');
Dog = classes.named('Dog');
F = classes.named('F');
Dep = classes.named('Deprecated');
Helper = classes.named('Helper');
SpecialList = fakeLibrary.classes.named('SpecialList');
ExtendingClass = twoExportsLib.classes.named('ExtendingClass');
CatString = exLibrary.classes.named('CatString');
Expand Down Expand Up @@ -1879,7 +1879,7 @@ void main() async {
});

test('correctly finds all the classes', () {
expect(classes, hasLength(34));
expect(classes, hasLength(33));
});

test('abstract', () {
Expand Down Expand Up @@ -1982,10 +1982,9 @@ void main() async {
});

test('exported class should have hrefs from the current library', () {
expect(
Dep.href, equals('${htmlBasePlaceholder}ex/Deprecated-class.html'));
expect(Dep.instanceMethods.named('toString').href,
equals('${htmlBasePlaceholder}ex/Deprecated/toString.html'));
expect(Helper.href, equals('${htmlBasePlaceholder}ex/Helper-class.html'));
expect(Helper.instanceMethods.named('toString').href,
equals('${htmlBasePlaceholder}ex/Helper/toString.html'));
});

test('F has a single instance method', () {
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