Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Why scanners in the SourceViewerConfiguration and DocumentProvider?
Why scanners in the SourceViewerConfiguration and DocumentProvider? [message #1270285] Wed, 12 March 2014 20:14 Go to next message
valentin Mising name is currently offline valentin Mising nameFriend
Messages: 38
Registered: December 2011
Member
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

Re: Why scanners in the SourceViewerConfiguration and DocumentProvider? [message #1699869 is a reply to message #1270285] Sun, 28 June 2015 07:13 Go to previous message
Peter Mising name is currently offline Peter Mising nameFriend
Messages: 1
Registered: July 2009
Junior Member
Its written in the Javadoc from the sources but you need the SDK installed who contains the ...-source.jar's.

You have not downloaded a EclipseSDK you can install it via "Help"->"Install new Software"->"The Eclipse project updates" ->"Eclipse SDK".

You do not need any kind of reconfiguration the project, the sources are available immedentely.

There is no big difference between the PartitionScanner and the Scanner. The Scanner can only Scan Partitions, so Partitions are scanned first.
Previous Topic:Trying to figure out how to set default includes for Eclipse CDT
Next Topic: Macbook air os x c++ installation and setup
Goto Forum:
  


Current Time: Fri Apr 26 10:07:27 GMT 2024

Powered by FUDForum. Page generated in 0.08684 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top