use of org.eclipse.wst.sse.core.internal.text.CoreNodeList in project webtools.sourceediting by eclipse.
the class CSSModelParser method getStructuredDocumentRegionList.
/**
*/
private IStructuredDocumentRegionList getStructuredDocumentRegionList(int start, int end) {
IStructuredDocumentRegionList nodeList = null;
if (0 <= start && start <= end) {
ICSSModel model = fDocument.getModel();
if (model instanceof CSSModelImpl) {
IStructuredDocument structuredDocument = ((CSSModelImpl) model).getStructuredDocument();
if (structuredDocument != null) {
IStructuredDocumentRegion startNode = structuredDocument.getRegionAtCharacterOffset(start);
IStructuredDocumentRegion endNode = structuredDocument.getRegionAtCharacterOffset(end - 1);
if (startNode != null && endNode != null) {
nodeList = new CoreNodeList(startNode, endNode);
}
}
}
}
return nodeList;
}
use of org.eclipse.wst.sse.core.internal.text.CoreNodeList in project webtools.sourceediting by eclipse.
the class ScannerUnitTests method testBlockScanBufferBoundaries.
protected void testBlockScanBufferBoundaries(String contentTypeID) {
IStructuredDocument document = null;
// for (int i = 17000; i > 15000; i--) {
for (int i = 16384 + 25; i > 16364 - 25; i--) {
StringBuffer text = new StringBuffer();
document = StructuredModelManager.getModelManager().createStructuredDocumentFor(contentTypeID);
appendTagBlock(text, "script", i);
String string = text.toString();
try {
document.setText(this, string);
verifyLengths(document, string);
assertTrue("too few document regions [run value " + i + "] ", new CoreNodeList(document.getFirstStructuredDocumentRegion()).getLength() == 3);
verifyLengths(document, string);
IStructuredDocumentRegion startTag = document.getFirstStructuredDocumentRegion();
IStructuredDocumentRegion middleBlock = startTag.getNext();
// IStructuredDocumentRegion endTag = middleBlock.getNext();
assertTrue("not block text in middle", middleBlock.getFirstRegion().getType() == DOMRegionContext.BLOCK_TEXT);
} catch (Exception e) {
assertNull("exception caught" + e, e);
}
// System.gc();
}
}
use of org.eclipse.wst.sse.core.internal.text.CoreNodeList in project webtools.sourceediting by eclipse.
the class JSPReParser method reparse.
/**
* The core reparsing method ... after the dirty start and dirty end have
* been calculated elsewhere. - this method overrides, does not extend
* super's method. changes/fixes to super may have to be made here as
* well.
*/
protected StructuredDocumentEvent reparse(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) {
StructuredDocumentEvent result = null;
int rescanStart = -1;
int rescanEnd = -1;
boolean firstTime = false;
boolean detectedBreakingChange = false;
//
// "save" the oldNodes (that may be replaced) in a list
CoreNodeList oldNodes = formOldNodes(dirtyStart, dirtyEnd);
if (containsBreakingChange(oldNodes) || isBreakingWithNestedTag(dirtyStart, dirtyEnd)) {
if (Debug.debugTaglibs)
// $NON-NLS-1$
System.out.println("reparse: is taglib or include");
detectedBreakingChange = true;
rescanStart = 0;
rescanEnd = fStructuredDocument.getLength() + fLengthDifference;
oldNodes = formOldNodes(fStructuredDocument.getFirstStructuredDocumentRegion(), fStructuredDocument.getLastStructuredDocumentRegion());
clearTaglibInfo();
} else if (dirtyStart == null || dirtyEnd == null) {
// dirtyStart or dirty end are null, then that means we didn't
// have a
// cached node, which means we have an empty document, so we
// just need to rescan the changes
rescanStart = 0;
rescanEnd = fChanges.length();
firstTime = true;
} else {
// set the start of the text to rescan
rescanStart = dirtyStart.getStart();
//
// set the end of the text to rescan
// notice we use the same rationale as for the rescanStart,
// with the added caveat that length has to be added to it,
// to compensate for the new text which has been added or deleted.
// If changes has zero length, then "length" will be negative,
// since
// we are deleting text. Otherwise, use the difference between
// what's selected to be replaced and the length of the new text.
rescanEnd = dirtyEnd.getEnd() + fLengthDifference;
}
// now that we have the old stuff "saved" away, update the document
// with the changes.
fStructuredDocument.updateDocumentData(fStart, fLengthToReplace, fChanges);
// ------------------ now the real work
result = core_reparse(rescanStart, rescanEnd, oldNodes, firstTime);
// everthing, so no need to do again.
if ((!detectedBreakingChange) && (containsBreakingChange(oldNodes))) {
clearTaglibInfo();
// reparse all
oldNodes = formOldNodes(fStructuredDocument.getFirstStructuredDocumentRegion(), fStructuredDocument.getLastStructuredDocumentRegion());
result = core_reparse(0, fStructuredDocument.getLength(), oldNodes, firstTime);
}
// some optimization they can do
return result;
}
Aggregations