NameManager.VariableNameManager

public static final class NameManager.VariableNameManager extends NameManager

The NameManager for variable names.

Inherited Field Summary

Public Constructor Summary

Public Method Summary

String
generateExternalName(Set<String> reservedWords, String baseName)
Convert a Blockly entity name to a legal exportable entity name.
String
generateVariableName(boolean addName)
Return a new variable name that is not yet being used.
void
setVariablePrefix(String variablePrefix)
Sets the prefix that will be attached to external names during generation.

Inherited Method Summary

Public Constructors

public NameManager.VariableNameManager ()

Public Methods

public String generateExternalName (Set<String> reservedWords, String baseName)

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. The new name will conform to the [_A-Za-z][_A-Za-z0-9]* format that most languages consider legal for variables.

Parameters
reservedWords Reserved words in the target language.
baseName The name to convert.
Returns
  • A legal variable or procedure name in the target language.

public String generateVariableName (boolean addName)

Return a new variable name that is not yet being used. This will try to generate single letter variable names in the range 'i' to 'z' to start with. If no unique name is located it will try 'i' to 'z', 'a' to 'h', then 'i2' to 'z2' etc. Skip 'l'.

Parameters
addName Whether to add the new name to the list of variables.
Returns
  • New variable name.

public void setVariablePrefix (String variablePrefix)

Sets the prefix that will be attached to external names during generation. Some languages need a '$' or a namespace before all variable names.

Parameters
variablePrefix The prefix to attach.