(self, m)
return matched_text
Rewrites bits of the program selected by a regexp.

    These can be curly braces, literal strings, function declarations and var
    declarations.  (These last two must be on one line including the opening
    curly brace of the function for their variables to be renamed).

    Args:
      m: The match object returned by re.search.

    Returns:
      The string that should replace the match in the rewritten program.
Rewrites bits of the program selected by a regexp.
Rewrites bits of the program selected by a regexp .
def Declaration(self, m):
    """Rewrites bits of the program selected by a regexp.

    These can be curly braces, literal strings, function declarations and var
    declarations.  (These last two must be on one line including the opening
    curly brace of the function for their variables to be renamed).

    Args:
      m: The match object returned by re.search.

    Returns:
      The string that should replace the match in the rewritten program.
    """
    matched_text = m.group(0)

    if matched_text.startswith("`") and matched_text.endswith("`"):
      return re.sub(r"\$\{([\w$%]+)\}",
                    lambda m: '${' + self.FindNewName(m.group(1)) + '}',
                    matched_text)

    if matched_text == "{":
      self.Push()
      return matched_text
    if matched_text == "}":
      self.Pop()
      return matched_text
    if re.match("[\"'/]", matched_text):
      return matched_text
    m = re.match(r"var ", matched_text)
    if m:
      var_names = matched_text[m.end():]
      var_names = re.split(r",", var_names)
      return "var " + ",".join(map(self.FindNewName, var_names))
    m = re.match(r"(function\b[^(]*)\((.*)\)\{$", matched_text)
    if m:
      up_to_args = m.group(1)
      args = m.group(2)
      args = re.split(r",", args)
      self.Push()
      return up_to_args + "(" + ",".join(map(self.FindNewName, args)) + "){"

    if matched_text in self.map:
      return self.map[matched_text]

    return matched_text
def Declaration ( self , m ) : matched_text = m . group ( 0 ) if matched_text . startswith ( "`" ) and matched_text . endswith ( "`" ) : return re . sub ( r"\$\{([\w$%]+)\}" , lambda m : '${' + self . FindNewName ( m . group ( 1 ) ) + '}' , matched_text ) if matched_text == "{" : self . Push ( ) return matched_text if matched_text == "}" : self . Pop ( ) return matched_text if re . match ( "[\"'/]" , matched_text ) : return matched_text m = re . match ( r"var " , matched_text ) if m : var_names = matched_text [ m . end ( ) : ] var_names = re . split ( r"," , var_names ) return "var " + "," . join ( map ( self . FindNewName , var_names ) ) m = re . match ( r"(function\b[^(]*)\((.*)\)\{$" , matched_text ) if m : up_to_args = m . group ( 1 ) args = m . group ( 2 ) args = re . split ( r"," , args ) self . Push ( ) return up_to_args + "(" + "," . join ( map ( self . FindNewName , args ) ) + "){" if matched_text in self . map : return self . map [ matched_text ] return matched_text