initial import
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / editors / PHPDocumentProvider.java
1 package net.sourceforge.phpeclipse.editors;
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 PHPDocumentProvider extends FileDocumentProvider {
10
11         /**
12          * Constructor for XMLDocumentProvider.
13          */
14         public PHPDocumentProvider() {
15                 super();
16         }
17
18         /* (non-Javadoc)
19          * Method declared on AbstractDocumentProvider
20          */
21         protected IDocument createDocument(Object element) throws CoreException {
22                 IDocument document = super.createDocument(element);
23                 if (document != null) {
24                         IDocumentPartitioner partitioner =
25                                 new DefaultPartitioner(
26                                         new PHPPartitionScanner(),
27                                         new String[] {
28                                                 PHPPartitionScanner.HTML_TAG,
29                                                 PHPPartitionScanner.HTML_COMMENT });
30                         partitioner.connect(document);
31                         document.setDocumentPartitioner(partitioner);
32                 }
33                 return document;
34         }
35 }