findOrCreateLibraryFor method

Library findOrCreateLibraryFor(
  1. DartDocResolvedLibrary resolvedLibrary
)

This is used when we might need a Library object that isn't actually a documentation entry point (for elements that have no Library within the set of canonical Libraries).

Implementation

Library findOrCreateLibraryFor(DartDocResolvedLibrary resolvedLibrary) {
  final libraryElement = resolvedLibrary.library;
  // can be null if e is for dynamic
  if (libraryElement == null) {
    return null;
  }
  var foundLibrary = findButDoNotCreateLibraryFor(libraryElement);
  if (foundLibrary != null) return foundLibrary;

  foundLibrary = Library.fromLibraryResult(
      resolvedLibrary,
      this,
      Package.fromPackageMeta(
          packageMetaProvider.fromElement(libraryElement, config.sdkDir),
          packageGraph));
  allLibraries[libraryElement.source.fullName] = foundLibrary;
  return foundLibrary;
}