use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.
the class NamedTopLevelNode method setName.
public void setName(Object requestor, String name) {
ITextRegion nameRegion = getNameRegion();
if (nameRegion != null) {
super.setName(requestor, name);
} else {
RegionIterator iter = iterator();
ITextRegion elementTagRegion = getNextRegion(iter, tagStartType);
int replaceLength = 0;
if (iter.hasNext()) {
ITextRegion region = iter.next();
if (region.getType().equals(DTDRegionTypes.WHITESPACE)) {
if (region.getLength() >= 2) {
// there are 2 spaces between 'ELEMENT' and the
// content
// Change replace length to 1 so that the new name and
// the content are separated by a single space
replaceLength = 1;
}
}
}
// beginRecording(requestor, "Name Change");
// $NON-NLS-1$
String newText = " " + name;
replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(elementTagRegion), replaceLength, newText);
// endRecording(requestor);
}
}
use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.
the class CMBasicNode method getOccurrenceRegion.
// returns the occurrencetoken, or the token where the occurrence token
// should appear after
public ITextRegion getOccurrenceRegion() {
RegionIterator iter = iterator();
skipPastName(iter);
if (iter.hasNext()) {
ITextRegion region = iter.next();
if (region.getType() == DTDRegionTypes.OCCUR_TYPE) {
return region;
}
}
return getNameRegion();
}
use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.
the class DTDNode method getFullNodeText.
public String getFullNodeText() {
String text = getNodeText();
if (whitespace.size() > 0) {
RegionIterator iter = new RegionIterator(whitespace);
while (iter.hasNext()) {
ITextRegion region = iter.next();
text += getStructuredDTDDocumentRegion().getText(region);
}
}
return text;
}
use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.
the class DTDNode method getNodeText.
public String getNodeText() {
StringBuffer sb = new StringBuffer();
RegionIterator iter = iterator();
while (iter.hasNext()) {
ITextRegion region = iter.next();
sb.append(getStructuredDTDDocumentRegion().getText(region));
}
return sb.toString();
}
use of org.eclipse.wst.dtd.core.internal.text.RegionIterator in project webtools.sourceediting by eclipse.
the class Element method resolveRegions.
public void resolveRegions() {
// System.out.println("element node stream = " +
// tokenStream.getString());
fContentModel = null;
removeChildNodes();
RegionIterator iter = iterator();
if (getNameRegion() != null) {
// we skip past the name token is our name
skipPastName(iter);
}
while (iter.hasNext()) {
ITextRegion currentRegion = iter.next();
if (fContentModel == null) {
if (currentRegion.getType().equals(DTDRegionTypes.NAME)) {
fContentModel = new CMBasicNode(getDTDFile(), getStructuredDTDDocumentRegion());
} else if (currentRegion.getType().equals(DTDRegionTypes.CONTENT_PCDATA)) {
fContentModel = new CMBasicNode(getDTDFile(), getStructuredDTDDocumentRegion());
} else if (currentRegion.getType().equals(DTDRegionTypes.LEFT_PAREN)) {
fContentModel = new CMGroupNode(getDTDFile(), getStructuredDTDDocumentRegion());
}
}
if (fContentModel != null) {
if (!currentRegion.getType().equals(DTDRegionTypes.END_TAG)) {
// content model gets all regions except for the '>'
fContentModel.addRegion(currentRegion);
} else {
// for the content model
break;
}
}
}
if (fContentModel != null) {
appendChild(fContentModel);
// this is the root element content so set it true
fContentModel.setRootElementContent(true);
// now tell the content model to resolve it's regions
fContentModel.resolveRegions();
}
}
Aggregations