import Modification from '../../modification'; import * as Shift from 'shift-ast'; export default class VariableRenamer extends Modification { private globalScope; private variableNames; private usedVariableNames; private nameMapping; /** * Creates a new modification. * @param ast The AST. */ constructor(ast: Shift.Script | Shift.Module); /** * Executes the modification. */ execute(): void; /** * Finds all variable declarations. */ private collectDeclarations; /** * Finds all references of variables. */ private collectReferences; /** * Renames all suitable variables within a given scope and it's * children. * @param scope The scope. */ private renameVariables; /** * Returns the name mapping. * @returns The name mapping. */ getNameMapping(): any; /** * Generates a list of unique variable names. */ private generateNames; /** * Randomly shuffles an array. * @param array The array to be shuffled. * @returns The shuffled array. */ private shuffleArray; /** * Returns the next unique variable name. * @returns The next variable name. */ private getVariableName; /** * Records a variable name as used. * @param name The variable name. */ private addName; /** * Returns whether a variable name should be renamed. * @param name The variable name. * @returns Whether. */ private shouldRename; }