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;
}
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;
}
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);
}
}
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);
}
}
}
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);
}
Aggregations