Added first PHP parser version (doesn't work correct actually)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPEditorEnvironment.java
1 package net.sourceforge.phpeclipse.phpeditor;
2
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
9
10 Contributors:
11     IBM Corporation - Initial implementation
12     Klaus Hartlage - www.eclipseproject.de
13 **********************************************************************/
14
15 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
16 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
17 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
18 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
19 import org.eclipse.jface.text.rules.RuleBasedScanner;
20
21 /** The PHPEditorEnvironment maintains singletons used by the php editor
22  */
23 public class PHPEditorEnvironment {
24
25   private static PHPColorProvider fgColorProvider;
26   private static PHPCodeScanner fgCodeScanner;
27   private static HTMLCodeScanner fgHTMLCodeScanner;
28   //private static JavaDocScanner fgDocScanner;
29
30   private static int fgRefCount = 0;
31
32   /**
33    * A connection has occured - initialize the receiver if it is the first activation.
34    */
35   public static void connect(Object client) {
36     if (++fgRefCount == 1) {
37       fgColorProvider = new PHPColorProvider();
38       fgCodeScanner = new PHPCodeScanner(fgColorProvider);
39       fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider);
40       //                fgDocScanner= new JavaDocScanner(fgColorProvider);
41     }
42   }
43
44   /**
45    * A disconnection has occured - clear the receiver if it is the last deactivation.
46    */
47   public static void disconnect(Object client) {
48     if (--fgRefCount == 0) {
49       fgCodeScanner = null;
50       fgHTMLCodeScanner = null;
51       //                        fgDocScanner= null;
52       fgColorProvider.dispose();
53       fgColorProvider = null;
54     }
55   }
56
57   /**
58    * Returns the singleton scanner.
59    */
60   public static RuleBasedScanner getPHPCodeScanner() {
61     return fgCodeScanner;
62   }
63
64   public static RuleBasedScanner getHTMLCodeScanner() {
65     return fgHTMLCodeScanner;
66   }
67
68   /**
69    * Returns the singleton color provider.
70    */
71   public static PHPColorProvider getJavaColorProvider() {
72     return fgColorProvider;
73   }
74
75   /**
76    * Returns the singleton document scanner.
77    */
78   //     public static RuleBasedScanner getJavaDocScanner() {
79   //            return fgDocScanner;
80   //    }
81 }