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}) {
  bool process(String key, dynamic decl) {
    if (!other.willExportAll) {
      if (!other.exports.contains(decl?.id)) {
        return false;
      }
    }
    if (lexicon.isPrivate(key)) {
      return false;
    }
    if (decl is HTDeclaration) {
      if (clone) {
        decl = decl.clone();
      }
    }
    if (idOnly) {
      defineImport(key, null as T, other.fullName);
    } else {
      defineImport(key, decl, other.fullName);
    }
    if (export) {
      declareExport(key);
    }
    return true;
  }

  for (final key in other.symbols.keys) {
    var decl = other.symbols[key]!;
    if (!process(key, decl)) continue;
  }
  for (final key in other.importedSymbols.keys) {
    var decl = other.importedSymbols[key]!;
    if (other.exports.contains(decl?.id)) {
      if (!process(key, decl)) continue;
    }
  }
}