Fixed bug #1404228: Crash on <?php // comment ?>
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / JavaUI.java
index 23ff50e..9d306a6 100644 (file)
@@ -13,11 +13,10 @@ package net.sourceforge.phpdt.ui;
 import net.sourceforge.phpdt.core.IBufferFactory;
 import net.sourceforge.phpdt.core.IJavaElement;
 import net.sourceforge.phpdt.core.IWorkingCopy;
+import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.JavaModelException;
-import net.sourceforge.phpeclipse.PHPCore;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
-import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
 
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.ISharedImages;
@@ -26,7 +25,7 @@ import org.eclipse.ui.internal.SharedImages;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 
 /**
- * Central access point for the Java UI plug-in (id <code>"org.eclipse.jdt.ui"</code>).
+ * Central access point for the Java UI plug-in (id <code>"net.sourceforge.phpdt.ui"</code>).
  * This class provides static methods for:
  * <ul>
  *  <li> creating various kinds of selection dialogs to present a collection
@@ -47,81 +46,81 @@ public final class JavaUI {
        }
        
        /**
-        * The id of the Java plugin (value <code>"org.eclipse.jdt.ui"</code>).
+        * The id of the Java plugin (value <code>"net.sourceforge.phpdt.ui"</code>).
         */     
-//     public static final String ID_PLUGIN= "org.eclipse.jdt.ui"; //$NON-NLS-1$
+//     public static final String ID_PLUGIN= "net.sourceforge.phpdt.ui"; //$NON-NLS-1$
        
        /**
         * The id of the Java perspective
-        * (value <code>"org.eclipse.jdt.ui.JavaPerspective"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.JavaPerspective"</code>).
         */     
-//     public static final String ID_PERSPECTIVE=              "org.eclipse.jdt.ui.JavaPerspective"; //$NON-NLS-1$
+ //    public static final String ID_PERSPECTIVE=              "net.sourceforge.phpdt.ui.JavaPerspective"; //$NON-NLS-1$
        
        /**
         * The id of the Java hierarchy perspective
-        * (value <code>"org.eclipse.jdt.ui.JavaHierarchyPerspective"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.JavaHierarchyPerspective"</code>).
         */     
-//     public static final String ID_HIERARCHYPERSPECTIVE= "org.eclipse.jdt.ui.JavaHierarchyPerspective"; //$NON-NLS-1$
+//     public static final String ID_HIERARCHYPERSPECTIVE= "net.sourceforge.phpdt.ui.JavaHierarchyPerspective"; //$NON-NLS-1$
 
        /**
         * The id of the Java action set
-        * (value <code>"org.eclipse.jdt.ui.JavaActionSet"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.JavaActionSet"</code>).
         */
-//     public static final String ID_ACTION_SET= "org.eclipse.jdt.ui.JavaActionSet"; //$NON-NLS-1$
+//     public static final String ID_ACTION_SET= "net.sourceforge.phpdt.ui.JavaActionSet"; //$NON-NLS-1$
 
        /**
         * The id of the Java Element Creation action set
-        * (value <code>"org.eclipse.jdt.ui.JavaElementCreationActionSet"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.JavaElementCreationActionSet"</code>).
         * 
         * @since 2.0
         */
-//     public static final String ID_ELEMENT_CREATION_ACTION_SET= "org.eclipse.jdt.ui.JavaElementCreationActionSet"; //$NON-NLS-1$
+//     public static final String ID_ELEMENT_CREATION_ACTION_SET= "net.sourceforge.phpdt.ui.JavaElementCreationActionSet"; //$NON-NLS-1$
        
        /**
         * The id of the Java Coding action set
-        * (value <code>"org.eclipse.jdt.ui.CodingActionSet"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.CodingActionSet"</code>).
         * 
         * @since 2.0
         */
-//     public static final String ID_CODING_ACTION_SET= "org.eclipse.jdt.ui.CodingActionSet"; //$NON-NLS-1$
+//     public static final String ID_CODING_ACTION_SET= "net.sourceforge.phpdt.ui.CodingActionSet"; //$NON-NLS-1$
 
        /**
         * The id of the Java action set for open actions
-        * (value <code>"org.eclipse.jdt.ui.A_OpenActionSet"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.A_OpenActionSet"</code>).
         * 
         * @since 2.0
         */
-//     public static final String ID_OPEN_ACTION_SET= "org.eclipse.jdt.ui.A_OpenActionSet"; //$NON-NLS-1$
+//     public static final String ID_OPEN_ACTION_SET= "net.sourceforge.phpdt.ui.A_OpenActionSet"; //$NON-NLS-1$
 
        /**
         * The id of the Java Search action set
-        * (value <code>org.eclipse.jdt.ui.SearchActionSet"</code>).
+        * (value <code>net.sourceforge.phpdt.ui.SearchActionSet"</code>).
         * 
         * @since 2.0
         */
-//     public static final String ID_SEARCH_ACTION_SET= "org.eclipse.jdt.ui.SearchActionSet"; //$NON-NLS-1$
+//     public static final String ID_SEARCH_ACTION_SET= "net.sourceforge.phpdt.ui.SearchActionSet"; //$NON-NLS-1$
        
        /**
         * The editor part id of the editor that presents Java compilation units
-        * (value <code>"org.eclipse.jdt.ui.CompilationUnitEditor"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.CompilationUnitEditor"</code>).
         */     
 //     public static final String ID_CU_EDITOR=                        "net.sourceforge.phpdt.ui.PHPUnitEditor"; //$NON-NLS-1$
        
        /**
         * The editor part id of the editor that presents Java binary class files
-        * (value <code>"org.eclipse.jdt.ui.ClassFileEditor"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.ClassFileEditor"</code>).
         */
-//     public static final String ID_CF_EDITOR=                        "org.eclipse.jdt.ui.ClassFileEditor"; //$NON-NLS-1$
+//     public static final String ID_CF_EDITOR=                        "net.sourceforge.phpdt.ui.ClassFileEditor"; //$NON-NLS-1$
        
        /**
         * The editor part id of the code snippet editor
-        * (value <code>"org.eclipse.jdt.ui.SnippetEditor"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.SnippetEditor"</code>).
         */
-//     public static final String ID_SNIPPET_EDITOR=           "org.eclipse.jdt.ui.SnippetEditor"; //$NON-NLS-1$
+//     public static final String ID_SNIPPET_EDITOR=           "net.sourceforge.phpdt.ui.SnippetEditor"; //$NON-NLS-1$
 
        /**
         * The view part id of the Packages view
-        * (value <code>"org.eclipse.jdt.ui.PackageExplorer"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.PackageExplorer"</code>).
         * <p>
         * When this id is used to access
         * a view part with <code>IWorkbenchPage.findView</code> or 
@@ -137,7 +136,7 @@ public final class JavaUI {
        
        /** 
         * The view part id of the type hierarchy part.
-        * (value <code>"org.eclipse.jdt.ui.TypeHierarchy"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.TypeHierarchy"</code>).
         * <p>
         * When this id is used to access
         * a view part with <code>IWorkbenchPage.findView</code> or 
@@ -149,47 +148,47 @@ public final class JavaUI {
         * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
         * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
         */ 
-//     public static final String ID_TYPE_HIERARCHY=           "org.eclipse.jdt.ui.TypeHierarchy"; //$NON-NLS-1$
+       public static final String ID_TYPE_HIERARCHY=           "net.sourceforge.phpdt.ui.TypeHierarchy"; //$NON-NLS-1$
 
        /**
         * The id of the Java Browsing Perspective
-        * (value <code>"org.eclipse.jdt.ui.JavaBrowsingPerspective"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.JavaBrowsingPerspective"</code>).
         * 
         * @since 2.0
         */
-//     public static String ID_BROWSING_PERSPECTIVE= "org.eclipse.jdt.ui.JavaBrowsingPerspective"; //$NON-NLS-1$
+//     public static String ID_BROWSING_PERSPECTIVE= "net.sourceforge.phpdt.ui.JavaBrowsingPerspective"; //$NON-NLS-1$
 
        /**
         * The view part id of the Java Browsing Projects view
-        * (value <code>"org.eclipse.jdt.ui.ProjectsView"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.ProjectsView"</code>).
         * 
         * @since 2.0
         */
-//     public static String ID_PROJECTS_VIEW= "org.eclipse.jdt.ui.ProjectsView"; //$NON-NLS-1$
+//     public static String ID_PROJECTS_VIEW= "net.sourceforge.phpdt.ui.ProjectsView"; //$NON-NLS-1$
 
        /**
         * The view part id of the Java Browsing Packages view
-        * (value <code>"org.eclipse.jdt.ui.PackagesView"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.PackagesView"</code>).
         * 
         * @since 2.0
         */
-//     public static String ID_PACKAGES_VIEW= "org.eclipse.jdt.ui.PackagesView"; //$NON-NLS-1$
+//     public static String ID_PACKAGES_VIEW= "net.sourceforge.phpdt.ui.PackagesView"; //$NON-NLS-1$
 
        /**
         * The view part id of the Java Browsing Types view
-        * (value <code>"org.eclipse.jdt.ui.TypesView"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.TypesView"</code>).
         * 
         * @since 2.0
         */
-//     public static String ID_TYPES_VIEW= "org.eclipse.jdt.ui.TypesView"; //$NON-NLS-1$
+//     public static String ID_TYPES_VIEW= "net.sourceforge.phpdt.ui.TypesView"; //$NON-NLS-1$
 
        /**
         * The view part id of the Java Browsing Members view
-        * (value <code>"org.eclipse.jdt.ui.MembersView"</code>).
+        * (value <code>"net.sourceforge.phpdt.ui.MembersView"</code>).
         * 
         * @since 2.0
         */
-//     public static String ID_MEMBERS_VIEW= "org.eclipse.jdt.ui.MembersView"; //$NON-NLS-1$
+//     public static String ID_MEMBERS_VIEW= "net.sourceforge.phpdt.ui.MembersView"; //$NON-NLS-1$
 
        /**
         * The class org.eclipse.debug.core.model.IProcess allows attaching
@@ -200,7 +199,7 @@ public final class JavaUI {
         * was launched with.
         * @deprecated
         */
-//     public final static String ATTR_CMDLINE= "org.eclipse.jdt.ui.launcher.cmdLine"; //$NON-NLS-1$
+//     public final static String ATTR_CMDLINE= "net.sourceforge.phpdt.ui.launcher.cmdLine"; //$NON-NLS-1$
 
        /**
         * Returns the shared images for the Java UI.
@@ -552,11 +551,11 @@ public final class JavaUI {
         * 
         * @return the list of shared working copies
         * 
-        * @see org.eclipse.jdt.core.JavaCore#getSharedWorkingCopies(org.eclipse.jdt.core.IBufferFactory)
+        * @see net.sourceforge.phpdt.core.JavaCore#getSharedWorkingCopies(net.sourceforge.phpdt.core.IBufferFactory)
         * @since 2.0
         */
        public static IWorkingCopy[] getSharedWorkingCopies() {
-               return PHPCore.getSharedWorkingCopies(getBufferFactory());
+               return JavaCore.getSharedWorkingCopies(getBufferFactory());
        }
        
        /**
@@ -583,22 +582,21 @@ public final class JavaUI {
 //             }
 //             return (IWorkingCopy[])result.toArray(new IWorkingCopy[result.size()]);
 //     }
-       
+        
        /**
         * Returns the BufferFactory for the Java UI plug-in.
         *
         * @return the BufferFactory for the Java UI plug-in
         * 
-        * @see org.eclipse.jdt.core.IBufferFactory
+        * @see net.sourceforge.phpdt.core.IBufferFactory
         * @since 2.0
+        * @deprecated {@link IBufferFactory} has been replaced by {@link net.sourceforge.phpdt.core.WorkingCopyOwner}.
+        * The Java UI plug-in uses the <i>primary working copy owner</i> that can be accessed with <code>null</code> in
+        * API's that require an owner
         */
        public static IBufferFactory getBufferFactory() {
-               PHPDocumentProvider provider= PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider();
-               if (provider != null)
-                       return provider.getBufferFactory();
-               return null;
+               return PHPeclipsePlugin.getDefault().getBufferFactory();
        }
-
        /**
         * Returns the DocumentProvider used for Java compilation units.
         *