use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection in project webtools.sourceediting by eclipse.
the class LineStyleProviderForXSL method prepareTextRegion.
/**
* @param region
* @param start
* @param length
* @param holdResults
* @return
*/
protected boolean prepareTextRegion(ITextRegionCollection blockedRegion, int partitionStartOffset, int partitionLength, Collection holdResults) {
boolean handled = false;
final int partitionEndOffset = partitionStartOffset + partitionLength - 1;
ITextRegion region = null;
ITextRegionList regions = blockedRegion.getRegions();
StyleRange styleRange = null;
for (int i = 0; i < regions.size(); i++) {
region = regions.get(i);
TextAttribute attr = null;
TextAttribute previousAttr = null;
if (blockedRegion.getStartOffset(region) > partitionEndOffset)
break;
if (blockedRegion.getEndOffset(region) <= partitionStartOffset)
continue;
if (region instanceof ITextRegionCollection) {
handled = prepareTextRegion((ITextRegionCollection) region, partitionStartOffset, partitionLength, holdResults);
} else {
attr = getAttributeFor(blockedRegion, region);
if (attr != null) {
handled = true;
styleRange = applyStyleRange(blockedRegion, partitionStartOffset, partitionLength, holdResults, region, styleRange, attr, previousAttr);
} else {
previousAttr = null;
}
}
}
return handled;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection in project webtools.sourceediting by eclipse.
the class Debug method printChildRegions.
private static void printChildRegions(ITextRegionCollection region, int depth) {
if (region != null) {
// ==> // ITextRegionCollection regionCollection = region;
System.out.println(region);
ITextRegionList regionList = region.getRegions();
for (int i = 0; i < regionList.size(); i++) {
ITextRegion r = regionList.get(i);
if (r instanceof ITextRegionCollection) {
ITextRegionCollection rc = (ITextRegionCollection) r;
printChildRegions(rc, depth++);
} else {
System.out.println(space(depth) + r);
depth--;
}
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection in project webtools.sourceediting by eclipse.
the class JsValidator method createMessageFromProblem.
/**
* Creates an IMessage from an IProblem
*
* @param problem
* @param f
* @param translation
* @param textDoc
* @return message representation of the problem, or null if it could not
* create one
*/
private IMessage createMessageFromProblem(IProblem problem, IFile f, IJsTranslation translation, IDocument textDoc) {
int sourceStart = problem.getSourceStart();
int sourceEnd = problem.getSourceEnd();
if (sourceStart == -1) {
return null;
}
sourceStart = translation.getWebPageOffset(sourceStart);
sourceEnd = translation.getWebPageOffset(sourceEnd);
/*
* Bug 241794 - Validation shows errors when using JSP Expressions
* inside JavaScript code
*/
IStructuredDocument doc = (IStructuredDocument) textDoc;
IStructuredDocumentRegion documentRegion = doc.getRegionAtCharacterOffset(sourceStart);
if (documentRegion != null) {
ITextRegion textRegion = documentRegion.getRegionAtCharacterOffset(sourceStart);
/*
* Filter out problems from areas that aren't simple JavaScript,
* e.g. JSP.
*/
if (textRegion != null && textRegion instanceof ITextRegionCollection)
return null;
}
int sev = problem.isError() ? IMessage.HIGH_SEVERITY : (problem.isWarning() ? IMessage.NORMAL_SEVERITY : IMessage.LOW_SEVERITY);
IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);
// line numbers from document starts @ 0
try {
int lineNo = textDoc.getLineOfOffset(sourceStart) + 1;
m.setLineNo(lineNo);
m.setOffset(sourceStart);
m.setLength(sourceEnd - sourceStart + 1);
} catch (BadLocationException e) {
Logger.logException(e);
}
return m;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection in project webtools.sourceediting by eclipse.
the class Debug method printChildRegions.
private static void printChildRegions(ITextRegionCollection region, int depth) {
if (region != null) {
// ==> // ITextRegionCollection regionCollection = region;
System.out.println(region);
ITextRegionList regionList = region.getRegions();
for (int i = 0; i < regionList.size(); i++) {
ITextRegion r = regionList.get(i);
if (r instanceof ITextRegionCollection) {
ITextRegionCollection rc = (ITextRegionCollection) r;
printChildRegions(rc, depth++);
} else {
System.out.println(space(depth) + r);
depth--;
}
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection in project webtools.sourceediting by eclipse.
the class Debug method dump.
public static final void dump(IStructuredDocument structuredDocument, boolean verbose) {
ITextRegionCollection flatNode = null;
// $NON-NLS-1$
System.out.println("Dump of structuredDocument:");
IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
Enumeration structuredDocumentRegions = flatNodes.elements();
while (structuredDocumentRegions.hasMoreElements()) {
flatNode = (ITextRegionCollection) structuredDocumentRegions.nextElement();
if (!verbose) {
String outString = flatNode.toString();
outString = org.eclipse.wst.sse.core.utils.StringUtils.escape(outString);
System.out.println(outString);
} else {
dump(flatNode, verbose);
}
}
System.out.println();
// $NON-NLS-1$
System.out.println("= = = = = =");
System.out.println();
}
Aggregations