use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList 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.provisional.text.IStructuredDocumentRegionList in project webtools.sourceediting by eclipse.
the class CSSModelParser method insertStructuredDocumentRegions.
/**
*/
private void insertStructuredDocumentRegions(IStructuredDocumentRegionList regionList) {
for (Enumeration e = regionList.elements(); e.hasMoreElements(); ) {
IStructuredDocumentRegion region = (IStructuredDocumentRegion) e.nextElement();
if (region == null) {
continue;
}
insertStructuredDocumentRegion(region);
if (fCreationContext.isToReparse()) {
int origStart = region.getEnd();
int origEnd = regionList.item(regionList.getLength() - 1).getEnd();
int newStart = fCreationContext.getReparseStart();
int newEnd = fCreationContext.getReparseEnd();
if (newStart < origStart || origEnd < newEnd) {
IStructuredDocumentRegionList newNodeList = getStructuredDocumentRegionList(newStart, newEnd);
setupCreationContext(newNodeList.item(0));
insertStructuredDocumentRegions(newNodeList);
return;
} else {
fCreationContext.resetReparseRange();
}
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList in project webtools.sourceediting by eclipse.
the class StyleAttrAdapter method setValue.
/**
*/
private void setValue() {
Element element = getElement();
if (element == null)
return;
ICSSModel model = getExistingModel();
if (model == null)
return;
IStructuredDocument structuredDocument = model.getStructuredDocument();
if (structuredDocument == null)
return;
String value = null;
IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
if (flatNodes != null) {
int count = flatNodes.getLength();
if (count > 0) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < count; i++) {
IStructuredDocumentRegion flatNode = flatNodes.item(i);
if (flatNode == null)
continue;
buffer.append(flatNode.getText());
}
value = buffer.toString();
}
}
this.ignoreNotification = true;
if (value == null || value.length() == 0) {
element.removeAttribute(STYLE);
} else {
Attr attr = element.getAttributeNode(STYLE);
if (attr != null) {
((IDOMNode) attr).setValueSource(value);
} else {
Document document = element.getOwnerDocument();
attr = document.createAttribute(STYLE);
((IDOMNode) attr).setValueSource(value);
element.setAttributeNode(attr);
}
}
this.ignoreNotification = false;
notifyStyleChanged(element);
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList in project webtools.sourceediting by eclipse.
the class StructuredDocumentToTextAdapter method redrawNodesReplaced.
/**
* Request a redraw of the text range occupied by the given
* StructuredDocumentRegionsReplacedEvent
*
* @param structuredDocumentEvent
*/
protected void redrawNodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
if (isStoppedForwardingChanges())
return;
if (Debug.debugStructuredDocument) {
// $NON-NLS-1$
System.out.println("maybe redraw stuff");
}
// just the new stuff
IStructuredDocumentRegionList newStructuredDocumentRegions = structuredDocumentEvent.getNewStructuredDocumentRegions();
int nNewNodes = newStructuredDocumentRegions.getLength();
if (nNewNodes > 0) {
IStructuredDocumentRegion firstNode = newStructuredDocumentRegions.item(0);
IStructuredDocumentRegion lastNode = newStructuredDocumentRegions.item(nNewNodes - 1);
redrawRange(firstNode.getStartOffset(), lastNode.getEndOffset());
}
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList in project webtools.sourceediting by eclipse.
the class ScannerUnitTests method testNothinginBlockJSP9.
public void testNothinginBlockJSP9() {
String text = "<script>";
IStructuredDocumentRegionList nodes = setUpJSP(text);
boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 3 });
assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE });
assertTrue("region context type check", typeCheck);
verifyLengths(0, nodes.item(0), text);
}
Aggregations