Skip to content

Commit 84ce4e1

Browse files
committed
Canonicalize elements in remote packages
1 parent 882aea9 commit 84ce4e1

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/src/model/model_element.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,10 @@ abstract class ModelElement
512512
// This is not accurate if we are still constructing the Package.
513513
assert(packageGraph.allLibrariesAdded);
514514

515-
var definingLibraryIsLocalPublic =
516-
packageGraph.localPublicLibraries.contains(library);
517-
var possibleCanonicalLibrary = definingLibraryIsLocalPublic
518-
? library
519-
: canonicalLibraryCandidate(this);
515+
var definingLibraryIsPublic =
516+
packageGraph.publicLibraries.contains(library);
517+
var possibleCanonicalLibrary =
518+
definingLibraryIsPublic ? library : canonicalLibraryCandidate(this);
520519

521520
if (possibleCanonicalLibrary != null) return possibleCanonicalLibrary;
522521

test/packages_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ library bar;
263263
.writeAsStringSync('''
264264
/// Documentation comment.
265265
library one;
266+
export 'some_other_lib.dart' show Exported;
266267
267268
class One {}
268269
''');
@@ -276,6 +277,10 @@ library script;
276277
277278
class Script {}
278279
''');
280+
packageOneRoot
281+
.getChildAssumingFolder('lib')
282+
.getChildAssumingFile('some_other_lib.dart')
283+
.writeAsStringSync('''class Exported {}''');
279284

280285
packageTwoRoot =
281286
utils.writePackage('two', resourceProvider, packageConfigProvider);
@@ -316,6 +321,12 @@ dartdoc:
316321
expect(packageOne.documentedWhere, equals(DocumentLocation.remote));
317322
expect(classOne.href,
318323
equals('https://mypub.topdomain/one/0.0.1/one/One-class.html'));
324+
// Validate that canonicalization takes place for remote packages.
325+
var exported = libraryOne.classes.named('Exported');
326+
expect(
327+
exported.href,
328+
equals(
329+
'https://mypub.topdomain/one/0.0.1/some_other_lib/Exported-class.html'));
319330
});
320331

321332
test(

0 commit comments

Comments
 (0)