Package org.eclipse.wst.sse.core.internal.provisional.text

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion


      return null;
    }

    ITextRegion region = null;
    int offset = documentPosition;
    IStructuredDocumentRegion flatNode = null;
    IDOMNode node = (IDOMNode) domnode;

    if (node.getNodeType() == Node.DOCUMENT_NODE) {
      if (node.getStructuredDocument().getLength() == 0) {
        return null;
      }
      ITextRegion result = node.getStructuredDocument()
          .getRegionAtCharacterOffset(offset)
          .getRegionAtCharacterOffset(offset);
      while (result == null) {
        offset--;
        result = node.getStructuredDocument()
            .getRegionAtCharacterOffset(offset)
            .getRegionAtCharacterOffset(offset);
      }
      return result;
    }

    IStructuredDocumentRegion startTag = node
        .getStartStructuredDocumentRegion();
    IStructuredDocumentRegion endTag = node
        .getEndStructuredDocumentRegion();

    // Determine if the offset is within the start
    // IStructuredDocumentRegion, end IStructuredDocumentRegion, or
    // somewhere within the Node's XML content.
    if ((startTag != null) && (startTag.getStartOffset() <= offset)
        && (offset < startTag.getStartOffset() + startTag.getLength())) {
      flatNode = startTag;
    } else if ((endTag != null) && (endTag.getStartOffset() <= offset)
        && (offset < endTag.getStartOffset() + endTag.getLength())) {
      flatNode = endTag;
    }

    if (flatNode != null) {
      // the offset is definitely within the start or end tag, continue
      // on and find the region
      region = getCompletionRegion(offset, flatNode);
    } else {
      // Start test code added by Gavin Lei
      System.out
          .println("Build ITextRegion instance with char '< or $' start    node instance:"
              + node.getClass());
      IStructuredDocumentRegion preFlatNode = node
          .getStructuredDocument().getRegionAtCharacterOffset(
              offset - 1);
      System.out.println(node.getStructuredDocument().getClass());
      System.out.println(preFlatNode.getPrevious().toString());

      // the docPosition is neither within the start nor the end, so it
      // must be content
      flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(
          offset);
View Full Code Here


  public int getEndOffset() {
    Node node = this;
    while (node != null) {
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        ElementImpl element = (ElementImpl) node;
        IStructuredDocumentRegion endStructuredDocumentRegion = element.getEndStructuredDocumentRegion();
        if (endStructuredDocumentRegion != null)
          return endStructuredDocumentRegion.getEnd();
      }

      Node last = node.getLastChild();
      if (last != null) { // dig into the last
        node = last;
        continue;
      }

      IStructuredDocumentRegion lastStructuredDocumentRegion = ((NodeImpl) node).getStructuredDocumentRegion();
      if (lastStructuredDocumentRegion != null)
        return lastStructuredDocumentRegion.getEnd();

      Node prev = node.getPreviousSibling();
      if (prev != null) { // move to the previous
        node = prev;
        continue;
      }

      Node parent = node.getParentNode();
      node = null;
      while (parent != null) {
        if (parent.getNodeType() == Node.ELEMENT_NODE) {
          ElementImpl element = (ElementImpl) parent;
          IStructuredDocumentRegion startStructuredDocumentRegion = element.getStartStructuredDocumentRegion();
          if (startStructuredDocumentRegion != null)
            return startStructuredDocumentRegion.getEnd();
        }
        Node parentPrev = parent.getPreviousSibling();
        if (parentPrev != null) { // move to the previous
          node = parentPrev;
          break;
View Full Code Here

      }
      if (child.getStartOffset() > offset) {
        break;
      }

      IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
      if (startStructuredDocumentRegion != null) {
        if (startStructuredDocumentRegion.getEnd() > offset)
          return child;
      }

      // dig more
      parent = child;
View Full Code Here

      return element.getStartOffset();
    }
    // final fallback to look into first child
    NodeImpl child = (NodeImpl) getFirstChild();
    while (child != null) {
      IStructuredDocumentRegion childStructuredDocumentRegion = child.getStructuredDocumentRegion();
      if (childStructuredDocumentRegion != null)
        return childStructuredDocumentRegion.getStart();
      child = (NodeImpl) child.getFirstChild();
    }
    return 0;
  }
View Full Code Here

   * @return
   */
  private boolean hasNestedRegion(TextImpl text) {
    boolean done = false;

    IStructuredDocumentRegion currRegion = text.getFirstStructuredDocumentRegion();
    IStructuredDocumentRegion lastRegion = text.getLastStructuredDocumentRegion();

    while(currRegion != null && !done) {
     
      ITextRegionList regions = currRegion.getRegions();
      for(int i = 0; i < regions.size(); ++i) {
View Full Code Here

  }

  /**
   */
  public boolean isClosed() {
    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode == null)
      return true; // will be generated
    String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
    return (regionType == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE || regionType == DOMRegionContext.XML_DECLARATION_CLOSE);
  }
View Full Code Here

    buffer.append(getPublicId());
    buffer.append(')');
    buffer.append('(');
    buffer.append(getSystemId());
    buffer.append(')');
    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode != null) {
      buffer.append('@');
      buffer.append(flatNode.toString());
    }
    return buffer.toString();
  }
View Full Code Here

        return new Span(0, -1);
    }
  }

  private Span getDataSpanForElement(IDOMElement node) {
    IStructuredDocumentRegion docRegion = node.getStartStructuredDocumentRegion();
    if (docRegion == null) {
      return new Span(0, -1);
    }

    ITextRegionList regions = docRegion.getRegions();
    if (regions == null) {
      return new Span(0, -1);
    }

    String startType;
View Full Code Here

      return new Span(0, -1);
    }
  }

  private Span getDataSpanForText(IDOMText node) {
    IStructuredDocumentRegion docRegion = ((NodeImpl) node).getStructuredDocumentRegion();
    if (docRegion == null) {
      return new Span(0, -1);
    }
    return new Span(0, docRegion.getLength());
  }
View Full Code Here

  void lockBoth(IDOMNode node) {
    if (node == null) {
      return;
    }

    IStructuredDocumentRegion flatNode;
    boolean canInsert = false;

    // end node (element)
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      flatNode = node.getEndStructuredDocumentRegion();
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.