@NotNull
  private static String escape(@NotNull StringKind kind, @NotNull String s) {
    if (s.isEmpty()) {
      return s;
    }
    if (kind != StringKind.DOUBLE_QUOTED && kind != StringKind.TRIPLE_DOUBLE_QUOTED) {
      return kind.escape(s);
    }
    boolean singleLine = kind == StringKind.DOUBLE_QUOTED;
    StringBuilder b = new StringBuilder(s.length());
    GrStringUtil.escapeStringCharacters(s.length(), s, singleLine ? "\"" : "", singleLine, true, b);
    GrStringUtil.unescapeCharacters(b, singleLine ? "'" : "'\"", true);
    for (int i = b.length() - 2; i >= 0; i--) {
      if (b.charAt(i) == '$') {
        final char next = b.charAt(i + 1);
        if (next != '{' && !Character.isLetter(next)) {
          b.insert(i, '\\');
        }
      }
    }
    if (b.charAt(b.length() - 1) == '$') {
      b.insert(b.length() - 1, '\\');
    }
    return b.toString();
  }
@NotNull
  private static String escape(@NotNull StringKind kind, @NotNull String s)