use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.
the class SyntaxValidator method getEndTagFullText.
private String getEndTagFullText(ElementInfo info) {
// $NON-NLS-1$
String hint = "";
ITextRegionList regions = info.endTag.getRegions();
Iterator iter = regions.iterator();
while (iter.hasNext()) {
ITextRegion rgn = (ITextRegion) iter.next();
String type = rgn.getType();
if (type == null)
continue;
if (type == DOMRegionContext.XML_END_TAG_OPEN || type == DOMRegionContext.XML_TAG_CLOSE)
continue;
hint += info.endTag.getFullText(rgn);
}
return hint;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.
the class HTMLTokenizer method getRegions.
/**
* user method - skeleton.sed
*
* Return ALL of the regions scannable within the remaining text
* Note: for verification use
*/
public final List getRegions() {
List tokens = new ArrayList();
ITextRegion region = null;
try {
region = getNextToken();
while (region != null) {
if (region != null) {
tokens.add(region);
}
region = getNextToken();
}
} catch (StackOverflowError e) {
// $NON-NLS-1$
Logger.logException(getClass().getName() + ": input could not be tokenized correctly at position " + getOffset(), e);
throw e;
} catch (Exception e) {
// Since this is convenience method and NOT the recommended
// way of getting tokens, many errors are simply hidden
// $NON-NLS-1$
Logger.logException("Exception not handled retrieving regions: " + e.getLocalizedMessage(), e);
}
return tokens;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.
the class FMUtil method getSegment.
/**
*/
public static final Segment getSegment(IDOMNode target, int segType) {
if (target == null)
return new Segment(0, 0);
Segment seg = null;
IStructuredDocumentRegion startTag = null;
IStructuredDocumentRegion endTag = null;
switch(segType) {
case SEG_WHOLE_TAG:
startTag = target.getFirstStructuredDocumentRegion();
if (startTag != null) {
endTag = target.getLastStructuredDocumentRegion();
seg = new Segment(startTag, endTag);
} else {
int startOffset = target.getStartOffset();
int endOffset = target.getEndOffset();
seg = new Segment(startOffset, endOffset - startOffset);
}
break;
case SEG_START_TAG:
startTag = target.getStartStructuredDocumentRegion();
if (startTag != null) {
seg = new Segment(startTag);
} else {
seg = new Segment(target.getStartOffset(), 1);
}
break;
case SEG_END_TAG:
endTag = target.getEndStructuredDocumentRegion();
if (endTag != null) {
seg = new Segment(endTag);
} else {
seg = new Segment(target.getEndOffset(), 1);
}
break;
case SEG_START_TAG_NAME:
startTag = target.getStartStructuredDocumentRegion();
if (startTag != null) {
ITextRegion nameRegion = getNameRegion(startTag);
if (nameRegion != null) {
seg = new Segment(startTag.getStartOffset(nameRegion), nameRegion.getTextLength());
}
}
if (seg == null) {
seg = getSegment(target, SEG_START_TAG);
}
break;
case SEG_END_TAG_NAME:
endTag = target.getEndStructuredDocumentRegion();
if (endTag != null) {
ITextRegion nameRegion = getNameRegion(endTag);
if (nameRegion != null) {
seg = new Segment(endTag.getStartOffset(nameRegion), nameRegion.getTextLength());
}
}
if (seg == null) {
seg = getSegment(target, SEG_END_TAG);
}
break;
case SEG_NONE:
default:
return new Segment(0, 0);
}
return seg;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.
the class RegionIterator method prev.
/**
*/
public ITextRegion prev() {
if (documentRegion == null)
return null;
if (current < 0 || documentRegion.getRegions() == null || documentRegion.getRegions().size() <= current)
return null;
ITextRegion region = documentRegion.getRegions().get(current);
curDocumentRegion = documentRegion;
if (current == 0) {
documentRegion = documentRegion.getPrevious();
if (documentRegion != null)
current = documentRegion.getRegions().size();
else
current = 0;
}
current--;
return region;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion in project webtools.sourceediting by eclipse.
the class CSSUtil method stripSurroundingSpace.
/**
*/
public static void stripSurroundingSpace(ITextRegionList regions) {
if (regions == null) {
return;
}
while (!regions.isEmpty()) {
ITextRegion region = regions.get(0);
String type = region.getType();
if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
regions.remove(0);
} else {
break;
}
}
while (!regions.isEmpty()) {
ITextRegion region = regions.get(regions.size() - 1);
String type = region.getType();
if (type == CSSRegionContexts.CSS_S || type == CSSRegionContexts.CSS_COMMENT) {
regions.remove(region);
} else {
break;
}
}
}
Aggregations