swc_core::ecma::transforms::base::rename

Trait Renamer

pub trait Renamer: Send + Sync {
    const RESET_N: bool;
    const MANGLE: bool;

    // Required method
    fn new_name_for(&self, orig: &(Atom, SyntaxContext), n: &mut usize) -> Atom;

    // Provided methods
    fn preserved_ids_for_module(
        &mut self,
        _: &Module,
    ) -> HashSet<(Atom, SyntaxContext), BuildHasherDefault<FxHasher>> { ... }
    fn preserved_ids_for_script(
        &mut self,
        _: &Script,
    ) -> HashSet<(Atom, SyntaxContext), BuildHasherDefault<FxHasher>> { ... }
    fn get_cached(
        &self,
    ) -> Option<Cow<'_, HashMap<(Atom, SyntaxContext), Atom, BuildHasherDefault<FxHasher>>>> { ... }
    fn store_cache(
        &mut self,
        _update: &HashMap<(Atom, SyntaxContext), Atom, BuildHasherDefault<FxHasher>>,
    ) { ... }
}
Available on crate feature __ecma and (crate features __ecma_transforms or __testing_transform) only.

Required Associated Constants§

const RESET_N: bool

Should reset n to 0 for each identifier?

const MANGLE: bool

It should be true if you expect lots of collisions

Required Methods§

fn new_name_for(&self, orig: &(Atom, SyntaxContext), n: &mut usize) -> Atom

Should increment n.

Provided Methods§

fn preserved_ids_for_module( &mut self, _: &Module, ) -> HashSet<(Atom, SyntaxContext), BuildHasherDefault<FxHasher>>

fn preserved_ids_for_script( &mut self, _: &Script, ) -> HashSet<(Atom, SyntaxContext), BuildHasherDefault<FxHasher>>

fn get_cached( &self, ) -> Option<Cow<'_, HashMap<(Atom, SyntaxContext), Atom, BuildHasherDefault<FxHasher>>>>

fn store_cache( &mut self, _update: &HashMap<(Atom, SyntaxContext), Atom, BuildHasherDefault<FxHasher>>, )

Object Safety§

This trait is not object safe.

Implementors§