Package.fromPackageMeta constructor

Package.fromPackageMeta(
  1. PackageMeta packageMeta,
  2. PackageGraph packageGraph
)

Implementation

factory Package.fromPackageMeta(
    PackageMeta packageMeta, PackageGraph packageGraph) {
  var packageName = packageMeta.name;

  var expectNonLocal = false;

  if (!packageGraph.packageMap.containsKey(packageName) &&
      packageGraph.allLibrariesAdded) expectNonLocal = true;
  packageGraph.packageMap.putIfAbsent(
      packageName, () => Package._(packageName, packageGraph, packageMeta));
  // Verify that we don't somehow decide to document locally a package picked
  // up after all documented libraries are added, because that breaks the
  // assumption that we've picked up all documented libraries and packages
  // before allLibrariesAdded is true.
  assert(
      !(expectNonLocal &&
          packageGraph.packageMap[packageName].documentedWhere ==
              DocumentLocation.local),
      'Found more libraries to document after allLibrariesAdded was set to true');
  return packageGraph.packageMap[packageName];
}