Examples of ITextRegionList


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

    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;
    String endType;
    if (node.isCommentTag()) {
      startType = DOMRegionContext.XML_COMMENT_OPEN;
      endType = DOMRegionContext.XML_COMMENT_CLOSE;
    } else {
      startType = DOMRegionContext.XML_TAG_NAME;
      endType = DOMRegionContext.XML_TAG_CLOSE;
    }

    int startOffset = -1;
    int endOffset = -1;
    ITextRegion prevRegion = null;
    ITextRegion region;
    for (int i = 0; i < regions.size(); i++) {
      region = regions.get(i);
      String type = region.getType();
      if (type == startType) {
        startOffset = region.getEnd();
      } else if (type == endType && prevRegion != null) {
        endOffset = prevRegion.getTextEnd();
View Full Code Here

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

  /**
   */
  private String getData(IStructuredDocumentRegion flatNode) {
    if (flatNode == null)
      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_CDATA_OPEN || regionType == DOMRegionContext.XML_CDATA_CLOSE) {
        continue;
View Full Code Here

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

        // end tag's indent level should be same as start tag's
        childrenConstraints.setIndentLevel(thisConstraints.getIndentLevel());
        // format end tag
        boolean formatEndTag = false;
        if (nextRegion != null && currentDOMNode != null) {
          ITextRegionList rs = nextRegion.getRegions();
          if (rs.size() > 1) {
            ITextRegion r = rs.get(0);
            if (r != null && DOMRegionContext.XML_END_TAG_OPEN.equals(r.getType())) {
              r = rs.get(1);
              if (r != null && DOMRegionContext.XML_TAG_NAME.equals(r.getType())) {
                String tagName = nextRegion.getText(r);
                if (tagName != null && tagName.equals(currentDOMNode.getNodeName()))
                  formatEndTag = true;
              }
View Full Code Here

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

  private void formatWithinEndTag(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion) {
    String indentStrategy = constraints.getIndentStrategy();
    String whitespaceStrategy = constraints.getWhitespaceStrategy();
    int availableLineWidth = constraints.getAvailableLineWidth();
    ITextRegionList textRegions = currentDocumentRegion.getRegions();
    int currentNumberOfRegions = currentDocumentRegion.getNumberOfRegions();
    int currentTextRegionIndex = 1;

    ITextRegion currentTextRegion = textRegions.get(currentTextRegionIndex);
    String currentType = currentTextRegion.getType();
    // tag name should always be the first text region
    if (DOMRegionContext.XML_TAG_NAME.equals(currentType) && currentTextRegionIndex < currentNumberOfRegions - 1) {
      ITextRegion nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
      // Bug 221279 - Some non well-formed documents will not contribute a next region
      if (nextTextRegion != null && DOMRegionContext.XML_TAG_CLOSE.equals(nextTextRegion.getType())) {
        // calculate available line width
        int tagNameLineWidth = currentTextRegion.getTextLength() + 3;
        availableLineWidth -= tagNameLineWidth;
View Full Code Here

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

  private boolean formatWithinTag(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion) {
    int availableLineWidth = constraints.getAvailableLineWidth();
    String indentStrategy = constraints.getIndentStrategy();
    String whitespaceStrategy = constraints.getWhitespaceStrategy();
    int indentLevel = constraints.getIndentLevel();
    ITextRegionList textRegions = currentDocumentRegion.getRegions();
    int currentTextRegionIndex = 1;

    ITextRegion currentTextRegion = textRegions.get(currentTextRegionIndex);
    String currentType = currentTextRegion.getType();
    // tag name should always be the first text region
    if (DOMRegionContext.XML_TAG_NAME.equals(currentType)) {
      ITextRegion nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
      String nextType = (nextTextRegion != null) ? nextTextRegion.getType() : null;
      if (DOMRegionContext.XML_TAG_CLOSE.equals(nextType)) {
        // already at tag close
        formatStartTagWithNoAttr(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, availableLineWidth, indentStrategy, whitespaceStrategy, currentTextRegion);
        return false;
      }
      else if (DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(nextType)) {
        // already at empty tag close
        formatEmptyStartTagWithNoAttr(textEdit, constraints, currentDocumentRegion, previousDocumentRegion, availableLineWidth, indentStrategy, whitespaceStrategy, currentTextRegion);
        return true;
      }
      else {
        availableLineWidth -= (currentTextRegion.getTextLength() + 2);
        boolean alignFinalBracket = getFormattingPreferences().getAlignFinalBracket();
        boolean oneSpaceInTagName = getFormattingPreferences().getSpaceBeforeEmptyCloseTag();
        boolean indentMultipleAttribute = getFormattingPreferences().getIndentMultipleAttributes();
        // indicates if tag spanned more than one line
        boolean spanMoreThan1Line = false;
        // indicates if all attributes should be indented
        boolean indentAllAttributes = false;
        if (indentMultipleAttribute) {
          int attributesCount = 0;
          int i = 2;
          final int size = textRegions.size();
          while (i < size && attributesCount < 2) {
            if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(textRegions.get(i).getType())) {
              ++attributesCount;
            }
            i++;
          }
          indentAllAttributes = (attributesCount > 1);
        }

        while ((currentTextRegionIndex + 1) < textRegions.size()) {
          nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
          nextType = nextTextRegion.getType();
          if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(nextType)) {
            boolean indentAttribute = indentAllAttributes;
            if (!indentAttribute)
              indentAttribute = shouldIndentBeforeAttribute(constraints, textRegions, availableLineWidth, currentTextRegionIndex, currentTextRegion, nextTextRegion);
View Full Code Here

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

            childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
          }
        }
        else {
          // search within current tag for xml:space attribute
          ITextRegionList textRegions = currentRegion.getRegions();
          int i = 0;
          boolean xmlSpaceFound = false;
          boolean preserveFound = false;
          while (i < textRegions.size() && !xmlSpaceFound) {
            ITextRegion textRegion = textRegions.get(i);
            if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(textRegion.getType())) {
              String regionText = currentRegion.getText(textRegion);
              if (XML_SPACE.equals(regionText)) {
                if ((i + 1) < textRegions.size()) {
                  ++i;
                  textRegion = textRegions.get(i);
                  if (DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS.equals(textRegion.getType()) && ((i + 1) < textRegions.size())) {
                    ++i;
                    textRegion = textRegions.get(i);
                    regionText = currentRegion.getText(textRegion);
                    if (PRESERVE.equals(regionText) || PRESERVE_QUOTED.equals(regionText)) {
                      preserveFound = true;
                    }
                  }
View Full Code Here

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

        return;
      }
    }

    // update attributes
    ITextRegionList regions = flatNode.getRegions();
    if (regions == null)
      return; // error
    NamedNodeMap attributes = element.getAttributes();
    if (attributes == null)
      return; // error

    // first remove attributes
    int regionIndex = 0;
    int attrIndex = 0;
    AttrImpl attr = null;
    while (attrIndex < attributes.getLength()) {
      attr = (AttrImpl) attributes.item(attrIndex);
      if (attr == null) { // error
        attrIndex++;
        continue;
      }
      ITextRegion nameRegion = attr.getNameRegion();
      if (nameRegion == null) { // error
        element.removeAttributeNode(attr);
        continue;
      }
      boolean found = false;
      for (int i = regionIndex; i < regions.size(); i++) {
        ITextRegion region = regions.get(i);
        if (region == nameRegion) {
          regionIndex = i + 1; // next region
          found = true;
          break;
        }
      }
      if (found) {
        attrIndex++;
      }
      else {
        element.removeAttributeNode(attr);
      }
    }

    // insert or update attributes
    attrIndex = 0; // reset to first
    AttrImpl newAttr = null;
    ITextRegion oldValueRegion = null;
    Iterator e = regions.iterator();
    while (e.hasNext()) {
      ITextRegion region = (ITextRegion) e.next();
      String regionType = region.getType();
      if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
        if (newAttr != null) {
View Full Code Here

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

  /**
   * insertCDATASection method
   *
   */
  private void insertCDATASection(IStructuredDocumentRegion flatNode) {
    ITextRegionList regions = flatNode.getRegions();
    if (regions == null)
      return;

    CDATASectionImpl cdata = null;
    try {
View Full Code Here

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

  /**
   * insertComment method
   *
   */
  private void insertComment(IStructuredDocumentRegion flatNode) {
    ITextRegionList regions = flatNode.getRegions();
    if (regions == null)
      return;

    StringBuffer data = null;
    boolean isJSPTag = false;
    Iterator e = regions.iterator();
    while (e.hasNext()) {
      ITextRegion region = (ITextRegion) e.next();
      String regionType = region.getType();
      if (isNestedCommentOpen(regionType)) {
        isJSPTag = true;
View Full Code Here

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

  /**
   * insertDecl method
   *
   */
  private void insertDecl(IStructuredDocumentRegion flatNode) {
    ITextRegionList regions = flatNode.getRegions();
    if (regions == null)
      return;

    boolean isDocType = false;
    String name = null;
    String publicId = null;
    String systemId = null;
    Iterator e = regions.iterator();
    while (e.hasNext()) {
      ITextRegion region = (ITextRegion) e.next();
      String regionType = region.getType();
      if (regionType == DOMRegionContext.XML_DOCTYPE_DECLARATION) {
        isDocType = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.