public static void escapeSymbolsForDollarSlashyStrings(StringBuilder buffer, String str) {
    final int length = str.length();
    int idx = 0;
    while (idx < length) {
      final char ch = str.charAt(idx);
      if (ch == '/') {
        if (idx + 1 < length) {
          char nextCh = str.charAt(idx + 1);
          if (nextCh == '$') {
            // /$ -> $/$
            buffer.append("$/");
            idx++;
            continue;
          }
        }
      }
      else if (ch == '$') {
        if (idx + 1 < length) {
          final char nextCh = str.charAt(idx + 1);
          if (nextCh == '$' || nextCh == '/' || GroovyNamesUtil.isIdentifier(Character.toString(nextCh))) {
            // $$ -> $$$
            // $/ -> $$/
            buffer.append("$$");
            idx += 1;
            continue;
          }
        }
        else {
          buffer.append("$$");
          idx++;
          continue;
        }
      }
      if (Character.isISOControl(ch) && ch != '\n') {
        appendUnicode(buffer, ch);
      }
      else {
        buffer.append(ch);
      }
      idx++;
    }
  }
public static void escapeSymbolsForDollarSlashyStrings(StringBuilder buffer, String str)