1 package net.sourceforge.phpeclipse.phpeditor;
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. and others.
5 All rights reserved. This program and the accompanying materials
6 are made available under the terms of the Common Public License v1.0
7 which accompanies this distribution, and is available at
8 http://www.eclipse.org/legal/cpl-v10.html
11 IBM Corporation - Initial implementation
12 Klaus Hartlage - www.eclipseproject.de
13 **********************************************************************/
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.jface.text.IDocument;
17 import org.eclipse.jface.text.IDocumentPartitioner;
18 import org.eclipse.jface.text.rules.DefaultPartitioner;
19 import org.eclipse.jface.text.rules.RuleBasedPartitioner;
20 import org.eclipse.ui.editors.text.FileDocumentProvider;
21 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
24 * The JavaDocumentProvider provides the IDocuments used by java editors.
27 public class PHPDocumentProvider extends FileDocumentProvider {
29 // private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC, PHPPartitionScanner.JAVA_MULTILINE_COMMENT };
30 private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_MULTILINE_COMMENT };
32 private static PHPPartitionScanner fgScanner= null;
34 public PHPDocumentProvider() {
39 * Method declared on AbstractDocumentProvider
41 protected IDocument createDocument(Object element) throws CoreException {
42 IDocument document= super.createDocument(element);
43 if (document != null) {
44 IDocumentPartitioner partitioner= createJavaPartitioner();
45 document.setDocumentPartitioner(partitioner);
46 partitioner.connect(document);
52 * Return a partitioner for .java files.
54 private IDocumentPartitioner createJavaPartitioner() {
55 return new DefaultPartitioner(getPHPPartitionScanner(), TYPES);
59 * Return a scanner for creating java partitions.
61 private PHPPartitionScanner getPHPPartitionScanner() {
62 if (fgScanner == null)
63 fgScanner= new PHPPartitionScanner();