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

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


    ITextRegionList regions = this.endStructuredDocumentRegion.getRegions();
    if (regions == null)
      return null;
    Iterator e = regions.iterator();
    while (e.hasNext()) {
      ITextRegion region = (ITextRegion) e.next();
      String regionType = region.getType();
      if (regionType == DOMRegionContext.XML_TAG_NAME || isNestedEndTag(regionType)) {
        return this.endStructuredDocumentRegion.getText(region);
      }
    }
View Full Code Here


    if (xmlNode == null)
      return false;
   
    IStructuredDocumentRegion sdRegion = xmlNode.getFirstStructuredDocumentRegion();
    ITextRegionList regions = sdRegion.getRegions();
    ITextRegion r = null;
    String attrName = ""; //$NON-NLS-1$
    Object temp = null;
    Position p = null;
    HashMap map = ((AttributeContextInformation) fInfo).getAttr2RangeMap();

    // so we can add ranges in order
    StyleRange[] sorted = new StyleRange[fInfo.getInformationDisplayString().length()];
    for (int i = 0; i < regions.size(); i++) {
      r = regions.get(i);
      if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
        attrName = sdRegion.getText(r);
        temp = map.get(attrName);
        if (temp != null) {
          p = (Position) temp;
          sorted[p.offset] = new StyleRange(p.offset, p.length, null, null, SWT.BOLD);
View Full Code Here

      return null;
    ITextRegionList regions = flatNode.getRegions();
    if (regions == null)
      return null;

    ITextRegion contentRegion = null;
    StringBuffer buffer = null;
    Iterator e = regions.iterator();
    while (e.hasNext()) {
      ITextRegion region = (ITextRegion) e.next();
      String regionType = region.getType();
      if (regionType == DOMRegionContext.XML_COMMENT_OPEN || regionType == DOMRegionContext.XML_COMMENT_CLOSE || isNestedCommentOpenClose(regionType)) {
        continue;
      }
      if (contentRegion == null) { // first content
        contentRegion = region;
View Full Code Here

    }
    return headnode;
  }

  protected ITextRegion getNextRegion() {
    ITextRegion region = null;
    try {
      region = getTokenizer().getNextToken();
      // DMW: 2/12/03 Removed state
      // if (region != null) {
      // fRegions.add(region);
View Full Code Here

    // scanned input
    // they are adjusted here to be indexes from the currentNode's start
    // offset
    IStructuredDocumentRegion headNode = null;
    IStructuredDocumentRegion lastNode = null;
    ITextRegion region = null;
    IStructuredDocumentRegion currentNode = null;
    String type = null;

    while ((region = getNextRegion()) != null) {
      type = region.getType();
      // these types (might) demand a IStructuredDocumentRegion for each
      // of them
      if (type == DOMRegionContext.BLOCK_TEXT) {
        if (currentNode != null && currentNode.getLastRegion().getType() == DOMRegionContext.BLOCK_TEXT) {
          // multiple block texts indicated embedded containers; no
          // new IStructuredDocumentRegion
          currentNode.addRegion(region);
          currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
          region.adjustStart(-currentNode.getStart());
          // DW 4/16/2003 regions no longer have parents
          // region.setParent(currentNode);
        }
        else {
          // not continuing a IStructuredDocumentRegion
          if (currentNode != null) {
            // ensure that any existing node is at least
            // terminated
            if (!currentNode.isEnded()) {
              currentNode.setLength(region.getStart() - currentNode.getStart());
              // fCurrentNode.setTextLength(region.getStart() -
              // fCurrentNode.getStart());
            }
            lastNode = currentNode;
          }
          fireNodeParsed(currentNode);
          currentNode = createStructuredDocumentRegion(type);
          if (lastNode != null) {
            lastNode.setNext(currentNode);
          }
          currentNode.setPrevious(lastNode);
          currentNode.setStart(region.getStart());
          currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
          currentNode.setEnded(true);
          region.adjustStart(-currentNode.getStart());
          currentNode.addRegion(region);
          // DW 4/16/2003 regions no longer have parents
          // region.setParent(currentNode);
        }
      }
      // the following contexts OPEN new StructuredDocumentRegions
      else if ((currentNode != null && currentNode.isEnded()) || (type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_DECLARATION_OPEN)) {
        if (currentNode != null) {
          // ensure that any existing node is at least terminated
          if (!currentNode.isEnded()) {
            currentNode.setLength(region.getStart() - currentNode.getStart());
            // fCurrentNode.setTextLength(region.getStart() -
            // fCurrentNode.getStart());
          }
          lastNode = currentNode;
        }
        fireNodeParsed(currentNode);
        currentNode = createStructuredDocumentRegion(type);
        if (lastNode != null) {
          lastNode.setNext(currentNode);
        }
        currentNode.setPrevious(lastNode);
        currentNode.setStart(region.getStart());
        currentNode.addRegion(region);
        currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
        region.adjustStart(-currentNode.getStart());
        // DW 4/16/2003 regions no longer have parents
        // region.setParent(currentNode);
      }
      // the following contexts neither open nor close
      // StructuredDocumentRegions; just add to them
      else if ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) || (type == DOMRegionContext.XML_COMMENT_TEXT) || (type == DOMRegionContext.XML_PI_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)) {
        currentNode.addRegion(region);
        currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
        region.adjustStart(-currentNode.getStart());
        // DW 4/16/2003 regions no longer have parents
        // region.setParent(currentNode);
      }
      // the following contexts close off StructuredDocumentRegions
      // cleanly
      else if ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE)) {
        currentNode.setEnded(true);
        currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
        currentNode.addRegion(region);
        region.adjustStart(-currentNode.getStart());
        // DW 4/16/2003 regions no longer have parents
        // region.setParent(currentNode);
      }
      // this is extremely rare, but valid
      else if (type == DOMRegionContext.WHITE_SPACE) {
        ITextRegion lastRegion = currentNode.getLastRegion();
        // pack the embedded container with this region
        if (lastRegion instanceof ITextRegionContainer) {
          ITextRegionContainer container = (ITextRegionContainer) lastRegion;
          container.getRegions().add(region);
          // containers must have parent set ...
View Full Code Here

import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;

public class XMLHeadParserFactory {
  public ITextRegion createToken(String context, int start, int textLength, int length, String text) {
    ITextRegion newRegion = null;
    //    if (context == XMLRegionContext.XML_CDATA_TEXT) {
    newRegion = new XMLHeadParserRegion(context, start, textLength, length, text);
    //    }
    return newRegion;
  }
View Full Code Here

  /**
   * The parameter offset refers to the overall offset in the document.
   */
  public ITextRegion getRegionAtCharacterOffset(int offset) {
    ITextRegion result = null;
    if (regions != null) {
      int thisStartOffset = getStartOffset();
      if (offset < thisStartOffset)
        return null;
      int thisEndOffset = getStartOffset() + getLength();
      if (offset > thisEndOffset)
        return null;
      // transform the requested offset to the "scale" that
      // regions are stored in, which are all relative to the
      // start point.
      //int transformedOffset = offset - getStartOffset();
      //
      ITextRegionList regions = getRegions();
      int length = regions.size();
      int low = 0;
      int high = length;
      int mid = 0;
      // Binary search for the region
      while (low < high) {
        mid = low + ((high - low) >> 1);
        ITextRegion region = regions.get(mid);
        if (org.eclipse.wst.sse.core.internal.util.Debug.debugStructuredDocument) {
          System.out.println("region(s) in IStructuredDocumentRegion::getRegionAtCharacterOffset: " + region); //$NON-NLS-1$
          System.out.println("       midpoint of search:" + mid); //$NON-NLS-1$
          System.out.println("       requested offset: " + offset); //$NON-NLS-1$
          //System.out.println(" transformedOffset: " +
          // transformedOffset); //$NON-NLS-1$
          System.out.println("       region start: " + region.getStart()); //$NON-NLS-1$
          System.out.println("       region end: " + region.getEnd()); //$NON-NLS-1$
          System.out.println("       region type: " + region.getType()); //$NON-NLS-1$
          System.out.println("       region class: " + region.getClass()); //$NON-NLS-1$

        }
        // Region is before this one
        if (offset < region.getStart() + thisStartOffset)
          high = mid;
        else if (offset > (region.getEnd() + thisStartOffset - 1))
          low = mid + 1;
        else
          return region;
      }
      return null;
View Full Code Here

  public int getTextEnd() {
    return start + textLength;
  }

  public int getTextEndOffset() {
    ITextRegion region = regions.get(regions.size() - 1);
    // our startOffset take into account our parent, and our start
    // (pa) 10/4 changed to be based on text end
    //           it used to return incorrect value for embedded region containers
    //

    // TODO CRITICAL -- need to re-work this work around, so doesn't
    // depend on XMLRegionContext
    //    // this is a workaround for 226823///////////
    //    for (int i = regions.size() - 1; i >= 0 && region.getType() ==
    // XMLRegionContext.WHITE_SPACE; i--)
    //      region = (ITextRegion) regions.get(i);
    //    /////////////////////////////////////////////

    return getStartOffset() + region.getTextEnd();
  }
View Full Code Here

  public int getTextEndOffset(ITextRegion containedRegion) {
    int result = 0;
    if (regions != null) {
      int length = getRegions().size();
      for (int i = 0; i < length; i++) {
        ITextRegion region = getRegions().get(i);
        if (region == containedRegion) {
          result = getStartOffset(region) + region.getTextEnd();
          break;
        }
      }
    }
    return result;
View Full Code Here

  private void getLocalRenameQuickAssistProposal(List proposals, ISourceViewer viewer, int offset) {
    IDOMNode node = (IDOMNode) getNodeAt(viewer, offset);
    IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion();
    IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion();

    ITextRegion region = null;
    int regionTextEndOffset = 0;
    if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
      region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
      regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region);
    }
    else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) {
      region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
      regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region);
    }

    if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) {
      proposals.add(new RenameInFileQuickAssistProposal());
    }
  }
View Full Code Here

TOP

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

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.