import method

void import(
  1. HTDeclarationNamespace other, {
  2. bool clone = false,
  3. bool export = false,
  4. Set<String> showList = const {},
  5. bool idOnly = false,
})

Implementation

void import(HTDeclarationNamespace<dynamic> other,
    {bool clone = false,
    bool export = false,
    Set<String> showList = const {},
    bool idOnly = false}) {
  for (final key in other.symbols.keys) {
    var decl = other.symbols[key]!;
    if (!other.willExportAll) {
      if (!other.exports.contains(decl.id)) {
        continue;
      }
    }
    if (lexicon.isPrivate(key)) {
      continue;
    }
    if (decl is HTDeclaration) {
      if (clone) {
        decl = decl.clone();
      }
    }
    if (idOnly) {
      defineImport(key, null as T);
    } else {
      defineImport(key, decl);
    }
    if (export) {
      declareExport(key);
    }
  }
  for (final key in other.importedSymbols.keys) {
    var decl = other.importedSymbols[key]!;
    if (!other.exports.contains(decl.id)) {
      continue;
    }
    if (lexicon.isPrivate(key)) {
      continue;
    }
    if (decl is HTDeclaration) {
      if (clone) {
        decl = decl.clone();
      }
    }
    if (idOnly) {
      defineImport(key, null as T);
    } else {
      defineImport(key, decl);
    }
    if (export) {
      declareExport(key);
    }
  }
}