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 net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
16 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
17 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
18 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
20 /** The PHPEditorEnvironment maintains singletons used by the php editor
22 public class PHPEditorEnvironment {
24 private static PHPColorProvider fgColorProvider;
25 private static PHPCodeScanner fgPHPCodeScanner;
26 private static HTMLCodeScanner fgHTMLCodeScanner;
27 private static PHPDocCodeScanner fgDocScanner;
29 private static int fgRefCount = 0;
32 * A connection has occured - initialize the receiver if it is the first activation.
34 public static void connect(Object client) {
35 if (++fgRefCount == 1) {
36 fgColorProvider = new PHPColorProvider();
37 fgPHPCodeScanner = new PHPCodeScanner(fgColorProvider);
38 fgHTMLCodeScanner = new HTMLCodeScanner(fgColorProvider);
39 fgDocScanner = new PHPDocCodeScanner(fgColorProvider);
44 * A disconnection has occured - clear the receiver if it is the last deactivation.
46 public static void disconnect(Object client) {
47 if (--fgRefCount == 0) {
48 fgPHPCodeScanner = null;
49 fgHTMLCodeScanner = null;
51 fgColorProvider.dispose();
52 fgColorProvider = null;
57 * Returns the singleton scanner.
59 public static PHPCodeScanner getPHPCodeScanner() {
60 return fgPHPCodeScanner;
64 * Returns the singleton scanner.
66 public static HTMLCodeScanner getHTMLCodeScanner() {
67 return fgHTMLCodeScanner;
71 * Returns the singleton PHPDoc scanner.
73 public static PHPDocCodeScanner getPHPDocCodeScanner() {
78 * Returns the singleton color provider.
80 public static PHPColorProvider getPHPColorProvider() {
81 return fgColorProvider;