clone method

Create a copy of this declaration, mainly used on class member inheritance and function arguments passing.

Implementation

@override
HTDeclarationNamespace<HTDeclaration> clone() {
  final cloned = HTDeclarationNamespace<HTDeclaration>(
    lexicon: lexicon,
    id: id,
    classId: classId,
    closure: closure,
    source: source,
  );
  for (final decl in symbols.values) {
    cloned.symbols[decl.id!] = decl.clone();
  }
  for (final decl in imports.values) {
    cloned.imports[decl.fromPath] = decl;
  }
  cloned.exports.addAll(exports);
  for (final decl in importedSymbols.values) {
    cloned.importedSymbols[decl.id!] = decl.clone();
  }
  return cloned;
}