Search in sources :

Example 1 with RegionIterator

use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.

the class ExternalNode method getPublicValueRegion.

public ITextRegion getPublicValueRegion() {
    RegionIterator iter = iterator();
    ITextRegion publicKeyword = getPublicKeywordRegion(iter);
    if (publicKeyword != null && iter.hasNext()) {
        ITextRegion quotedLiteral = getNextQuotedLiteral(iter);
        if (quotedLiteral != null) {
            return quotedLiteral;
        }
    }
    return null;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.dtd.core.internal.text.RegionIterator)

Example 2 with RegionIterator

use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.

the class NamedTopLevelNode method getWhitespaceAfterName.

public ITextRegion getWhitespaceAfterName() {
    ITextRegion nameRegion = getNameRegion();
    RegionIterator iter = iterator();
    // skip past the element tag region
    getNextRegion(iter, tagStartType);
    boolean foundName = false;
    while (iter.hasNext()) {
        ITextRegion region = iter.next();
        if (!foundName && nameRegion != null && region == nameRegion) {
            foundName = true;
        }
        if (region.getType().equals(DTDRegionTypes.WHITESPACE)) {
            // there is no name region or we have already passed it
            if (nameRegion == null || foundName) {
                return region;
            }
        }
    }
    return null;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.dtd.core.internal.text.RegionIterator)

Example 3 with RegionIterator

use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.

the class AttributeEnumList method getItems.

// return the items that are in this enumerated list
public List getItems() {
    list.clear();
    RegionIterator iter = iterator();
    while (iter.hasNext()) {
        ITextRegion name = getNextRegion(iter, DTDRegionTypes.NAME);
        if (name != null) {
            list.add(getStructuredDTDDocumentRegion().getText(name));
        }
    }
    return list;
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.dtd.core.internal.text.RegionIterator)

Example 4 with RegionIterator

use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.

the class Comment method getStartAndEndOffsetForText.

private void getStartAndEndOffsetForText(StartEndPair pair) {
    RegionIterator iter = iterator();
    ITextRegion commentStartTag = getStartTag(iter);
    ITextRegion endCommentTag = getNextRegion(iter, DTDRegionTypes.COMMENT_END);
    pair.endOffset = getStructuredDTDDocumentRegion().getEndOffset();
    if (commentStartTag != null) {
        pair.startOffset = getStructuredDTDDocumentRegion().getEndOffset(commentStartTag);
    }
    if (endCommentTag != null) {
        pair.endOffset = getStructuredDTDDocumentRegion().getStartOffset(endCommentTag);
    }
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.dtd.core.internal.text.RegionIterator)

Example 5 with RegionIterator

use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.

the class CMGroupNode method getOccurrenceRegion.

// returns the occurrenceregion, or the last region where the occurrence
// region should appear after
public ITextRegion getOccurrenceRegion() {
    int nesting = 0;
    // we skip past the first left paren we see since that is the
    // beginning of our own node
    RegionIterator iter = iterator();
    // we assume the first region is the '('
    iter.next();
    ITextRegion currentRegion = null;
    while (iter.hasNext() && nesting >= 0) {
        currentRegion = iter.next();
        if (currentRegion.getType() == DTDRegionTypes.LEFT_PAREN) {
            nesting++;
        }
        if (currentRegion.getType() == DTDRegionTypes.RIGHT_PAREN) {
            nesting--;
        }
    }
    if (nesting < 0) {
        // Look for an occurrence region
        while (iter.hasNext()) {
            currentRegion = iter.next();
            if (currentRegion.getType() == DTDRegionTypes.OCCUR_TYPE) {
                return currentRegion;
            }
        }
    }
    // last region
    return iter.previous();
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) RegionIterator(org.eclipse.wst.dtd.core.internal.text.RegionIterator)

Aggregations

RegionIterator (org.eclipse.wst.dtd.core.internal.text.RegionIterator)22 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)22 ArrayList (java.util.ArrayList)1