public static <N, T extends N> int getItemSize(ReadableWDocument<N, ?, T> doc, N node) {
    // Short circuit if it's a text node, implementation is simpler
    T textNode = doc.asText(node);
    if (textNode != null) {
      return doc.getLength(textNode);
    }
    // Otherwise, calculate two locations and subtract
    N parent = doc.getParentElement(node);
    if (parent == null) {
      // Requesting size of the document root.
      // TODO(danilatos/anorth) This would change if we have multiple roots.
      noteCodeThatWillBreakWithMultipleRoots();
      return doc.size();
    }
    N next = doc.getNextSibling(node);
    int locationAfter = next != null ? doc.getLocation(next)
        : doc.getLocation(Point.end(parent));
    return locationAfter - doc.getLocation(node);
  }
public static <N, T extends N> int getItemSize(ReadableWDocument<N, ?, T> doc, N node) {
   
    T textNode = doc.asText(node);
    if (textNode != null) {
      return doc.getLength(textNode);
    }
   
    N parent = doc.getParentElement(node);
    if (parent == null) {
     
     
      noteCodeThatWillBreakWithMultipleRoots();
      return doc.size();
    }
    N next = doc.getNextSibling(node);
    int locationAfter = next != null ? doc.getLocation(next)
        : doc.getLocation(Point.end(parent));
    return locationAfter - doc.getLocation(node);
  }
public static <n, t extends n> int getitemsize(readablewdocument<n, ?, t> doc, n node) { t textnode = doc.astext(node); if (textnode != null) { return doc.getlength(textnode); } n parent = doc.getparentelement(node); if (parent == null) { notecodethatwillbreakwithmultipleroots(); return doc.size(); } n next = doc.getnextsibling(node); int locationafter = next != null ? doc.getlocation(next) : doc.getlocation(point.end(parent)); return locationafter - doc.getlocation(node); }