use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion 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.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class StructuredDocumentReParser method findDirtyEnd.
protected IStructuredDocumentRegion findDirtyEnd(int end) {
// Caution: here's one place we have to cast
IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(end);
// if not well formed, get one past, if there is something there
if ((result != null) && (!result.isEnded())) {
if (result.getNext() != null) {
result = result.getNext();
}
}
// there's probably a better way.
if ((result != null) && (end == result.getEnd())) {
if (result.getNext() != null) {
result = result.getNext();
}
}
// }
if (result != null)
fStructuredDocument.setCachedDocumentRegion(result);
dirtyEnd = result;
return dirtyEnd;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class StructuredDocumentReParser method insertNodes.
protected void insertNodes(IStructuredDocumentRegion previousOldNode, IStructuredDocumentRegion nextOldNode, CoreNodeList newNodes) {
//
IStructuredDocumentRegion firstNew = null;
IStructuredDocumentRegion lastNew = null;
//
IStructuredDocumentRegion oldPrevious = previousOldNode;
IStructuredDocumentRegion oldNext = nextOldNode;
//
if (newNodes.getLength() > 0) {
// get pointers
firstNew = newNodes.item(0);
lastNew = newNodes.item(newNodes.getLength() - 1);
// lists
if (oldPrevious != null)
oldPrevious.setNext(firstNew);
if (oldNext != null) {
oldNext.setPrevious(lastNew);
} else {
// SIDE EFFECT
// if oldNext is null, that means we are replaceing the
// lastNode in the chain,
// so we need to update the structuredDocuments lastNode as
// the
// last of the new nodes.
fStructuredDocument.setLastDocumentRegion(newNodes.item(newNodes.getLength() - 1));
}
if (firstNew != null)
firstNew.setPrevious(oldPrevious);
if (lastNew != null)
lastNew.setNext(oldNext);
}
// else nothing to insert
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class StructuredDocumentReParser method findDirtyStart.
protected void findDirtyStart(int start) {
IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start);
// bracket should become part of the previous content node)
if (result != null) {
IStructuredDocumentRegion previous = result.getPrevious();
if ((previous != null) && ((!(previous.isEnded())) || (start == result.getStart()))) {
result = previous;
}
// If we are now at the end of a "tag dependent" content area (or
// JSP area)
// then we need to back up all the way to the beginning of that.
IStructuredDocumentRegion potential = result;
// }
if (potential != null) {
result = potential;
fStructuredDocument.setCachedDocumentRegion(result);
}
}
dirtyStart = result;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class StructuredDocumentReParser method quickCheck.
/**
* A method to allow any heuristic "quick checks" that might cover many
* many cases, before expending the time on a full reparse.
*/
public StructuredDocumentEvent quickCheck() {
StructuredDocumentEvent result = null;
// to handle, but only if there is one flatnode involved.
if (dirtyStart != null && dirtyStart == dirtyEnd) {
IStructuredDocumentRegion targetNode = dirtyStart;
result = dirtyStart.updateRegion(fRequester, targetNode, fChanges, fStart, fLengthToReplace);
if (result != null) {
// at this point only, we need to update the text store and
// and downstream nodes.
// FUTURE_TO_DO: can this dependency on structuredDocument
// method be eliminated?
fStructuredDocument.updateDocumentData(fStart, fLengthToReplace, fChanges);
IStructuredDocumentRegion firstDownStreamNode = targetNode.getNext();
// any downstream ones
if (firstDownStreamNode != null) {
StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
}
}
}
if (result != null) {
result.setDeletedText(fDeletedText);
}
return result;
}
Aggregations