Class: Names
Defined in: packages/blockly/core/names.ts:26
Class for a database of entity names (variables, procedures, etc).
Properties index
| Property | Description |
|---|---|
| DEVELOPER_VARIABLE_TYPE | - |
Methods index
| Method | Description |
|---|---|
| reset | Empty the database and start from scratch. The reserved words are kept. |
| setVariableMap | Set the variable map that maps from variable name to variable object. |
| populateVariables | Generate names for user variables, but only ones that are being used. |
| populateProcedures | Generate names for procedures. |
| getName | Convert a Blockly entity name to a legal exportable entity name. |
| getUserNames | Return a list of all known user-created names of a specified name type. |
| getDistinctName | Convert a Blockly entity name to a legal exportable entity name. Ensure that this is a new name not overlapping any previously defined name. Also check against list of reserved words for the current language and ensure name doesn't collide. |
| equals | Do the given two entity names refer to the same entity? Blockly names are case-insensitive. |
Constructors
Constructor
new Names(reservedWordsList, opt_variablePrefix?): Names;
Defined in: packages/blockly/core/names.ts:54
Parameters
| Parameter | Type | Description |
|---|---|---|
reservedWordsList | string | A comma-separated string of words that are illegal for use as names in a language (e.g. 'new,if,this,...'). |
opt_variablePrefix? | string | Some languages need a '$' or a namespace before all variable names (but not procedure names). |
Returns
Names
Properties
DEVELOPER_VARIABLE_TYPE
static DEVELOPER_VARIABLE_TYPE: NameType;
Defined in: packages/blockly/core/names.ts:27
Methods
reset()
reset(): void;
Defined in: packages/blockly/core/names.ts:66
Empty the database and start from scratch. The reserved words are kept.
Returns
void
setVariableMap()
setVariableMap(map): void;
Defined in: packages/blockly/core/names.ts:77
Set the variable map that maps from variable name to variable object.
Parameters
| Parameter | Type | Description |
|---|---|---|
map | IVariableMap<IVariableModel<IVariableState>> | The map to track. |
Returns
void
populateVariables()
populateVariables(workspace): void;
Defined in: packages/blockly/core/names.ts:112
Generate names for user variables, but only ones that are being used.
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | Workspace | Workspace to generate variables from. |
Returns
void
populateProcedures()
populateProcedures(workspace): void;
Defined in: packages/blockly/core/names.ts:125
Generate names for procedures.
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | Workspace | Workspace to generate procedures from. |
Returns
void
getName()
getName(nameOrId, type): string;
Defined in: packages/blockly/core/names.ts:140
Convert a Blockly entity name to a legal exportable entity name.
Parameters
| Parameter | Type | Description |
|---|---|---|
nameOrId | string | The Blockly entity name (no constraints) or variable ID. |
type | string | The type of the name in Blockly ('VARIABLE', 'PROCEDURE', 'DEVELOPER_VARIABLE', etc...). |
Returns
string
An entity name that is legal in the exported language.
getUserNames()
getUserNames(type): string[];
Defined in: packages/blockly/core/names.ts:174
Return a list of all known user-created names of a specified name type.
Parameters
| Parameter | Type | Description |
|---|---|---|
type | string | The type of entity in Blockly ('VARIABLE', 'PROCEDURE', 'DEVELOPER_VARIABLE', etc...). |
Returns
string[]
A list of Blockly entity names (no constraints).
getDistinctName()
getDistinctName(name, type): string;
Defined in: packages/blockly/core/names.ts:190
Convert a Blockly entity name to a legal exportable entity name. Ensure that this is a new name not overlapping any previously defined name. Also check against list of reserved words for the current language and ensure name doesn't collide.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The Blockly entity name (no constraints). |
type | string | The type of entity in Blockly ('VARIABLE', 'PROCEDURE', 'DEVELOPER_VARIABLE', etc...). |
Returns
string
An entity name that is legal in the exported language.
equals()
static equals(name1, name2): boolean;
Defined in: packages/blockly/core/names.ts:240
Do the given two entity names refer to the same entity? Blockly names are case-insensitive.
Parameters
| Parameter | Type | Description |
|---|---|---|
name1 | string | First name. |
name2 | string | Second name. |
Returns
boolean
True if names are the same.