Improved "project.index" file for PHPdoc TextHover information
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPeclipsePlugin.java
1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
7
8 Contributors:
9     IBM Corporation - Initial implementation
10     Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse;
13
14 import java.io.File;
15 import java.util.Collection;
16 import java.util.HashMap;
17 import java.util.Iterator;
18
19 import net.sourceforge.phpdt.externaltools.internal.model.ColorManager;
20 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin;
21 import net.sourceforge.phpdt.externaltools.internal.model.VariableContextManager;
22 import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage;
23 import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry;
24 import net.sourceforge.phpdt.ui.PreferenceConstants;
25 import net.sourceforge.phpdt.ui.text.JavaTextTools;
26 import net.sourceforge.phpeclipse.builder.ExternalEditorInput;
27 import net.sourceforge.phpeclipse.builder.ExternalStorageDocumentProvider;
28 import net.sourceforge.phpeclipse.builder.FileStorage;
29 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
30 import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
31 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
32 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
33 import net.sourceforge.phpeclipse.resourcesview.PHPElement;
34 import net.sourceforge.phpeclipse.resourcesview.PHPElementAdapterFactory;
35 import net.sourceforge.phpeclipse.resourcesview.ResourceAdapterFactory;
36
37 import org.eclipse.core.boot.BootLoader;
38 import org.eclipse.core.resources.IFile;
39 import org.eclipse.core.resources.IProject;
40 import org.eclipse.core.resources.IResource;
41 import org.eclipse.core.resources.IWorkspace;
42 import org.eclipse.core.resources.ResourcesPlugin;
43 import org.eclipse.core.runtime.CoreException;
44 import org.eclipse.core.runtime.IAdapterManager;
45 import org.eclipse.core.runtime.IPath;
46 import org.eclipse.core.runtime.IPluginDescriptor;
47 import org.eclipse.core.runtime.IStatus;
48 import org.eclipse.core.runtime.Path;
49 import org.eclipse.core.runtime.Platform;
50 import org.eclipse.core.runtime.Status;
51 import org.eclipse.jface.preference.IPreferenceStore;
52 import org.eclipse.jface.preference.PreferenceConverter;
53 import org.eclipse.jface.text.BadLocationException;
54 import org.eclipse.jface.text.IDocument;
55 import org.eclipse.swt.widgets.Display;
56 import org.eclipse.swt.widgets.Shell;
57 import org.eclipse.ui.IEditorDescriptor;
58 import org.eclipse.ui.IEditorInput;
59 import org.eclipse.ui.IEditorPart;
60 import org.eclipse.ui.IEditorRegistry;
61 import org.eclipse.ui.IWorkbench;
62 import org.eclipse.ui.IWorkbenchPage;
63 import org.eclipse.ui.IWorkbenchWindow;
64 import org.eclipse.ui.PlatformUI;
65 import org.eclipse.ui.plugin.AbstractUIPlugin;
66 import org.eclipse.ui.texteditor.IDocumentProvider;
67 import org.eclipse.ui.texteditor.ITextEditor;
68
69 /**
70  * The main plugin class to be used in the desktop.
71  */
72 public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceConstants {
73   /**
74    * The id of the PHP plugin (value <code>"net.sourceforge.phpeclipse"</code>).
75    */
76   public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$
77
78   /** 
79    * id of builder - matches plugin.xml (concatenate pluginid.builderid) 
80    */
81   public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder";
82   public static final String BUILDER_PARSER_ID = PLUGIN_ID + ".parserbuilder";
83
84   /** General debug flag*/
85   public static final boolean DEBUG = false;
86
87   private static ExternalToolsPlugin externalTools;
88
89   /**
90   * The Java virtual machine that we are running on.
91   */
92   private static int jvm;
93
94   /** MRJ 2.0 */
95   private static final int MRJ_2_0 = 0;
96
97   /** MRJ 2.1 or later */
98   private static final int MRJ_2_1 = 1;
99
100   /** Java on Mac OS X 10.0 (MRJ 3.0) */
101   private static final int MRJ_3_0 = 3;
102
103   /** MRJ 3.1 */
104   private static final int MRJ_3_1 = 4;
105
106   /** JVM constant for any other platform */
107   private static final int OTHER = -1;
108
109   // public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID + ".resourcesview.ViewPHPResources"; //$NON-NLS-1$
110   public static final String PHP_CODING_ACTION_SET_ID = PLUGIN_ID + ".ui.CodingActionSet"; //$NON-NLS-1$
111   public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature";
112
113   public static final String PHPPARSER_ORIGINAL = "net.sourceforge.phpdt.internal.compiler.parser.Parser";
114
115   public static final String PHPPARSER_NEW = "test.PHPParser";
116
117   /** Change this if you want to switch PHP Parser. */
118   public static final String PHPPARSER = PHPPARSER_ORIGINAL;
119
120   //The shared instance.
121   private static PHPeclipsePlugin plugin;
122
123   /** Windows 9x  */
124   private static final int WINDOWS_9x = 6;
125
126   /** Windows NT  */
127   private static final int WINDOWS_NT = 5;
128   private PHPDocumentProvider fCompilationUnitDocumentProvider;
129   //Resource bundle.
130   //private ResourceBundle resourceBundle;
131
132   private ImageDescriptorRegistry fImageDescriptorRegistry;
133   private HashMap fIndexManagerMap = new HashMap();
134
135   private JavaTextTools fJavaTextTools;
136   private IFile fLastEditorFile = null;
137   /**
138    * The constructor.
139    */
140   public PHPeclipsePlugin(IPluginDescriptor descriptor) {
141     super(descriptor);
142     plugin = this;
143     setJVM();
144     externalTools = new ExternalToolsPlugin();
145     //    try {
146     //      resourceBundle = ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
147     //    } catch (MissingResourceException x) {
148     //      resourceBundle = null;
149     //    }
150   }
151
152   public static IWorkbenchPage getActivePage() {
153     return getDefault().internalGetActivePage();
154   }
155
156   public static Shell getActiveWorkbenchShell() {
157     return getActiveWorkbenchWindow().getShell();
158   }
159
160   public static IWorkbenchWindow getActiveWorkbenchWindow() {
161     return getDefault().getWorkbench().getActiveWorkbenchWindow();
162   }
163   /**
164    * Returns the shared instance.
165    */
166   public static PHPeclipsePlugin getDefault() {
167     return plugin;
168   }
169
170   public static ImageDescriptorRegistry getImageDescriptorRegistry() {
171     return getDefault().internalGetImageDescriptorRegistry();
172   }
173
174   static IPath getInstallLocation() {
175     return new Path(getDefault().getDescriptor().getInstallURL().getFile());
176   }
177   public static int getJVM() {
178     return jvm;
179   }
180
181   public static String getPluginId() {
182     return getDefault().getDescriptor().getUniqueIdentifier();
183   }
184
185   /**
186    * Returns the standard display to be used. The method first checks, if
187    * the thread calling this method has an associated display. If so, this
188    * display is returned. Otherwise the method returns the default display.
189    */
190   public static Display getStandardDisplay() {
191     Display display = Display.getCurrent();
192     if (display == null) {
193       display = Display.getDefault();
194     }
195     return display;
196   }
197
198   //  public static ExternalToolsPlugin getExternalTools() {
199   //    return externalTools;
200   //  }
201   /**
202    * Returns the workspace instance.
203    */
204   public static IWorkspace getWorkspace() {
205     return ResourcesPlugin.getWorkspace();
206   }
207
208   public static boolean isDebug() {
209     return getDefault().isDebugging();
210   }
211
212   //  public static void logErrorMessage(String message) {
213   //    log(new Status(IStatus.ERROR, getPluginId(), JavaStatusConstants.INTERNAL_ERROR, message, null));
214   //  }
215   //
216   //  public static void logErrorStatus(String message, IStatus status) {
217   //    if (status == null) {
218   //      logErrorMessage(message);
219   //      return;
220   //    }
221   //    MultiStatus multi= new MultiStatus(getPluginId(), JavaStatusConstants.INTERNAL_ERROR, message, null);
222   //    multi.add(status);
223   //    log(multi);
224   //  }
225   //
226   //  public static void log(Throwable e) {
227   //    log(new Status(IStatus.ERROR, getPluginId(), JavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$
228   //  }
229
230   public static void log(int severity, String message) {
231     Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null);
232     log(status);
233   }
234
235   public static void log(IStatus status) {
236     getDefault().getLog().log(status);
237   }
238   public static void log(Throwable e) {
239     log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
240   }
241
242   private static void setJVM() {
243     String osName = System.getProperty("os.name");
244
245     if (osName.startsWith("Mac OS")) {
246       String mrjVersion = System.getProperty("mrj.version");
247       String majorMRJVersion = mrjVersion.substring(0, 3);
248       jvm = OTHER;
249       try {
250
251         double version = Double.valueOf(majorMRJVersion).doubleValue();
252
253         if (version == 2) {
254           jvm = MRJ_2_0;
255         } else if (version >= 2.1 && version < 3) {
256           jvm = MRJ_2_1;
257         } else if (version == 3.0) {
258           jvm = MRJ_3_0;
259         } else if (version >= 3.1) {
260           jvm = MRJ_3_1;
261         }
262
263       } catch (NumberFormatException nfe) {
264
265       }
266
267     } else if (osName.startsWith("Windows")) {
268       if (osName.indexOf("9") != -1) {
269         jvm = WINDOWS_9x;
270       } else {
271         jvm = WINDOWS_NT;
272       }
273     }
274   }
275
276   // TODO: refactor this into a better method name !
277   public synchronized PHPDocumentProvider getCompilationUnitDocumentProvider() {
278     if (fCompilationUnitDocumentProvider == null)
279       fCompilationUnitDocumentProvider = new PHPDocumentProvider();
280     return fCompilationUnitDocumentProvider;
281   }
282
283   /**
284    * Get the identifier index manager for the given project
285    * 
286    * @param iProject the current project
287    * @return
288    */
289   public IdentifierIndexManager getIndexManager(IProject iProject) {
290     String indexFilename = iProject.getLocation() + File.separator + "project.index";
291     IdentifierIndexManager indexManager = (IdentifierIndexManager) fIndexManagerMap.get(indexFilename);
292     if (indexManager == null) {
293       indexManager = new IdentifierIndexManager(indexFilename);
294       fIndexManagerMap.put(indexFilename, indexManager);
295     }
296     return indexManager;
297   }
298
299   public synchronized JavaTextTools getJavaTextTools() {
300     if (fJavaTextTools == null)
301       fJavaTextTools = new JavaTextTools(getPreferenceStore());
302     return fJavaTextTools;
303   }
304
305   public IFile getLastEditorFile() {
306     return fLastEditorFile;
307   }
308
309   /**
310    * Returns the string from the plugin's resource bundle,
311    * or 'key' if not found.
312    */
313   //  public static String getResourceString(String key) {
314   //    ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle();
315   //    try {
316   //      return bundle.getString(key);
317   //    } catch (MissingResourceException e) {
318   //      return key;
319   //    }
320   //  }
321
322   /**
323    * Returns the plugin's resource bundle,
324    */
325   //  public ResourceBundle getResourceBundle() {
326   //    return resourceBundle;
327   //  }
328
329   protected void initializeDefaultPreferences(IPreferenceStore store) {
330     // windows preferences:
331     store.setDefault(LOCALHOST_PREF, "http://localhost");
332
333     store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true");
334     store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false");
335     store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true");
336
337     String windowsSystem = BootLoader.getWS();
338
339     if (jvm == WINDOWS_9x) {
340       store.setDefault(EXTERNAL_BROWSER_PREF, "command.com /c start iexplore {0}");
341     } else if (windowsSystem.equals(BootLoader.WS_WIN32)) {
342       store.setDefault(EXTERNAL_BROWSER_PREF, "rundll32 url.dll,FileProtocolHandler {0}");
343     } else if (windowsSystem.equals(BootLoader.WS_CARBON)) {
344       // TODO How do we start Safari on Mac OS X ?
345       store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}");
346     } else {
347       store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}");
348     }
349     store.setDefault(DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation().toString());
350
351     //  if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) {
352     //  
353     if (windowsSystem.equals(BootLoader.WS_WIN32)) {
354       store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe");
355       store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php -l -f {0}");
356       store.setDefault(MYSQL_RUN_PREF, "c:\\apache\\mysql\\bin\\mysqld-nt.exe");
357       store.setDefault(APACHE_RUN_PREF, "c:\\apache\\apache.exe");
358     } else {
359
360       store.setDefault(PHP_RUN_PREF, "/apache/php/php");
361       store.setDefault(EXTERNAL_PARSER_PREF, "/apache/php/php -l -f {0}");
362       store.setDefault(MYSQL_RUN_PREF, "/apache/mysql/bin/mysqld");
363       store.setDefault(APACHE_RUN_PREF, "/apache/apache");
364
365     }
366     store.setDefault(MYSQL_PREF, "--standalone");
367     store.setDefault(APACHE_START_PREF, "-c \"DocumentRoot \"{0}\"\"");
368     store.setDefault(APACHE_STOP_PREF, "-k shutdown");
369     store.setDefault(APACHE_RESTART_PREF, "-k restart");
370
371     store.setDefault(MYSQL_START_BACKGROUND, "true");
372     store.setDefault(APACHE_START_BACKGROUND, "true");
373     store.setDefault(APACHE_STOP_BACKGROUND, "true");
374     store.setDefault(APACHE_RESTART_BACKGROUND, "true");
375
376     store.setDefault(PHP_PARSER_DEFAULT, PHP_EXTERNAL_PARSER);
377     store.setDefault(PHP_INTERNAL_PARSER, "false");
378     store.setDefault(PHP_EXTERNAL_PARSER, "true");
379
380     //    store.setDefault(PHP_PARSE_ON_SAVE, "true");
381
382     // show line numbers:
383     //   store.setDefault(LINE_NUMBER_RULER, "false");
384     //    store.setDefault(FORMATTER_TAB_SIZE, "4");
385
386     // php syntax highlighting
387     store.setDefault(PHP_USERDEF_XMLFILE, "");
388     //assume there is none  chooA
389
390     PreferenceConverter.setDefault(store, PHP_MULTILINE_COMMENT, PHPColorProvider.MULTI_LINE_COMMENT);
391     PreferenceConverter.setDefault(store, PHP_SINGLELINE_COMMENT, PHPColorProvider.SINGLE_LINE_COMMENT);
392     PreferenceConverter.setDefault(store, PHP_KEYWORD, PHPColorProvider.KEYWORD);
393     PreferenceConverter.setDefault(store, PHP_VARIABLE, PHPColorProvider.VARIABLE);
394     PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME, PHPColorProvider.FUNCTION_NAME);
395     PreferenceConverter.setDefault(store, PHP_CONSTANT, PHPColorProvider.CONSTANT);
396     PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
397     PreferenceConverter.setDefault(store, PHP_STRING, PHPColorProvider.STRING);
398     PreferenceConverter.setDefault(store, PHP_DEFAULT, PHPColorProvider.DEFAULT);
399     //    PreferenceConverter.setDefault(
400     //      store,
401     //      PHP_EDITOR_BACKGROUND,
402     //      PHPColorProvider.BACKGROUND);
403     //    PreferenceConverter.setDefault(
404     //      store,
405     //      LINKED_POSITION_COLOR,
406     //      PHPColorProvider.LINKED_POSITION_COLOR);
407     //    PreferenceConverter.setDefault(
408     //      store,
409     //      LINE_NUMBER_COLOR,
410     //      PHPColorProvider.LINE_NUMBER_COLOR);
411
412     //    // set default PHPDoc colors:
413     //    PreferenceConverter.setDefault(
414     //      store,
415     //      PHPDOC_KEYWORD, 
416     //      PHPColorProvider.PHPDOC_KEYWORD);
417     //    PreferenceConverter.setDefault(
418     //      store,
419     //      PHPDOC_LINK, 
420     //      PHPColorProvider.PHPDOC_LINK);      
421     //    PreferenceConverter.setDefault(
422     //      store,
423     //      PHPDOC_DEFAULT, 
424     //      PHPColorProvider.PHPDOC_DEFAULT);
425     //    PreferenceConverter.setDefault(
426     //      store,
427     //      PHPDOC_TAG, 
428     //      PHPColorProvider.PHPDOC_TAG);
429
430     //    store.setDefault(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, "true");
431     //    PreferenceConverter.setDefault(
432     //      store,
433     //      PREFERENCE_COLOR_BACKGROUND,
434     //      PHPColorProvider.BACKGROUND_COLOR);
435
436     //language stuff
437     store.setDefault(RESOURCE_BUNDLE, LANGUAGE_DEFAULT);
438     store.setDefault(RESOURCE_BUNDLE_EN_GB, "true");
439     store.setDefault(RESOURCE_BUNDLE_DE, "false");
440     store.setDefault(RESOURCE_BUNDLE_FR, "false");
441     store.setDefault(RESOURCE_BUNDLE_ES, "false");
442
443     store.setDefault(PHP_OUTLINE_CLASS, "true"); //$NON-NLS-1$
444     store.setDefault(PHP_OUTLINE_FUNC, "true"); //$NON-NLS-1$
445     store.setDefault(PHP_OUTLINE_VAR, "true"); //$NON-NLS-1$
446
447     TemplatePreferencePage.initDefaults(store);
448     //this will initialize the static fields in the syntaxrdr class
449     new PHPSyntaxRdr();
450
451     PHPCore.initializeDefaultPluginPreferences();
452     PreferenceConstants.initializeDefaultValues(store);
453
454     externalTools.initializeDefaultPreferences(store);
455   }
456
457   private IWorkbenchPage internalGetActivePage() {
458     IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
459     if (window != null)
460       return window.getActivePage();
461     return null;
462   }
463
464   private ImageDescriptorRegistry internalGetImageDescriptorRegistry() {
465     if (fImageDescriptorRegistry == null)
466       fImageDescriptorRegistry = new ImageDescriptorRegistry();
467     return fImageDescriptorRegistry;
468   }
469   /**
470         * Open a file in the Workbench that may or may not exist in the workspace.
471         * Must be run on the UI thread.
472         * @param filename
473         * @throws CoreException
474         */
475   public ITextEditor openFileInTextEditor(String filename) throws CoreException {
476
477     //  reject directories
478     if (new File(filename).isDirectory())
479       return null;
480
481     IWorkbench workbench = PlatformUI.getWorkbench();
482     IWorkbenchWindow window = workbench.getWorkbenchWindows()[0];
483     IWorkbenchPage page = window.getActivePage();
484     IPath path = new Path(filename);
485
486     // If the file exists in the workspace, open it
487     IFile file = getWorkspace().getRoot().getFileForLocation(path);
488     IEditorPart editor;
489     ITextEditor textEditor;
490     if (file != null && file.exists()) {
491       editor = page.openEditor(file);
492       textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
493     } else {
494       // Otherwise open the stream directly
495       if (page == null)
496         return null;
497       FileStorage storage = new FileStorage(path);
498       IEditorRegistry registry = getWorkbench().getEditorRegistry();
499       IEditorDescriptor desc = registry.getDefaultEditor(filename);
500       if (desc == null) {
501         desc = registry.getDefaultEditor();
502       }
503       IEditorInput input = new ExternalEditorInput(storage);
504       editor = page.openEditor(input, desc.getId());
505       textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
506
507       // If the storage provider is not ours, we can't guarantee read/write.
508       if (textEditor != null) {
509         IDocumentProvider documentProvider = textEditor.getDocumentProvider();
510         if (!(documentProvider instanceof ExternalStorageDocumentProvider)) {
511           storage.setReadOnly();
512         }
513       }
514     }
515     return textEditor;
516   }
517   /**
518         * Open a file in the Workbench that may or may not exist in the workspace.
519         * Must be run on the UI thread.
520         * @param filename
521         * @param line
522         * @throws CoreException
523         */
524   public void openFileAndGotoLine(String filename, int line) throws CoreException {
525
526     ITextEditor textEditor = openFileInTextEditor(filename);
527     if (textEditor != null) {
528       // If a line number was given, go to it
529       if (line > 0) {
530         try {
531           line--; // document is 0 based
532           IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
533           textEditor.selectAndReveal(document.getLineOffset(line), document.getLineLength(line));
534
535         } catch (BadLocationException e) {
536           // invalid text position -> do nothing
537         }
538       }
539     }
540   }
541
542   /**
543         * Open a file in the Workbench that may or may not exist in the workspace.
544         * Must be run on the UI thread.
545         * @param filename
546         * @param offset
547         * @throws CoreException
548         */
549   public void openFileAndGotoOffset(String filename, int offset, int length) throws CoreException {
550
551     ITextEditor textEditor = openFileInTextEditor(filename);
552     if (textEditor != null) {
553       // If a line number was given, go to it
554       if (offset >= 0) {
555         IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
556         textEditor.selectAndReveal(offset, length);
557       }
558     }
559   }
560
561   public void openFileAndFindString(String filename, String findString) throws CoreException {
562
563     ITextEditor textEditor = openFileInTextEditor(filename);
564     if (textEditor != null) {
565       //                If a string was given, go to it
566       if (findString != null) {
567         try {
568           IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
569           int offset = document.search(0, findString, true, false, true);
570           textEditor.selectAndReveal(offset, findString.length());
571
572         } catch (BadLocationException e) {
573           // invalid text position -> do nothing
574         }
575
576       }
577     }
578   }
579   public void setLastEditorFile(IFile textEditor) {
580     this.fLastEditorFile = textEditor;
581   }
582
583   /**
584    * @see org.eclipse.ui.plugin.AbstractUIPlugin#shutdown()
585    */
586   public void shutdown() throws CoreException {
587     super.shutdown();
588
589     //  externalTools.shutDown();
590     ColorManager.getDefault().dispose();
591
592     // save the information from the php index files if necessary
593     Collection collection = fIndexManagerMap.values();
594     Iterator iterator = collection.iterator();
595     IdentifierIndexManager indexManager = null;
596     while (iterator.hasNext()) {
597       indexManager = (IdentifierIndexManager) iterator.next();
598       indexManager.writeFile();
599     }
600
601   }
602
603   public void startup() throws CoreException {
604     super.startup();
605     IAdapterManager manager = Platform.getAdapterManager();
606     manager.registerAdapters(new PHPElementAdapterFactory(), PHPElement.class);
607     manager.registerAdapters(new ResourceAdapterFactory(), IResource.class);
608     //  externalTools.startUp(); 
609     getStandardDisplay().asyncExec(new Runnable() {
610       public void run() {
611         //initialize the variable context manager
612         VariableContextManager.getDefault();
613       }
614     });
615   }
616
617 }