private static TextRange getContentRange(ASTNode node, @NotNull CharSequence text) {
    final IElementType tokenType = node.getElementType();
    final TextRange range = node.getTextRange();

    if (tokenType == JavaTokenType.STRING_TEMPLATE_BEGIN || tokenType == JavaTokenType.STRING_TEMPLATE_MID ||
        tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_MID) {
      return new TextRange(range.getStartOffset() + 1, range.getEndOffset() - 2);
    }
    else if (tokenType == JavaTokenType.STRING_TEMPLATE_END || tokenType == JavaTokenType.STRING_LITERAL) {
      int end = text.charAt(range.getEndOffset() - 1) == '"'
                      ? range.getEndOffset() - 1
                      : range.getEndOffset();
      return new TextRange(range.getStartOffset() + 1, end);
    }
    else if (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN || tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_END ||
             tokenType == JavaTokenType.TEXT_BLOCK_LITERAL) {
      int start;
      if (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_END) {
        start = range.getStartOffset() + 1;
      }
      else {
        start = range.getStartOffset() + 3;
        while (BasicLiteralUtil.isTextBlockWhiteSpace(text.charAt(start))) start++;
        if (text.charAt(start) == '\n') start++;
      }
      int end;
      if (tokenType == JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN) {
        end = range.getEndOffset() - 2;
      }
      else {
        end = range.getEndOffset();
        end -= StringUtil.endsWith(text, start, end, "\"\"\"") ? 4 : 1;
        for (; end >= start; end--) {
          char c = text.charAt(end);
          if (c == '\n' || !Character.isWhitespace(c)) {
            end += 1;
            break;
          }
        }
      }
      return new TextRange(start, end);
    }
    else {
      throw new IllegalArgumentException();
    }
  }
private static TextRange getContentRange(ASTNode node, @NotNull CharSequence text)