Skip to content

Commit e028609

Browse files
authored
Hide non-local embedded SDKs (#2175)
* Don't treat an embedded SDK as local unless it is defined in the default package. * dartfmt
1 parent 1698751 commit e028609

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/src/model/package.dart

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,22 @@ class Package extends LibraryContainer
152152
/// was not excluded on the command line.
153153
bool get isLocal {
154154
if (_isLocal == null) {
155-
_isLocal = (packageMeta == packageGraph.packageMeta ||
156-
packageGraph.hasEmbedderSdk && packageMeta.isSdk ||
157-
packageGraph.config.autoIncludeDependencies) &&
155+
_isLocal = (
156+
// Document as local if this is the default package.
157+
packageMeta == packageGraph.packageMeta ||
158+
// Assume we want to document an embedded SDK as local if
159+
// it has libraries defined in the default package.
160+
// TODO(jcollins-g): Handle case where embedder SDKs can be
161+
// assembled from multiple locations?
162+
packageGraph.hasEmbedderSdk &&
163+
packageMeta.isSdk &&
164+
libraries.any((l) => path.isWithin(
165+
packageGraph.packageMeta.dir.path,
166+
(l.element.source.fullName))) ||
167+
// autoIncludeDependencies means everything is local.
168+
packageGraph.config.autoIncludeDependencies) &&
169+
// Regardless of the above rules, do not document as local if
170+
// we excluded this package by name.
158171
!packageGraph.config.isPackageExcluded(name);
159172
}
160173
return _isLocal;

lib/src/model/package_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class PackageBuilder {
5252
return newGraph;
5353
}
5454

55-
DartSdk _sdk;
55+
FolderBasedDartSdk _sdk;
5656

57-
DartSdk get sdk {
57+
FolderBasedDartSdk get sdk {
5858
if (_sdk == null) {
5959
_sdk = FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
6060
PhysicalResourceProvider.INSTANCE.getFolder(config.sdkDir));

0 commit comments

Comments
 (0)