1 package $packageName$; 2 3 import org.eclipse.core.runtime.CoreException; 4 import org.eclipse.jface.text.IDocument; 5 import org.eclipse.jface.text.IDocumentPartitioner; 6 import org.eclipse.jface.text.rules.DefaultPartitioner; 7 import org.eclipse.ui.editors.text.FileDocumentProvider; 8 9 public class XMLDocumentProvider extends FileDocumentProvider { 10 11 protected IDocument createDocument(Object element) throws CoreException { 12 IDocument document = super.createDocument(element); 13 if (document != null) { 14 IDocumentPartitioner partitioner = 15 new DefaultPartitioner( 16 new XMLPartitionScanner(), 17 new String [] { 18 XMLPartitionScanner.XML_TAG, 19 XMLPartitionScanner.XML_COMMENT }); 20 partitioner.connect(document); 21 document.setDocumentPartitioner(partitioner); 22 } 23 return document; 24 } 25 } | Popular Tags |