The eclipse plugin development comes with XML text editor demo. It has such code
public XMLEditor() {
super();
colorManager = new ColorManager();
setSourceViewerConfiguration(new XMLConfiguration(colorManager));
setDocumentProvider(new XMLDocumentProvider());
}
I see that document Partitioner creates a scanner
public class XMLDocumentProvider extends FileDocumentProvider {
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = super.createDocument(element);
if (document != null) {
IDocumentPartitioner partitioner =
new FastPartitioner(
new XMLPartitionScanner(),
new String[] {
XMLPartitionScanner.XML_TAG,
XMLPartitionScanner.XML_COMMENT });
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
}
return document;
}
and configuration creates two others
protected XMLScanner getXMLScanner() {
if (scanner == null) {
scanner = new XMLScanner(colorManager);
scanner.setDefaultReturnToken(
new Token(
new TextAttribute(
colorManager.getColor(IXMLColorConstants.DEFAULT))));
}
return scanner;
}
protected XMLTagScanner getXMLTagScanner() {
if (tagScanner == null) {
tagScanner = new XMLTagScanner(colorManager);
tagScanner.setDefaultReturnToken(
new Token(
new TextAttribute(
colorManager.getColor(IXMLColorConstants.TAG))));
}
return tagScanner;
}
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new PresentationReconciler();
DefaultDamagerRepairer dr =
new DefaultDamagerRepairer(getXMLTagScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr = new DefaultDamagerRepairer(getXMLScanner());
reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
NonRuleBasedDamagerRepairer ndr =
new NonRuleBasedDamagerRepairer(
new TextAttribute(
colorManager.getColor(IXMLColorConstants.XML_COMMENT)));
reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
return reconciler;
}
in the reconciler. What is the difference between them? Why does this tutorial say in Partitioning section that there are 3 partition types, dftl_partition_content_type, xml_tag and xml_comment, based on the listing
Partition type: __xml_pi, offset: 0, length: 21
Text:
<?xml version="1.0"?>
---------------------------
Partition type: __dftl_partition_content_type, offset: 21, length: 2
Text:
---------------------------
Partition type: __xml_doctype, offset: 23, length: 36
Text:
<!DOCTYPE world SYSTEM "cities.dtd">
---------------------------
Partition type: __dftl_partition_content_type, offset: 59, length: 2
Text:
---------------------------
Partition type: __xml_start_tag, offset: 61, length: 7
Text:
<world>
---------------------------
Partition type: __dftl_partition_content_type, offset: 68, length: 5
Text:
---------------------------
Partition type: __xml_start_tag, offset: 73, length: 27
Text:
<continent name = "Africa">
---------------------------
Partition type: __dftl_partition_content_type, offset: 100, length: 4
Text:
--------------------------
Partition type: __xml_start_tag, offset: 104, length: 13
Text:
<description>
---------------------------
... rest of document until end ...
Partition type: __xml_end_tag, offset: 1301, length: 8
Text:
</world>
whereas I see xml_pi, xml_doctype, xml_start and end tags instead?
[Updated on: Wed, 12 March 2014 20:24]
Report message to a moderator