1) Fixed issue #844: Short form of ternary operator (since PHP 5.3).
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / JavaCore.java
index 7e8a366..f2d1b6c 100644 (file)
@@ -14,23 +14,26 @@ import net.sourceforge.phpdt.internal.core.BufferManager;
 import net.sourceforge.phpdt.internal.core.ClasspathEntry;
 import net.sourceforge.phpdt.internal.core.JavaModel;
 import net.sourceforge.phpdt.internal.core.JavaModelManager;
-import net.sourceforge.phpdt.internal.core.Region;
+//import net.sourceforge.phpdt.internal.core.Region;
 import net.sourceforge.phpdt.internal.core.util.MementoTokenizer;
-import net.sourceforge.phpdt.internal.corext.Assert;
+//incastrix
+//import net.sourceforge.phpdt.internal.corext.Assert;
+import org.eclipse.core.runtime.Assert;
+
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
+//import org.eclipse.core.resources.IMarker;
+//import org.eclipse.core.resources.IMarkerDelta;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeListener;
+//import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
+//import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Plugin;
@@ -1611,13 +1614,13 @@ public class JavaCore {
         * @param element
         *            the Java element for which the marker needs to be configured
         */
-       public static void addJavaElementMarkerAttributes(Map attributes,
-                       IJavaElement element) {
-               // if (element instanceof IMember)
-               // element = ((IMember) element).getClassFile();
-               if (attributes != null && element != null)
-                       attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
-       }
+//     public static void addJavaElementMarkerAttributes(Map attributes,
+//                     IJavaElement element) {
+//             // if (element instanceof IMember)
+//             // element = ((IMember) element).getClassFile();
+//             if (attributes != null && element != null)
+//                     attributes.put(ATT_HANDLE_ID, element.getHandleIdentifier());
+//     }
 
        /**
         * Adds the given listener for POST_CHANGE resource change events to the
@@ -1633,11 +1636,11 @@ public class JavaCore {
         * @see #removePreProcessingResourceChangedListener(IResourceChangeListener)
         * @since 3.0
         */
-       public static void addPreProcessingResourceChangedListener(
-                       IResourceChangeListener listener) {
-               JavaModelManager.getJavaModelManager().deltaState
-                               .addPreResourceChangedListener(listener);
-       }
+//     public static void addPreProcessingResourceChangedListener(
+//                     IResourceChangeListener listener) {
+//             JavaModelManager.getJavaModelManager().deltaState
+//                             .addPreResourceChangedListener(listener);
+//     }
 
        /**
         * Configures the given marker for the given Java element. Used for markers,
@@ -1651,13 +1654,13 @@ public class JavaCore {
         *                if the <code>IMarker.setAttribute</code> on the marker
         *                fails
         */
-       public void configureJavaElementMarker(IMarker marker, IJavaElement element)
-                       throws CoreException {
-               // if (element instanceof IMember)
-               // element = ((IMember) element).getClassFile();
-               if (marker != null && element != null)
-                       marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
-       }
+//     public void configureJavaElementMarker(IMarker marker, IJavaElement element)
+//                     throws CoreException {
+//             // if (element instanceof IMember)
+//             // element = ((IMember) element).getClassFile();
+//             if (marker != null && element != null)
+//                     marker.setAttribute(ATT_HANDLE_ID, element.getHandleIdentifier());
+//     }
 
        /**
         * Returns the Java model element corresponding to the given handle
@@ -2135,43 +2138,43 @@ public class JavaCore {
         *         initializer or <code>null</code> if none was found.
         * @since 2.1
         */
-       public static ClasspathVariableInitializer getClasspathVariableInitializer(
-                       String variable) {
-
-               Plugin jdtCorePlugin = JavaCore.getPlugin();
-               if (jdtCorePlugin == null)
-                       return null;
-
-               // IExtensionPoint extension =
-               // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
-               // if (extension != null) {
-               // IExtension[] extensions = extension.getExtensions();
-               // for(int i = 0; i < extensions.length; i++){
-               // IConfigurationElement [] configElements =
-               // extensions[i].getConfigurationElements();
-               // for(int j = 0; j < configElements.length; j++){
-               // try {
-               // String varAttribute = configElements[j].getAttribute("variable");
-               // //$NON-NLS-1$
-               // if (variable.equals(varAttribute)) {
-               // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
-               // System.out.println("CPVariable INIT - found initializer: "+variable+"
-               // --> " +
-               // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
-               // }
-               // Object execExt =
-               // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
-               // if (execExt instanceof ClasspathVariableInitializer){
-               // return (ClasspathVariableInitializer)execExt;
-               // }
-               // }
-               // } catch(CoreException e){
-               // }
-               // }
-               // }
-               // }
-               return null;
-       }
+//     public static ClasspathVariableInitializer getClasspathVariableInitializer(
+//                     String variable) {
+//
+//             Plugin jdtCorePlugin = JavaCore.getPlugin();
+//             if (jdtCorePlugin == null)
+//                     return null;
+//
+//             // IExtensionPoint extension =
+//             // jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
+//             // if (extension != null) {
+//             // IExtension[] extensions = extension.getExtensions();
+//             // for(int i = 0; i < extensions.length; i++){
+//             // IConfigurationElement [] configElements =
+//             // extensions[i].getConfigurationElements();
+//             // for(int j = 0; j < configElements.length; j++){
+//             // try {
+//             // String varAttribute = configElements[j].getAttribute("variable");
+//             // //$NON-NLS-1$
+//             // if (variable.equals(varAttribute)) {
+//             // if (JavaModelManager.CP_RESOLVE_VERBOSE) {
+//             // System.out.println("CPVariable INIT - found initializer: "+variable+"
+//             // --> " +
+//             // configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+//             // }
+//             // Object execExt =
+//             // configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+//             // if (execExt instanceof ClasspathVariableInitializer){
+//             // return (ClasspathVariableInitializer)execExt;
+//             // }
+//             // }
+//             // } catch(CoreException e){
+//             // }
+//             // }
+//             // }
+//             // }
+//             return null;
+//     }
 
        /**
         * Returns the names of all known classpath variables.
@@ -2686,9 +2689,9 @@ public class JavaCore {
         * 
         * @return the single instance of the Java core plug-in runtime class
         */
-       public static PHPeclipsePlugin getJavaCore() {
-               return (PHPeclipsePlugin) getPlugin();
-       }
+//     public static PHPeclipsePlugin getJavaCore() {
+//             return (PHPeclipsePlugin) getPlugin();
+//     }
 
        /**
         * Helper method for returning one option value only. Equivalent to
@@ -2848,7 +2851,7 @@ public class JavaCore {
                if (target instanceof File) {
                        File externalFile = (File) target;
                        if (externalFile.isFile()) {
-                               String fileName = externalFile.getName().toLowerCase();
+                               //String fileName = externalFile.getName().toLowerCase();
                                // if (fileName.endsWith(".jar" //$NON-NLS-1$
                                // ) || fileName.endsWith(".zip" //$NON-NLS-1$
                                // )) { // external binary archive
@@ -3169,49 +3172,49 @@ public class JavaCore {
         *                if the <code>IMarker.getAttribute</code> on the marker
         *                fails
         */
-       public static boolean isReferencedBy(IJavaElement element, IMarker marker)
-                       throws CoreException {
-
-               // only match units or classfiles
-               if (element instanceof IMember) {
-                       IMember member = (IMember) element;
-                       if (member.isBinary()) {
-                               element = null; // member.getClassFile();
-                       } else {
-                               element = member.getCompilationUnit();
-                       }
-               }
-               if (element == null)
-                       return false;
-               if (marker == null)
-                       return false;
-
-               String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
-               if (markerHandleId == null)
-                       return false;
-
-               IJavaElement markerElement = JavaCore.create(markerHandleId);
-               // while (true){
-               if (element.equals(markerElement))
-                       return true; // external elements may still be equal with
-                                                       // different
-               // handleIDs.
-
-               // cycle through enclosing types in case marker is associated with a
-               // classfile (15568)
-               // if (markerElement instanceof IClassFile){
-               // IType enclosingType =
-               // ((IClassFile)markerElement).getType().getDeclaringType();
-               // if (enclosingType != null){
-               // markerElement = enclosingType.getClassFile(); // retry with immediate
-               // enclosing classfile
-               // continue;
-               // }
-               // }
-               // break;
-               // }
-               return false;
-       }
+//     public static boolean isReferencedBy(IJavaElement element, IMarker marker)
+//                     throws CoreException {
+//
+//             // only match units or classfiles
+//             if (element instanceof IMember) {
+//                     IMember member = (IMember) element;
+//                     if (member.isBinary()) {
+//                             element = null; // member.getClassFile();
+//                     } else {
+//                             element = member.getCompilationUnit();
+//                     }
+//             }
+//             if (element == null)
+//                     return false;
+//             if (marker == null)
+//                     return false;
+//
+//             String markerHandleId = (String) marker.getAttribute(ATT_HANDLE_ID);
+//             if (markerHandleId == null)
+//                     return false;
+//
+//             IJavaElement markerElement = JavaCore.create(markerHandleId);
+//             // while (true){
+//             if (element.equals(markerElement))
+//                     return true; // external elements may still be equal with
+//                                                     // different
+//             // handleIDs.
+//
+//             // cycle through enclosing types in case marker is associated with a
+//             // classfile (15568)
+//             // if (markerElement instanceof IClassFile){
+//             // IType enclosingType =
+//             // ((IClassFile)markerElement).getType().getDeclaringType();
+//             // if (enclosingType != null){
+//             // markerElement = enclosingType.getClassFile(); // retry with immediate
+//             // enclosing classfile
+//             // continue;
+//             // }
+//             // }
+//             // break;
+//             // }
+//             return false;
+//     }
 
        /**
         * Returns whether the given marker delta references the given Java element.
@@ -3227,50 +3230,50 @@ public class JavaCore {
         *                if the <code>IMarkerDelta.getAttribute</code> on the
         *                marker delta fails
         */
-       public static boolean isReferencedBy(IJavaElement element,
-                       IMarkerDelta markerDelta) throws CoreException {
-
-               // only match units or classfiles
-               if (element instanceof IMember) {
-                       IMember member = (IMember) element;
-                       if (member.isBinary()) {
-                               element = null; // member.getClassFile();
-                       } else {
-                               element = member.getCompilationUnit();
-                       }
-               }
-               if (element == null)
-                       return false;
-               if (markerDelta == null)
-                       return false;
-
-               String markerDeltarHandleId = (String) markerDelta
-                               .getAttribute(ATT_HANDLE_ID);
-               if (markerDeltarHandleId == null)
-                       return false;
-
-               IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
-               // while (true){
-               if (element.equals(markerElement))
-                       return true; // external elements may still be equal with
-                                                       // different
-               // handleIDs.
-
-               // cycle through enclosing types in case marker is associated with a
-               // classfile (15568)
-               // if (markerElement instanceof IClassFile){
-               // IType enclosingType =
-               // ((IClassFile)markerElement).getType().getDeclaringType();
-               // if (enclosingType != null){
-               // markerElement = enclosingType.getClassFile(); // retry with immediate
-               // enclosing classfile
-               // continue;
-               // }
-               // }
-               // break;
-               // }
-               return false;
-       }
+//     public static boolean isReferencedBy(IJavaElement element,
+//                     IMarkerDelta markerDelta) throws CoreException {
+//
+//             // only match units or classfiles
+//             if (element instanceof IMember) {
+//                     IMember member = (IMember) element;
+//                     if (member.isBinary()) {
+//                             element = null; // member.getClassFile();
+//                     } else {
+//                             element = member.getCompilationUnit();
+//                     }
+//             }
+//             if (element == null)
+//                     return false;
+//             if (markerDelta == null)
+//                     return false;
+//
+//             String markerDeltarHandleId = (String) markerDelta
+//                             .getAttribute(ATT_HANDLE_ID);
+//             if (markerDeltarHandleId == null)
+//                     return false;
+//
+//             IJavaElement markerElement = JavaCore.create(markerDeltarHandleId);
+//             // while (true){
+//             if (element.equals(markerElement))
+//                     return true; // external elements may still be equal with
+//                                                     // different
+//             // handleIDs.
+//
+//             // cycle through enclosing types in case marker is associated with a
+//             // classfile (15568)
+//             // if (markerElement instanceof IClassFile){
+//             // IType enclosingType =
+//             // ((IClassFile)markerElement).getType().getDeclaringType();
+//             // if (enclosingType != null){
+//             // markerElement = enclosingType.getClassFile(); // retry with immediate
+//             // enclosing classfile
+//             // continue;
+//             // }
+//             // }
+//             // break;
+//             // }
+//             return false;
+//     }
 
        /**
         * Creates and returns a new classpath entry of kind
@@ -3327,10 +3330,10 @@ public class JavaCore {
         * @see JavaCore#newContainerEntry(IPath, boolean)
         * @since 2.0
         */
-       public static IClasspathEntry newContainerEntry(IPath containerPath) {
-
-               return newContainerEntry(containerPath, false);
-       }
+//     public static IClasspathEntry newContainerEntry(IPath containerPath) {
+//
+//             return newContainerEntry(containerPath, false);
+//     }
 
        /**
         * Creates and returns a new classpath entry of kind
@@ -3542,9 +3545,9 @@ public class JavaCore {
         * 
         * @see JavaCore#newProjectEntry(IPath, boolean)
         */
-       public static IClasspathEntry newProjectEntry(IPath path) {
-               return newProjectEntry(path, false);
-       }
+//     public static IClasspathEntry newProjectEntry(IPath path) {
+//             return newProjectEntry(path, false);
+//     }
 
        /**
         * Creates and returns a new classpath entry of kind
@@ -3589,9 +3592,9 @@ public class JavaCore {
         * 
         * @return a new empty region
         */
-       public static IRegion newRegion() {
-               return new Region();
-       }
+//     public static IRegion newRegion() {
+//             return new Region();
+//     }
 
        /**
         * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
@@ -3640,12 +3643,12 @@ public class JavaCore {
         * @see #newSourceEntry(IPath, IPath[], IPath[], IPath)
         * @since 2.1
         */
-       public static IClasspathEntry newSourceEntry(IPath path,
-                       IPath[] exclusionPatterns) {
-
-               return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
-                               exclusionPatterns, null /* output location */);
-       }
+//     public static IClasspathEntry newSourceEntry(IPath path,
+//                     IPath[] exclusionPatterns) {
+//
+//             return newSourceEntry(path, ClasspathEntry.INCLUDE_ALL,
+//                             exclusionPatterns, null /* output location */);
+//     }
 
        /**
         * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
@@ -4273,9 +4276,9 @@ public class JavaCore {
         * (non-Javadoc) Method declared on IExecutableExtension. Record any
         * necessary initialization data from the plugin.
         */
-       public void setInitializationData(IConfigurationElement cfig,
-                       String propertyName, Object data) throws CoreException {
-       }
+//     public void setInitializationData(IConfigurationElement cfig,
+//                     String propertyName, Object data) throws CoreException {
+//     }
 
        /**
         * Sets the current table of options. All and only the options explicitly