Search in sources :

Example 96 with ITextRegion

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion 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 97 with ITextRegion

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion 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 98 with ITextRegion

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion 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 99 with ITextRegion

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.

the class DTDNode method setName.

public void setName(Object requestor, String name) {
    if (!getName().equals(name)) {
        ITextRegion nameRegion = getNameRegion();
        if (nameRegion != null) {
            // nameToken.updateText(name);
            getDTDFile().getDTDModel().getReferenceUpdater().nameAboutToChange(requestor, this, name);
            replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(nameRegion), nameRegion.getLength(), name);
        }
    }
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)

Example 100 with ITextRegion

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.

the class Element method addContent.

protected void addContent(Object requestor, String content) {
    ITextRegion whitespace = getWhitespaceAfterName();
    int startOffset = 0;
    int length = 0;
    if (whitespace != null) {
        startOffset = getStructuredDTDDocumentRegion().getStartOffset(whitespace);
        length = whitespace.getLength() >= 2 ? 1 : 0;
    } else {
        ITextRegion nameRegion = getNameRegion();
        if (nameRegion != null) {
            startOffset = getStructuredDTDDocumentRegion().getEndOffset(nameRegion);
        } else {
            ITextRegion elementTag = getNextRegion(iterator(), DTDRegionTypes.ELEMENT_TAG);
            startOffset = getStructuredDTDDocumentRegion().getEndOffset(elementTag);
        }
    }
    replaceText(requestor, startOffset, length, content);
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)

Aggregations

ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)447 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)179 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)174 Iterator (java.util.Iterator)75 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)58 ArrayList (java.util.ArrayList)40 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)39 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)35 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)35 List (java.util.List)33 RegionIterator (org.eclipse.wst.css.core.internal.util.RegionIterator)31 BadLocationException (org.eclipse.jface.text.BadLocationException)30 RegionIterator (org.eclipse.wst.dtd.core.internal.text.RegionIterator)22 TextRegionListImpl (org.eclipse.wst.sse.core.internal.text.TextRegionListImpl)19 ITextRegionCollection (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)16 Node (org.w3c.dom.Node)16 ContextRegion (org.eclipse.wst.sse.core.internal.parser.ContextRegion)15 IOException (java.io.IOException)13 IRegion (org.eclipse.jface.text.IRegion)13 StyleRange (org.eclipse.swt.custom.StyleRange)13