1 11 package org.eclipse.ant.internal.ui.editor.text; 12 13 import org.eclipse.jface.text.IDocument; 14 import org.eclipse.jface.text.IDocumentExtension3; 15 import org.eclipse.jface.text.IDocumentPartitioner; 16 import org.eclipse.jface.text.rules.FastPartitioner; 17 import org.eclipse.ui.editors.text.StorageDocumentProvider; 18 19 22 public class AntStorageDocumentProvider extends StorageDocumentProvider { 23 24 28 protected void setupDocument(Object element, IDocument document) { 29 if (document != null) { 30 IDocumentPartitioner partitioner= createDocumentPartitioner(); 31 if (document instanceof IDocumentExtension3) { 32 IDocumentExtension3 extension3= (IDocumentExtension3) document; 33 extension3.setDocumentPartitioner(AntDocumentSetupParticipant.ANT_PARTITIONING, partitioner); 34 } else { 35 document.setDocumentPartitioner(partitioner); 36 } 37 partitioner.connect(document); 38 } 39 } 40 41 private IDocumentPartitioner createDocumentPartitioner() { 42 return new FastPartitioner( 43 new AntEditorPartitionScanner(), new String []{ 44 AntEditorPartitionScanner.XML_TAG, 45 AntEditorPartitionScanner.XML_COMMENT, 46 AntEditorPartitionScanner.XML_CDATA, 47 AntEditorPartitionScanner.XML_DTD}); 48 } 49 } 50 | Popular Tags |