use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList in project webtools.sourceediting by eclipse.
the class JSPTranslator method isEmptyTag.
private boolean isEmptyTag(ITextRegionCollection customTag, int index) {
String type = null;
// custom tag is embedded
ITextRegionList regions = customTag.getRegions();
ITextRegion nextRegion = regions.get(index);
int size = customTag.getNumberOfRegions();
type = nextRegion.getType();
while (index <= size && !(DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(type) || DOMRegionContext.XML_TAG_NAME.equals(type) || DOMRegionContext.XML_TAG_CLOSE.equals(type))) {
nextRegion = regions.get(++index);
type = nextRegion.getType();
}
return DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(type);
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList in project webtools.sourceediting by eclipse.
the class JSPTranslator method translateXMLContent.
/**
* This currently only detects EL content and translates it,
* but if other cases arise later then they could be added in here
*
* @param embeddedContainer the container that may contain EL
*/
protected void translateXMLContent(ITextRegionContainer embeddedContainer) {
ITextRegionList embeddedRegions = embeddedContainer.getRegions();
int length = embeddedRegions.size();
for (int i = 0; i < length; i++) {
ITextRegion delim = embeddedRegions.get(i);
String type = delim.getType();
// check next region to see if it's EL content
if (i + 1 < length) {
if ((type == DOMJSPRegionContexts.JSP_EL_OPEN || type == DOMJSPRegionContexts.JSP_VBL_OPEN)) {
ITextRegion region = null;
int start = delim.getEnd();
while (++i < length) {
region = embeddedRegions.get(i);
if (region == null || !isELType(region.getType()))
break;
}
fLastJSPType = EXPRESSION;
String elText = embeddedContainer.getFullText().substring(start, (region != null ? region.getStart() : embeddedContainer.getLength() - 1));
translateEL(elText, embeddedContainer.getText(delim), fCurrentNode, embeddedContainer.getEndOffset(delim), elText.length());
}
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList in project webtools.sourceediting by eclipse.
the class XMLJSPRegionHelper method hasIllegalContent.
private int hasIllegalContent(IStructuredDocumentRegion sdRegion) {
ITextRegionList list = sdRegion.getRegions();
for (int i = 0; i < list.size(); i++) {
ITextRegion region = list.get(i);
String type = region.getType();
if (type == DOMRegionContext.UNDEFINED)
return i;
if (type == DOMRegionContext.XML_END_TAG_OPEN || type == DOMRegionContext.XML_EMPTY_TAG_CLOSE || type == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE)
return -1;
}
return -1;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList in project webtools.sourceediting by eclipse.
the class XMLJSPRegionHelper method getRegionName.
protected String getRegionName(IStructuredDocumentRegion sdRegion) {
// $NON-NLS-1$
String nameStr = "";
ITextRegionList regions = sdRegion.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion r = regions.get(i);
if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
nameStr = fTextToParse.substring(sdRegion.getStartOffset(r), sdRegion.getTextEndOffset(r));
break;
}
}
return nameStr.trim();
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList in project webtools.sourceediting by eclipse.
the class StructuredDocumentReParser method replaceRegions.
protected void replaceRegions(IStructuredDocumentRegion oldNode, ITextRegionList oldRegions, IStructuredDocumentRegion newNode, ITextRegionList newRegions) {
int insertPos = -1;
ITextRegionList regions = oldNode.getRegions();
// offset
if (oldRegions.size() == 0) {
ITextRegion firstNewRegion = newRegions.get(0);
int firstOffset = newNode.getStartOffset(firstNewRegion);
// if at beginning, insert there
if (firstOffset == 0) {
insertPos = 0;
} else {
//
ITextRegion regionAtOffset = oldNode.getRegionAtCharacterOffset(firstOffset);
if (regionAtOffset == null)
insertPos = regions.size();
else
insertPos = regions.indexOf(regionAtOffset);
}
} else {
// else, delete old ones before inserting new ones in their place
ITextRegion firstOldRegion = oldRegions.get(0);
insertPos = regions.indexOf(firstOldRegion);
regions.removeAll(oldRegions);
}
regions.addAll(insertPos, newRegions);
// now regions vector of each node should be of equal length,
// so go through each, and make sure the old regions
// offsets matches the new regions offsets
// (we'll just assign them all, but could be slightly more effiecient)
ITextRegionList allNewRegions = newNode.getRegions();
for (int i = 0; i < regions.size(); i++) {
ITextRegion nextOldishRegion = regions.get(i);
ITextRegion nextNewRegion = allNewRegions.get(i);
nextOldishRegion.equatePositions(nextNewRegion);
checkAndAssignParent(oldNode, nextOldishRegion);
}
oldNode.setLength(newNode.getLength());
oldNode.setEnded(newNode.isEnded());
oldNode.setParentDocument(newNode.getParentDocument());
// removed concept of part of these regions, so no longer need to do.
// for (int i = 0; i < oldRegions.size(); i++) {
// ITextRegion region = (ITextRegion) oldRegions.elementAt(i);
// region.setParent(holdOldStructuredDocumentRegion);
// }
}
Aggregations