public static TextRange getContentRange(PsiFragment fragment) {
    final IElementType tokenType = fragment.getTokenType();

    if (tokenType == JavaTokenType.STRING_TEMPLATE_BEGIN || tokenType == JavaTokenType.STRING_TEMPLATE_MID) {
      final TextRange fragmentRange = fragment.getTextRange();
      return new TextRange(fragmentRange.getStartOffset() + 1, fragmentRange.getEndOffset() - 2);
    }
    else if (tokenType == JavaTokenType.STRING_TEMPLATE_END) {
      final TextRange fragmentRange = fragment.getTextRange();
      return new TextRange(fragmentRange.getStartOffset() + 1, fragmentRange.getEndOffset() - 1);
    }
    else if (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN) {
      final TextRange fragmentRange = fragment.getTextRange();
      final String text = fragment.getText();
      int index = 3;
      while (PsiLiteralUtil.isTextBlockWhiteSpace(text.charAt(index))) {
        index++;
      }
      index++;
      return new TextRange(fragmentRange.getStartOffset() + index, fragmentRange.getEndOffset() - 2);
    }
    else if (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_MID) {
      final TextRange fragmentRange = fragment.getTextRange();
      return new TextRange(fragmentRange.getStartOffset() + 1, fragmentRange.getEndOffset() - 2);
    }
    else if (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_END) {
      final TextRange fragmentRange = fragment.getTextRange();
      return new TextRange(fragmentRange.getStartOffset() + 1, fragmentRange.getEndOffset() - 3);
    }
    else {
      throw new AssertionError();
    }
  }
public static TextRange getContentRange(PsiFragment fragment)