private static String buildReplacementText(PsiElement element, String suffix, Function<String, String> lineTransformation) {
      String[] lines = element.getText().split("\n", -1);
      int indent = getIndent(element);
      StringBuilder result = new StringBuilder();
      for (int i = 0; i < lines.length; i++) {
        String line = lines[i];
        if (line.startsWith("\"\"\"")) {
          result.append("\"\"\"\n");
          continue;
        }
        boolean last = (i == lines.length - 1);
        if (last) {
          if (suffix.equals("\\{")) return result.append(line).toString();
          line = line.substring(0, line.length() - suffix.length());
        }
        String transformed = line.isEmpty() ? line : lineTransformation.apply(line);
        if (transformed == null) return null;
        if (last && hasUnescapedLastQuote(transformed)) {
          result.append(transformed, 0, transformed.length() - 1).append("\\\"");
        }
        else if (transformed.isEmpty()) {
          result.append((line.length() < indent) ? line : line.substring(0, indent));
        } else {
          result.append(transformed);
        }
        result.append(last ? suffix : "\n");
      }
      return result.toString();
    }
private static String buildReplacementText(PsiElement element, String suffix, Function<String, String> lineTransformation)