Class VariableMap

java.lang.Object
com.google.javascript.jscomp.VariableMap

public class VariableMap extends Object
Stores the mapping from original variable name to new variable names.
See Also:
  • RenameVars
  • Method Details

    • lookupNewName

      public String lookupNewName(String sourceName)
      Given an original variable name, look up new name, may return null if it's not found.
    • lookupSourceName

      public String lookupSourceName(String newName)
      Given a new variable name, lookup the source name, may return null if it's not found.
    • getOriginalNameToNewNameMap

      public Map<String,String> getOriginalNameToNewNameMap()
      Returns an unmodifiable mapping from original names to new names.
    • getNewNameToOriginalNameMap

      public Map<String,String> getNewNameToOriginalNameMap()
      Returns an unmodifiable mapping from new names to original names.
    • save

      public void save(String filename) throws IOException
      Saves the variable map to a file.
      Throws:
      IOException
    • load

      public static VariableMap load(String filename) throws IOException
      Reads the variable map from a file written via save(String).
      Throws:
      IOException
    • toBytes

      public byte[] toBytes()
      Serializes the variable map to a byte array.
    • fromBytes

      public static VariableMap fromBytes(byte[] bytes) throws ParseException
      Deserializes the variable map from a byte array returned by toBytes().
      Throws:
      ParseException
    • fromMap

      public static VariableMap fromMap(Map<String,String> map)
      Initializes the variable map from an existing map.
      Parameters:
      map - The map to use from original names to generated names. It is copied and changes to the specified map will not affect the returned object.