use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSModelCreationContext method setLast.
/**
*/
void setLast() {
fNextNode = null;
if (!(fRootNode instanceof CSSStructuredDocumentRegionContainer)) {
fTargetNode = fRootNode;
} else {
IStructuredDocumentRegion lastStructuredDocumentRegion = ((CSSStructuredDocumentRegionContainer) fRootNode).getLastStructuredDocumentRegion();
CSSNodeImpl node = fRootNode;
while (node != null) {
ICSSNode lastChild = node.getLastChild();
if (lastChild instanceof CSSStructuredDocumentRegionContainer && ((CSSStructuredDocumentRegionContainer) lastChild).getLastStructuredDocumentRegion() == lastStructuredDocumentRegion) {
node = (CSSNodeImpl) lastChild;
} else {
break;
}
}
fTargetNode = node;
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSModelImpl method regionsReplaced.
public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
if (structuredDocumentEvent == null)
return;
IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion();
if (flatNode == null)
return;
ITextRegionList oldRegions = structuredDocumentEvent.getOldRegions();
ITextRegionList newRegions = structuredDocumentEvent.getNewRegions();
if (oldRegions == null && newRegions == null)
return;
fStructuredDocumentUpdate = true;
CSSModelParser parser = getParser();
parser.setStructuredDocumentEvent(structuredDocumentEvent);
parser.replaceRegions(flatNode, newRegions, oldRegions);
fStructuredDocumentUpdate = false;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSModelImpl method regionChanged.
public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
if (structuredDocumentEvent == null) {
return;
}
IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion();
if (flatNode == null) {
return;
}
ITextRegion region = structuredDocumentEvent.getRegion();
if (region == null) {
return;
}
fStructuredDocumentUpdate = true;
CSSModelParser parser = getParser();
parser.setStructuredDocumentEvent(structuredDocumentEvent);
parser.changeRegion(flatNode, region);
fStructuredDocumentUpdate = false;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSModelDeletionContext method setupContext.
/**
*/
void setupContext(IStructuredDocumentRegionList newStructuredDocumentRegions, IStructuredDocumentRegionList oldStructuredDocumentRegions) {
IStructuredDocumentRegion flatNode = null;
fOldLength = CSSUtil.getTextLength(oldStructuredDocumentRegions);
if (oldStructuredDocumentRegions != null && 0 < oldStructuredDocumentRegions.getLength() && (flatNode = oldStructuredDocumentRegions.item(0)) != null) {
fOldStart = flatNode.getStart();
} else {
fOldStart = -1;
}
fNewLength = CSSUtil.getTextLength(newStructuredDocumentRegions);
if (newStructuredDocumentRegions != null && 0 < newStructuredDocumentRegions.getLength() && (flatNode = newStructuredDocumentRegions.item(0)) != null) {
fNewStart = flatNode.getStart();
fRemovedRangeBegin = fNewStart;
fRemovedRangeEnd = fNewStart + fNewLength;
} else {
fNewStart = -1;
fRemovedRangeBegin = fRemovedRangeEnd = -1;
}
fLengthDifference = fNewLength - fOldLength;
fOldRegionsList = new HashSet();
final Enumeration elements = oldStructuredDocumentRegions.elements();
while (elements.hasMoreElements()) {
fOldRegionsList.add(elements.nextElement());
}
// cleanup nodes
while (0 < fNodesToBeRemoved.getLength()) {
fNodesToBeRemoved.removeNode(0);
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion in project webtools.sourceediting by eclipse.
the class CSSModelDeletionContext method findDeletionTarget.
/**
*/
CSSStructuredDocumentRegionContainer findDeletionTarget(CSSNodeImpl parent, IStructuredDocumentRegion flatNode) {
CSSStructuredDocumentRegionContainer target = findContainer(parent, flatNode);
if (target == null) {
return null;
}
// System.out.print(flatNode.toString() + ": ");
// child a(=====)b(=====)c
// parent (================) a,c can remove parent, but b cannot.
ICSSNode child;
for (child = target.getFirstChild(); child != null && !(child instanceof CSSStructuredDocumentRegionContainer); child = child.getNextSibling()) {
// just advancing
}
if (child == null) {
// has no child containers.
return target;
} else {
IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) child).getFirstStructuredDocumentRegion();
if (flatNode.getStart() < getOriginalOffset(firstNode)) {
// a
return target;
}
}
for (child = target.getLastChild(); child != null && !(child instanceof CSSStructuredDocumentRegionContainer); child = child.getPreviousSibling()) {
// just advancing
}
if (child == null) {
// has no child containers.
return target;
} else {
IStructuredDocumentRegion firstNode = ((CSSStructuredDocumentRegionContainer) child).getFirstStructuredDocumentRegion();
if (getOriginalOffset(firstNode) < flatNode.getStart()) {
// c
return target;
}
}
// b
return null;
}
Aggregations