public static @Nullable PsiTemplateExpression inlineEmbeddedExpression(@NotNull PsiExpression expression) {
    PsiTemplate template = (PsiTemplate)expression.getParent();
    if (template == null) return null;
    PsiTemplateExpression templateExpression = ObjectUtils.tryCast(template.getParent(), PsiTemplateExpression.class);
    if (templateExpression == null) return null;
    PsiElement[] children = template.getChildren();
    int index = ArrayUtil.indexOf(children, expression);
    if (index == -1) return null;
    StringBuilder newTemplate = new StringBuilder();
    for (PsiElement child : templateExpression.getChildren()) {
      if (child == template) break;
      newTemplate.append(child.getText());
    }
    boolean suffixProcessed = false;
    boolean prefixProcessed = false;
    CommentTracker ct = new CommentTracker();
    PsiElement prev = PsiTreeUtil.skipWhitespacesAndCommentsBackward(expression);
    PsiElement next = PsiTreeUtil.skipWhitespacesAndCommentsForward(expression);
    for (int i = 0; i < children.length; i++) {
      PsiElement child = children[i];
      String childText = child.getText();
      if (i < index && prefixProcessed) continue;
      if (prev == child) {
        childText = StringUtil.trimEnd(childText, "\\{");
        prefixProcessed = true;
      } else if (next == child) {
        childText = StringUtil.trimStart(childText, "}");
        suffixProcessed = true;
      }
      if (i > index && !suffixProcessed) continue;
      if (child == expression) {
        if (expression instanceof PsiEmptyExpressionImpl) {
          childText = "null";
        } else if (expression instanceof PsiLiteralExpression literal) {
          Object value = literal.getValue();
          if (value instanceof String && !literal.isTextBlock()) {
            childText = StringUtil.trimEnd(StringUtil.trimStart(childText, "\""), "\"");
          } else {
            childText = StringUtil.escapeStringCharacters(String.valueOf(value));
          }
        }
      }
      ct.markUnchanged(child);
      newTemplate.append(childText);
    }
    PsiTemplateExpression newTemplateExpression = (PsiTemplateExpression)JavaPsiFacade.getElementFactory(expression.getProject())
      .createExpressionFromText(newTemplate.toString(), expression);
    return (PsiTemplateExpression)ct.replaceAndRestoreComments(templateExpression, newTemplateExpression);
  }
public static @Nullable PsiTemplateExpression inlineEmbeddedExpression(@NotNull PsiExpression expression)