Skip to content

Commit

Permalink
Hide non-local embedded SDKs (#2175)
Browse files Browse the repository at this point in the history
* Don't treat an embedded SDK as local unless it is defined in the default package.

* dartfmt
  • Loading branch information
jcollins-g committed Apr 10, 2020
1 parent 1698751 commit e028609
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions lib/src/model/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,22 @@ class Package extends LibraryContainer
/// was not excluded on the command line.
bool get isLocal {
if (_isLocal == null) {
_isLocal = (packageMeta == packageGraph.packageMeta ||
packageGraph.hasEmbedderSdk && packageMeta.isSdk ||
packageGraph.config.autoIncludeDependencies) &&
_isLocal = (
// Document as local if this is the default package.
packageMeta == packageGraph.packageMeta ||
// Assume we want to document an embedded SDK as local if
// it has libraries defined in the default package.
// TODO(jcollins-g): Handle case where embedder SDKs can be
// assembled from multiple locations?
packageGraph.hasEmbedderSdk &&
packageMeta.isSdk &&
libraries.any((l) => path.isWithin(
packageGraph.packageMeta.dir.path,
(l.element.source.fullName))) ||
// autoIncludeDependencies means everything is local.
packageGraph.config.autoIncludeDependencies) &&
// Regardless of the above rules, do not document as local if
// we excluded this package by name.
!packageGraph.config.isPackageExcluded(name);
}
return _isLocal;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/package_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class PackageBuilder {
return newGraph;
}

DartSdk _sdk;
FolderBasedDartSdk _sdk;

DartSdk get sdk {
FolderBasedDartSdk get sdk {
if (_sdk == null) {
_sdk = FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
PhysicalResourceProvider.INSTANCE.getFolder(config.sdkDir));
Expand Down

0 comments on commit e028609

Please sign in to comment.