blockly > VariableMap

VariableMap class

Class for a variable map. This contains a dictionary data structure with variable types as keys and lists of variables as values. The list of variables are the type indicated by the key.


export declare class VariableMap 


Constructor Modifiers Description
(constructor)(workspace) Constructs a new instance of the VariableMap class


Property Modifiers Type Description
workspace Workspace


Method Modifiers Description
clear() Clear the variable map. Fires events for every deletion.
createVariable(name, opt_type, opt_id) Create a variable with a given name, optional type, and optional ID.
deleteVariable(variable) Delete a variable.
deleteVariableById(id) Delete a variables by the passed in ID and all of its uses from this workspace. May prompt the user for confirmation.
getAllVariableNames() Returns all of the variable names of all types.
getAllVariables() Return all variables of all types.
getVariable(name, opt_type) Find the variable by the given name and type and return it. Return null if it is not found.
getVariableById(id) Find the variable by the given ID and return it. Return null if not found.
getVariablesOfType(type) Get a list containing all of the variables of a specified type. If type is null, return list of variables with empty string type.
getVariableUsesById(id) Find all the uses of a named variable.
renameVariableById(id, newName) Rename a variable by updating its name in the variable map. Identify the variable to rename with the given ID.