use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class StructuredDocumentWalker method getPrevNodeInCurrent.
/**
* Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes:
* ---[C1]-----[C2]-----[C3]-----[C4]---
*
* Input: O* -> Output: C1 Input: Cn -> Output: Cn-1
*/
public IStructuredDocumentRegion getPrevNodeInCurrent(IStructuredDocumentRegion node) {
IStructuredDocumentRegion prevNode = null;
if (isOldNode(node)) {
IStructuredDocumentRegion oldStartNode = fOldStructuredDocumentRegionList.item(0);
int newEnd = oldStartNode.getStart() - 1;
prevNode = fStructuredDocument.getRegionAtCharacterOffset(newEnd);
} else if (node != null) {
prevNode = node.getPrevious();
}
return prevNode;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class StructuredDocumentWalker method getNextNodeInCurrent.
/**
* Old Nodes: --[O1]--[O2]--[O3]--- : / \ Current Nodes:
* ---[C1]-----[C2]-----[C3]-----[C4]---
*
* Input: O* -> Output: C4 Input: Cn -> Output: Cn+1
*/
public IStructuredDocumentRegion getNextNodeInCurrent(IStructuredDocumentRegion node) {
IStructuredDocumentRegion nextNode = null;
if (isOldNode(node)) {
IStructuredDocumentRegion oldEndNode = fOldStructuredDocumentRegionList.item(fOldStructuredDocumentRegionList.getLength() - 1);
int newStart = oldEndNode.getEnd() + fLengthDifference;
nextNode = fStructuredDocument.getRegionAtCharacterOffset(newStart);
} else if (node != null) {
nextNode = node.getNext();
}
return nextNode;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSSourceParser method getRegions.
public List getRegions() {
IStructuredDocumentRegion headNode = null;
if (!getTokenizer().isEOF()) {
headNode = getDocumentRegions();
// throw new IllegalStateException("parsing has not finished");
}
// for memory recovery, we assume if someone
// requests all regions, we can reset our big
// memory consuming objects
// but the new "getRegions" method is then more expensive.
// I don't think its used much, though.
List localRegionsList = getRegions(headNode);
primReset();
return localRegionsList;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSSourceParser method getDocumentRegions.
public IStructuredDocumentRegion getDocumentRegions() {
IStructuredDocumentRegion headnode = null;
if (headnode == null) {
if (Debug.perfTest) {
fStartTime = System.currentTimeMillis();
}
headnode = parseNodes();
if (Debug.perfTest) {
fStopTime = System.currentTimeMillis();
// $NON-NLS-1$
System.out.println(" -- creating nodes of IStructuredDocument -- ");
// $NON-NLS-2$//$NON-NLS-1$
System.out.println(" Time parse and init all regions: " + (fStopTime - fStartTime) + " (msecs)");
// System.out.println(" for " + fRegions.size() + "
// Regions");//$NON-NLS-2$//$NON-NLS-1$
// $NON-NLS-2$//$NON-NLS-1$
System.out.println(" and " + _countNodes(headnode) + " Nodes");
}
}
return headnode;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSSourceParser method parseNodes.
private IStructuredDocumentRegion parseNodes() {
// regions are initially reported as complete offsets within the
// scanned input
// they are adjusted here to be indexes from the currentNode's start
// offset
IStructuredDocumentRegion headNode = null;
IStructuredDocumentRegion lastNode = null;
ITextRegion region = null;
IStructuredDocumentRegion currentNode = null;
String type = null;
String currentRegionType = null;
while ((region = getNextRegion()) != null) {
type = region.getType();
if (mustBeStart(type, currentRegionType) && currentNode != null) {
currentNode.setEnded(true);
}
if ((currentNode != null && currentNode.isEnded()) || currentNode == null) {
if (currentNode != null && !currentNode.isEnded()) {
currentNode.setEnded(true);
}
lastNode = currentNode;
currentNode = createStructuredDocumentRegion(type);
currentRegionType = type;
if (lastNode != null) {
lastNode.setNext(currentNode);
}
currentNode.setPrevious(lastNode);
currentNode.setStart(region.getStart());
}
currentNode.addRegion(region);
currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
region.adjustStart(-currentNode.getStart());
if (mustBeEnd(type)) {
currentNode.setEnded(true);
}
if (headNode == null && currentNode != null) {
headNode = currentNode;
}
}
if (currentNode != null && !currentNode.isEnded()) {
currentNode.setEnded(true);
}
primReset();
return headNode;
}
Aggregations