use of org.eclipse.jface.text.IDocumentPartitionerExtension2 in project webtools.sourceediting by eclipse.
the class BasicStructuredDocument method getPartition.
public ITypedRegion getPartition(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException {
if ((0 > offset) || (offset > getLength()))
throw new BadLocationException();
ITypedRegion result = null;
IDocumentPartitioner partitioner = getDocumentPartitioner(partitioning);
if (partitioner instanceof IDocumentPartitionerExtension2) {
result = ((IDocumentPartitionerExtension2) partitioner).getPartition(offset, preferOpenPartitions);
} else if (partitioner != null) {
result = partitioner.getPartition(offset);
} else if (IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING.equals(partitioning)) {
result = new TypedRegion(0, getLength(), DEFAULT_CONTENT_TYPE);
} else
throw new BadPartitioningException();
return result;
}
use of org.eclipse.jface.text.IDocumentPartitionerExtension2 in project tmdm-studio-se by Talend.
the class XMLTreeModel method createTree.
public void createTree(IDocument document) {
this.fireDocumentAboutToBeChanged(this.getTree());
IDocumentPartitioner partitioner = document.getDocumentPartitioner();
String[] categories = ((IDocumentPartitionerExtension2) partitioner).getManagingPositionCategories();
this.sourceViewer.getCodeTagContainersRegistry().clear();
for (int iCat = 0; iCat < categories.length; iCat++) {
String category = categories[iCat];
Position[] positions = null;
try {
positions = document.getPositions(category);
this.rootNode = new XMLRootNode(0, 0, IXMLPartitions.XML_TAG, document, sourceViewer);
ElementsToRelate.currentNode = this.rootNode;
ElementsToRelate.parentNode = null;
for (int j = 0; j < positions.length; j++) {
Position pos = positions[j];
ElementsToRelate.node = (XMLNode) pos;
ElementsToRelate.node.getChildren().clear();
ElementsToRelate.node.setCorrespondingNode(null);
ElementsToRelate.node.setSourceViewer(this.sourceViewer);
if (ElementsToRelate.currentNode != null && ElementsToRelate.currentNode.isTag()) {
String nodeType = ElementsToRelate.node.getType();
RelateElementsCommand command = this.commands.get(nodeType);
if (command != null) {
command.excecute(this.rootNode, this.sourceViewer.getCodeTagContainersRegistry());
}
}
}
} catch (BadPositionCategoryException e) {
e.printStackTrace();
}
}
this.fireDocumentChanged(this.getTree());
}
Aggregations