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

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


    if (flatNode instanceof StructuredDocumentRegionContainer) {
      StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
      int count = container.getStructuredDocumentRegionCount();
      for (int i = 0; i < count; i++) {
        IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
        if (isInvalid(content))
          return true;
      }
      return false;
    }
View Full Code Here


   */
  boolean isSharingStructuredDocumentRegion(IStructuredDocumentRegion sharedStructuredDocumentRegion) {
    if (sharedStructuredDocumentRegion == null)
      return false;

    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode == null)
      return false;

    if (flatNode == sharedStructuredDocumentRegion)
      return false;

    if (flatNode instanceof StructuredDocumentRegionProxy) {
      StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
      if (proxy.getStructuredDocumentRegion() == sharedStructuredDocumentRegion)
        return true;
      return false;
    }

    if (flatNode instanceof StructuredDocumentRegionContainer) {
      StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
      int count = container.getStructuredDocumentRegionCount();
      for (int i = 0; i < count; i++) {
        IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
        if (content == null)
          continue;
        if (content == sharedStructuredDocumentRegion)
          return false;
        if (content instanceof StructuredDocumentRegionProxy) {
View Full Code Here

   */
  IStructuredDocumentRegion removeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
    if (oldStructuredDocumentRegion == null)
      return null;

    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode == null)
      return null; // error

    if (flatNode == oldStructuredDocumentRegion) {
      setStructuredDocumentRegion(null);
      return oldStructuredDocumentRegion;
    }

    if (flatNode instanceof StructuredDocumentRegionProxy) {
      StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
      if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
        // removed with proxy
        setStructuredDocumentRegion(null);
        return oldStructuredDocumentRegion;
      }
      return null; // error
    }

    if (flatNode instanceof StructuredDocumentRegionContainer) {
      StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
      int count = container.getStructuredDocumentRegionCount();
      for (int i = 0; i < count; i++) {
        IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
        if (content == oldStructuredDocumentRegion) {
          container.removeStructuredDocumentRegion(i);
          if (container.getStructuredDocumentRegionCount() == 1) {
            // get back to single IStructuredDocumentRegion
            setStructuredDocumentRegion(container.getStructuredDocumentRegion(0));
View Full Code Here

    if (oldStructuredDocumentRegion == null)
      return null;
    if (newStructuredDocumentRegion == null)
      return removeStructuredDocumentRegion(oldStructuredDocumentRegion);

    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode == null)
      return null; // error

    if (flatNode == oldStructuredDocumentRegion) {
      setStructuredDocumentRegion(newStructuredDocumentRegion);
      return oldStructuredDocumentRegion;
    }

    if (flatNode instanceof StructuredDocumentRegionProxy) {
      StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
      if (proxy.getStructuredDocumentRegion() == oldStructuredDocumentRegion) {
        if (newStructuredDocumentRegion instanceof StructuredDocumentRegionProxy) {
          // proxy must not be nested
          setStructuredDocumentRegion(newStructuredDocumentRegion);
        }
        else {
          proxy.setStructuredDocumentRegion(newStructuredDocumentRegion);
        }
        return oldStructuredDocumentRegion;
      }
      return null; // error
    }

    if (flatNode instanceof StructuredDocumentRegionContainer) {
      StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
      int count = container.getStructuredDocumentRegionCount();
      for (int i = 0; i < count; i++) {
        IStructuredDocumentRegion content = container.getStructuredDocumentRegion(i);
        if (content == null)
          continue; // error
        if (content == oldStructuredDocumentRegion) {
          container.replaceStructuredDocumentRegion(newStructuredDocumentRegion, i);
          return oldStructuredDocumentRegion;
View Full Code Here

   */
  Text splitText(IStructuredDocumentRegion nextStructuredDocumentRegion) {
    if (nextStructuredDocumentRegion == null)
      return null;

    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode == null || !(flatNode instanceof StructuredDocumentRegionContainer))
      return null; // error

    StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
    int count = container.getStructuredDocumentRegionCount();
    int index = 0;
    for (; index < count; index++) {
      if (container.getStructuredDocumentRegion(index) == nextStructuredDocumentRegion)
        break;
    }
    if (index >= count) {
      // this is the case nextStructuredDocumentRegion is a new
      // IStructuredDocumentRegion
      // search gap by offset
      int offset = nextStructuredDocumentRegion.getStart();
      for (index = 0; index < count; index++) {
        IStructuredDocumentRegion content = container.getStructuredDocumentRegion(index);
        if (content == null)
          continue; // error
        if (content.getStart() >= offset)
          break;
      }
      if (index >= count)
        return null; // error
    }
View Full Code Here

  /**
   */
  public String getSource() {
    StringBuffer buffer = new StringBuffer();

    IStructuredDocumentRegion startStructuredDocumentRegion = getStartStructuredDocumentRegion();
    if (startStructuredDocumentRegion != null) {
      String source = startStructuredDocumentRegion.getText();
      if (source != null)
        buffer.append(source);
    }

    for (NodeImpl child = firstChild; child != null; child = (NodeImpl) child.getNextSibling()) {
      String source = child.getSource();
      if (source != null)
        buffer.append(source);
    }

    IStructuredDocumentRegion endStructuredDocumentRegion = getEndStructuredDocumentRegion();
    if (endStructuredDocumentRegion != null) {
      String source = endStructuredDocumentRegion.getText();
      if (source != null)
        buffer.append(source);
    }

    return buffer.toString();
View Full Code Here

        IStructuredDocument document = getDocument();

        for(Iterator ite = results.iterator(); ite.hasNext();){
            StyleRange styleRange = (StyleRange)ite.next();

            IStructuredDocumentRegion region = document.getRegionAtCharacterOffset(styleRange.start);
            String text = region.getText();
            int mStart = styleRange.start - region.getStartOffset();
            int mEnd = mStart + styleRange.length;
            for(IStructuredDocumentRegion chkRegion = region.getPrevious(); chkRegion != null; chkRegion = chkRegion.getPrevious()){
                String type = chkRegion.getType();
                if(!type.equals(DOMRegionContext.XML_CONTENT) && !type.equals(DOMRegionContext.UNDEFINED)){
                    break;
                }
                text = chkRegion.getText() + text;
                mStart += chkRegion.getLength();
                mEnd   += chkRegion.getLength();
            }

            for(IStructuredDocumentRegion chkRegion = region.getNext(); chkRegion != null; chkRegion = chkRegion.getNext()){
                String type = chkRegion.getType();
                if(!type.equals(DOMRegionContext.XML_CONTENT) && !type.equals(DOMRegionContext.UNDEFINED)){
                    break;
                }
                text = (new StringBuilder(String.valueOf(text))).append(chkRegion.getText()).toString();
View Full Code Here

    IStructuredModel model = null;
   
    try {
      model = StructuredModelManager.getModelManager().getModelForRead(file);
      IStructuredDocument doc = model.getStructuredDocument();
      IStructuredDocumentRegion curNode = doc.getFirstStructuredDocumentRegion();
      while (null != (curNode = curNode.getNext()) && !monitor.isCanceled()) {
        if (curNode.getType() == DOMRegionContext.XML_TAG_NAME) {
          ITextRegionList list = curNode.getRegions();
          String text = curNode.getText();
          String tagName  = null;
          String attrName = null;
          for(int j=0;j<list.size();j++){
            ITextRegion region = list.get(j);
            if(region.getType()==DOMRegionContext.XML_TAG_NAME){
              tagName = text.substring(region.getStart(), region.getEnd()).trim();
             
            } else if(region.getType()==DOMRegionContext.XML_TAG_ATTRIBUTE_NAME){
              attrName = text.substring(region.getStart(), region.getEnd()).trim();
             
            } else if(region.getType()==DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE){
              String attrValue = text.substring(region.getStart(), region.getEnd()).trim();
              int length = attrValue.length();
              attrValue = attrValue.replaceAll("^\"|\"$","");
              if(tagName!=null && attrName!=null){
                validateAttributeValue(file, tagName, attrName, attrValue,
                    curNode.getStart() + region.getStart(), length);
              }
              attrName = null;
            }
          }
        }
View Full Code Here

      String data = ((CharacterData) node).getData();
      String source = node.getSource();
      if (data.equals(source)) {
        return new DOMPosition(node, offset - start);
      }
      IStructuredDocumentRegion r = node
          .getFirstStructuredDocumentRegion();
      int countedData = 0;
      // TODO: dead? int offsetInNode = offset - start;
      while (r != null) {
        if (DOMRegionContext.XML_CHAR_REFERENCE.equals(r.getType())
            || DOMRegionContext.XML_ENTITY_REFERENCE.equals(r
                .getType())) {
          countedData += 1; // FIXME: what if the entity reference's
          // corresponding data is more than 1
          // char?
          // where can we get that information?
          if (r.getEnd() >= offset) {
            return new DOMPosition(node, countedData);
          }
        } else {
          if (r.getEnd() >= offset) {
            return new DOMPosition(node, countedData + offset
                - r.getStart());
          }
          countedData += r.getLength();
        }
        r = r.getNext();
      }
      return new DOMRefPosition(node, true);
    } else if (node instanceof Element) {
      CMElementDeclaration cm = CMUtil
          .getElementDeclaration((Element) node);
      if (cm != null && cm.getContentType() == CMElementDeclaration.EMPTY) {
        // this node can't have children.
        return new DOMRefPosition(node, true);
      }
      IStructuredDocumentRegion startRegion = node
          .getStartStructuredDocumentRegion();
      if (startRegion == null) {
        return new DOMRefPosition(node, true);
      }
            int startRegionEnd = node.getStartStructuredDocumentRegion()
View Full Code Here

        return parent.getStartOffset() + p.getOffset();
      }
      // CR404708. Need to handle entity reference in the text.
      int offset = p.getOffset();
      int counted = 0;
      IStructuredDocumentRegion r = parent
          .getFirstStructuredDocumentRegion();
      while (r != null && counted < offset) {
        if (DOMRegionContext.XML_CHAR_REFERENCE.equals(r.getType())
            || DOMRegionContext.XML_ENTITY_REFERENCE.equals(r
                .getType())) {
          counted++;
          if (counted >= offset) {
            return r.getEndOffset();
          }
        } else {
          int length = r.getLength();
          if (counted + length >= offset) {
            return r.getStartOffset() + offset - counted;
          }
          counted += length;
        }
        r = r.getNext();
      }
      return parent.getStartOffset() + p.getOffset();
    }
        IDOMNode previous = (IDOMNode) p.getPreviousSiblingNode();
        if (previous != null) {
          return previous.getEndOffset();
        }
        IDOMNode next = (IDOMNode) p.getNextSiblingNode();
        if (next != null) {
          return next.getStartOffset();
        }
        IStructuredDocumentRegion r = parent
            .getStartStructuredDocumentRegion();
        if (r != null) {
          return r.getEnd();
        }
        // r == null normally means the parent is the document node.
        return parent.getEndOffset();
  }
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.