use of org.w3c.dom.ranges.Range in project webtools.sourceediting by eclipse.
the class TestRangeCompare method testRangeCompare.
public void testRangeCompare() throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
model.getStructuredDocument().set(decl);
Document document = model.getDocument();
// $NON-NLS-1$
Element root = document.createElement("parent");
document.appendChild(root);
// $NON-NLS-1$
Element child = document.createElement("child");
root.appendChild(child);
// $NON-NLS-1$
child.appendChild(document.createElement("child1-1"));
// $NON-NLS-1$
Text textnode = document.createTextNode("Text Node");
root.appendChild(textnode);
// $NON-NLS-1$
NodeList children = root.getElementsByTagName("child");
Range range = ((DocumentImpl) document).createRange();
range.setEnd(children.item(0), 1);
Range sourceRange = ((DocumentImpl) document).createRange();
sourceRange.setEnd(textnode, 0);
int result = range.compareBoundaryPoints(Range.END_TO_END, sourceRange);
assertEquals(-1, result);
}
Aggregations