code: final void add(String newcode) {
      maybeEndStatement();
  
      if (newcode.isEmpty()) {
        return;
      }
  
      char c = newcode.charAt(0);
      if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
        // need space to separate. This is not pretty printing.
        // For example: "return foo;"
        append(" ");
      } else if (c == '/' && getLastChar() == '/') {
        // Do not allow a forward slash to appear after a DIV.
        // For example,
        // REGEXP DIV REGEXP
        // is valid and should print like
        // / // / /
        append(" ");
      } else if ((c == '"' || c == '\'') && isWordChar(getLastChar())) {
        maybeInsertSpace();
      }
  
      // Iterate through the new code and add each contained line, followed by a break. Remember that
      // the string may start and end in the middle of a line. We do this rather primitively because
      // this method is called frequently and most invocations have only one line.
      // TODO(nickreid): There are other possible newline characters recognized by the JS spec. We
      // should also be considering them.
      int startOfLine = 0;
      int endOfLine = newcode.indexOf('\n');
      while (endOfLine >= 0) {
        if (endOfLine > startOfLine) {
          // Append line only if it is non-empty.
          append(newcode.substring(startOfLine, endOfLine));
        }
        // Breaking is non-optional. Newlines added this way must be preserved (e.g. newlines in
        // template literals).
        startNewLine();
  
        startOfLine = endOfLine + 1; // Jump over the newline char.
        endOfLine = newcode.indexOf('\n', startOfLine);
      }
      if (newcode.length() > startOfLine) {
        // Append line only if it is non-empty.
        append(newcode.substring(startOfLine)); // Append the last or only line without breaking.
      }
    }
docs: Appends a (possibly multiline) string to the code, keeping track of the current line length and
  count.
  
  <p>Clients should use this method rather than {@link #append()}. It sanitizes the input to
  {@link #append()}.