X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java index fd46139..4d83115 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/JavaModelManager.java @@ -26,7 +26,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.WeakHashMap; -import java.util.zip.ZipFile; +//import java.util.zip.ZipFile; import net.sourceforge.phpdt.core.ElementChangedEvent; import net.sourceforge.phpdt.core.IClasspathEntry; @@ -57,10 +57,10 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ISaveContext; import org.eclipse.core.resources.ISaveParticipant; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; +//import org.eclipse.core.resources.IWorkspace; +//import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; +//import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -69,7 +69,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; +//import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; @@ -154,11 +154,11 @@ public class JavaModelManager implements ISaveParticipant { // public String toString() { return getDescription(); } // }; - private static final String INDEX_MANAGER_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/indexmanager"; //$NON-NLS-1$ +// private static final String INDEX_MANAGER_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/indexmanager"; //$NON-NLS-1$ - private static final String COMPILER_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/compiler"; //$NON-NLS-1$ +// private static final String COMPILER_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/compiler"; //$NON-NLS-1$ private static final String JAVAMODEL_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/javamodel"; //$NON-NLS-1$ @@ -172,8 +172,8 @@ public class JavaModelManager implements ISaveParticipant { private static final String DELTA_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/javadelta"; //$NON-NLS-1$ - private static final String HIERARCHY_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/hierarchy"; //$NON-NLS-1$ +// private static final String HIERARCHY_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/hierarchy"; //$NON-NLS-1$ private static final String POST_ACTION_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/postaction"; //$NON-NLS-1$ @@ -181,17 +181,17 @@ public class JavaModelManager implements ISaveParticipant { private static final String BUILDER_DEBUG = PHPeclipsePlugin.PLUGIN_ID + "/debug/builder"; //$NON-NLS-1$ - private static final String COMPLETION_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/completion"; //$NON-NLS-1$ +// private static final String COMPLETION_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/completion"; //$NON-NLS-1$ - private static final String SELECTION_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/selection"; //$NON-NLS-1$ - - private static final String SHARED_WC_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/sharedworkingcopy"; //$NON-NLS-1$ - - private static final String SEARCH_DEBUG = PHPeclipsePlugin.PLUGIN_ID - + "/debug/search"; //$NON-NLS-1$ +// private static final String SELECTION_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/selection"; //$NON-NLS-1$ +// +// private static final String SHARED_WC_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/sharedworkingcopy"; //$NON-NLS-1$ +// +// private static final String SEARCH_DEBUG = PHPeclipsePlugin.PLUGIN_ID +// + "/debug/search"; //$NON-NLS-1$ public final static IWorkingCopy[] NoWorkingCopy = new IWorkingCopy[0]; @@ -802,7 +802,7 @@ public class JavaModelManager implements ISaveParticipant { * to java.io.ZipFile) NOTE: this object itself is used as a lock to * synchronize creation/removal of entries */ - private HashMap zipFiles = new HashMap(); + //private HashMap zipFiles = new HashMap(); /** * Update the classpath variable cache @@ -848,11 +848,11 @@ public class JavaModelManager implements ISaveParticipant { /** * @deprecated - discard once debug has converted to not using it */ - public void addElementChangedListener(IElementChangedListener listener) { - this.addElementChangedListener(listener, - ElementChangedEvent.POST_CHANGE - | ElementChangedEvent.POST_RECONCILE); - } +// public void addElementChangedListener(IElementChangedListener listener) { +// this.addElementChangedListener(listener, +// ElementChangedEvent.POST_CHANGE +// | ElementChangedEvent.POST_RECONCILE); +// } /** * addElementChangedListener method comment. Need to clone defensively the @@ -902,32 +902,32 @@ public class JavaModelManager implements ISaveParticipant { /** * Starts caching ZipFiles. Ignores if there are already clients. */ - public void cacheZipFiles() { - synchronized (this.zipFiles) { - Thread currentThread = Thread.currentThread(); - if (this.zipFiles.get(currentThread) != null) - return; - this.zipFiles.put(currentThread, new HashMap()); - } - } - - public void closeZipFile(ZipFile zipFile) { - if (zipFile == null) - return; - synchronized (this.zipFiles) { - if (this.zipFiles.get(Thread.currentThread()) != null) { - return; // zip file will be closed by call to flushZipFiles - } - try { - if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out - .println("(" + Thread.currentThread() + ") [JavaModelManager.closeZipFile(ZipFile)] Closing ZipFile on " + zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ - } - zipFile.close(); - } catch (IOException e) { - } - } - } +// public void cacheZipFiles() { +// synchronized (this.zipFiles) { +// Thread currentThread = Thread.currentThread(); +// if (this.zipFiles.get(currentThread) != null) +// return; +// this.zipFiles.put(currentThread, new HashMap()); +// } +// } + +// public void closeZipFile(ZipFile zipFile) { +// if (zipFile == null) +// return; +// synchronized (this.zipFiles) { +// if (this.zipFiles.get(Thread.currentThread()) != null) { +// return; // zip file will be closed by call to flushZipFiles +// } +// try { +// if (JavaModelManager.ZIP_ACCESS_VERBOSE) { +// System.out +// .println("(" + Thread.currentThread() + ") [JavaModelManager.closeZipFile(ZipFile)] Closing ZipFile on " + zipFile.getName()); //$NON-NLS-1$ //$NON-NLS-2$ +// } +// zipFile.close(); +// } catch (IOException e) { +// } +// } +// } /** * Configure the plugin with respect to option settings defined in @@ -1221,26 +1221,26 @@ public class JavaModelManager implements ISaveParticipant { /** * Flushes ZipFiles cache if there are no more clients. */ - public void flushZipFiles() { - synchronized (this.zipFiles) { - Thread currentThread = Thread.currentThread(); - HashMap map = (HashMap) this.zipFiles.remove(currentThread); - if (map == null) - return; - Iterator iterator = map.values().iterator(); - while (iterator.hasNext()) { - try { - ZipFile zipFile = (ZipFile) iterator.next(); - if (JavaModelManager.ZIP_ACCESS_VERBOSE) { - System.out - .println("(" + currentThread + ") [JavaModelManager.flushZipFiles()] Closing ZipFile on " + zipFile.getName()); //$NON-NLS-1$//$NON-NLS-2$ - } - zipFile.close(); - } catch (IOException e) { - } - } - } - } +// public void flushZipFiles() { +// synchronized (this.zipFiles) { +// Thread currentThread = Thread.currentThread(); +// HashMap map = (HashMap) this.zipFiles.remove(currentThread); +// if (map == null) +// return; +// Iterator iterator = map.values().iterator(); +// while (iterator.hasNext()) { +// try { +// ZipFile zipFile = (ZipFile) iterator.next(); +// if (JavaModelManager.ZIP_ACCESS_VERBOSE) { +// System.out +// .println("(" + currentThread + ") [JavaModelManager.flushZipFiles()] Closing ZipFile on " + zipFile.getName()); //$NON-NLS-1$//$NON-NLS-2$ +// } +// zipFile.close(); +// } catch (IOException e) { +// } +// } +// } +// } public DeltaProcessor getDeltaProcessor() { return this.deltaState.getDeltaProcessor(); @@ -1445,31 +1445,31 @@ public class JavaModelManager implements ISaveParticipant { * Returns the name of the variables for which an CP variable initializer is * registered through an extension point */ - public static String[] getRegisteredVariableNames() { - - Plugin jdtCorePlugin = JavaCore.getPlugin(); - if (jdtCorePlugin == null) - return null; - - ArrayList variableList = new ArrayList(5); - // 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++){ - // String varAttribute = configElements[j].getAttribute("variable"); - // //$NON-NLS-1$ - // if (varAttribute != null) variableList.add(varAttribute); - // } - // } - // } - String[] variableNames = new String[variableList.size()]; - variableList.toArray(variableNames); - return variableNames; - } +// public static String[] getRegisteredVariableNames() { +// +// Plugin jdtCorePlugin = JavaCore.getPlugin(); +// if (jdtCorePlugin == null) +// return null; +// +// ArrayList variableList = new ArrayList(5); +// // 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++){ +// // String varAttribute = configElements[j].getAttribute("variable"); +// // //$NON-NLS-1$ +// // if (varAttribute != null) variableList.add(varAttribute); +// // } +// // } +// // } +// String[] variableNames = new String[variableList.size()]; +// variableList.toArray(variableNames); +// return variableNames; +// } /** * Returns the name of the container IDs for which an CP container @@ -1530,74 +1530,74 @@ public class JavaModelManager implements ISaveParticipant { * @exception CoreException * If unable to create/open the ZipFile */ - public ZipFile getZipFile(IPath path) throws CoreException { - - synchronized (this.zipFiles) { // TODO: use PeThreadObject which does - // synchronization - Thread currentThread = Thread.currentThread(); - HashMap map = null; - ZipFile zipFile; - if ((map = (HashMap) this.zipFiles.get(currentThread)) != null - && (zipFile = (ZipFile) map.get(path)) != null) { - - return zipFile; - } - String fileSystemPath = null; - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IResource file = root.findMember(path); - if (path.isAbsolute() && file != null) { - if (file == null) { // external file - fileSystemPath = path.toOSString(); - } else { // internal resource (not an IFile or not existing) - IPath location; - if (file.getType() != IResource.FILE - || (location = file.getFullPath()) == null) { - throw new CoreException( - new Status( - IStatus.ERROR, - JavaCore.PLUGIN_ID, - -1, - Util - .bind( - "file.notFound", path.toString()), null)); //$NON-NLS-1$ - } - fileSystemPath = location.toOSString(); - } - } else if (!path.isAbsolute()) { - file = root.getFile(path); - if (file == null || file.getType() != IResource.FILE) { - throw new CoreException(new Status(IStatus.ERROR, - JavaCore.PLUGIN_ID, -1, Util.bind( - "file.notFound", path.toString()), null)); //$NON-NLS-1$ - } - IPath location = file.getFullPath(); - if (location == null) { - throw new CoreException(new Status(IStatus.ERROR, - JavaCore.PLUGIN_ID, -1, Util.bind( - "file.notFound", path.toString()), null)); //$NON-NLS-1$ - } - fileSystemPath = location.toOSString(); - } else { - fileSystemPath = path.toOSString(); - } - - try { - if (ZIP_ACCESS_VERBOSE) { - System.out - .println("(" + currentThread + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + fileSystemPath); //$NON-NLS-1$ //$NON-NLS-2$ - } - zipFile = new ZipFile(fileSystemPath); - if (map != null) { - map.put(path, zipFile); - } - return zipFile; - } catch (IOException e) { - throw new CoreException(new Status(Status.ERROR, - JavaCore.PLUGIN_ID, -1, - Util.bind("status.IOException"), e)); //$NON-NLS-1$ - } - } - } +// public ZipFile getZipFile(IPath path) throws CoreException { +// +// synchronized (this.zipFiles) { // TODO: use PeThreadObject which does +// // synchronization +// Thread currentThread = Thread.currentThread(); +// HashMap map = null; +// ZipFile zipFile; +// if ((map = (HashMap) this.zipFiles.get(currentThread)) != null +// && (zipFile = (ZipFile) map.get(path)) != null) { +// +// return zipFile; +// } +// String fileSystemPath = null; +// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); +// IResource file = root.findMember(path); +// if (path.isAbsolute() && file != null) { +// if (file == null) { // external file +// fileSystemPath = path.toOSString(); +// } else { // internal resource (not an IFile or not existing) +// IPath location; +// if (file.getType() != IResource.FILE +// || (location = file.getFullPath()) == null) { +// throw new CoreException( +// new Status( +// IStatus.ERROR, +// JavaCore.PLUGIN_ID, +// -1, +// Util +// .bind( +// "file.notFound", path.toString()), null)); //$NON-NLS-1$ +// } +// fileSystemPath = location.toOSString(); +// } +// } else if (!path.isAbsolute()) { +// file = root.getFile(path); +// if (file == null || file.getType() != IResource.FILE) { +// throw new CoreException(new Status(IStatus.ERROR, +// JavaCore.PLUGIN_ID, -1, Util.bind( +// "file.notFound", path.toString()), null)); //$NON-NLS-1$ +// } +// IPath location = file.getFullPath(); +// if (location == null) { +// throw new CoreException(new Status(IStatus.ERROR, +// JavaCore.PLUGIN_ID, -1, Util.bind( +// "file.notFound", path.toString()), null)); //$NON-NLS-1$ +// } +// fileSystemPath = location.toOSString(); +// } else { +// fileSystemPath = path.toOSString(); +// } +// +// try { +// if (ZIP_ACCESS_VERBOSE) { +// System.out +// .println("(" + currentThread + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + fileSystemPath); //$NON-NLS-1$ //$NON-NLS-2$ +// } +// zipFile = new ZipFile(fileSystemPath); +// if (map != null) { +// map.put(path, zipFile); +// } +// return zipFile; +// } catch (IOException e) { +// throw new CoreException(new Status(Status.ERROR, +// JavaCore.PLUGIN_ID, -1, +// Util.bind("status.IOException"), e)); //$NON-NLS-1$ +// } +// } +// } /* * Returns whether there is a temporary cache for the current thread. @@ -1778,9 +1778,9 @@ public class JavaModelManager implements ISaveParticipant { public void prepareToSave(ISaveContext context) throws CoreException { } - protected void putInfo(IJavaElement element, Object info) { - this.cache.putInfo(element, info); - } +// protected void putInfo(IJavaElement element, Object info) { +// this.cache.putInfo(element, info); +// } /* * Puts the infos in the given map (keys are IJavaElements and values are @@ -2247,66 +2247,66 @@ public class JavaModelManager implements ISaveParticipant { * Record the order in which to build the java projects (batch build). This * order is based on the projects classpath settings. */ - protected void setBuildOrder(String[] javaBuildOrder) - throws JavaModelException { - - // optional behaviour - // possible value of index 0 is Compute - if (!JavaCore.COMPUTE.equals(JavaCore - .getOption(JavaCore.CORE_JAVA_BUILD_ORDER))) - return; // cannot be customized at project level - - if (javaBuildOrder == null || javaBuildOrder.length <= 1) - return; - - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceDescription description = workspace.getDescription(); - String[] wksBuildOrder = description.getBuildOrder(); - - String[] newOrder; - if (wksBuildOrder == null) { - newOrder = javaBuildOrder; - } else { - // remove projects which are already mentionned in java builder - // order - int javaCount = javaBuildOrder.length; - HashMap newSet = new HashMap(javaCount); // create a set for fast - // check - for (int i = 0; i < javaCount; i++) { - newSet.put(javaBuildOrder[i], javaBuildOrder[i]); - } - int removed = 0; - int oldCount = wksBuildOrder.length; - for (int i = 0; i < oldCount; i++) { - if (newSet.containsKey(wksBuildOrder[i])) { - wksBuildOrder[i] = null; - removed++; - } - } - // add Java ones first - newOrder = new String[oldCount - removed + javaCount]; - System.arraycopy(javaBuildOrder, 0, newOrder, 0, javaCount); // java - // projects - // are - // built - // first - - // copy previous items in their respective order - int index = javaCount; - for (int i = 0; i < oldCount; i++) { - if (wksBuildOrder[i] != null) { - newOrder[index++] = wksBuildOrder[i]; - } - } - } - // commit the new build order out - description.setBuildOrder(newOrder); - try { - workspace.setDescription(description); - } catch (CoreException e) { - throw new JavaModelException(e); - } - } +// protected void setBuildOrder(String[] javaBuildOrder) +// throws JavaModelException { +// +// // optional behaviour +// // possible value of index 0 is Compute +// if (!JavaCore.COMPUTE.equals(JavaCore +// .getOption(JavaCore.CORE_JAVA_BUILD_ORDER))) +// return; // cannot be customized at project level +// +// if (javaBuildOrder == null || javaBuildOrder.length <= 1) +// return; +// +// IWorkspace workspace = ResourcesPlugin.getWorkspace(); +// IWorkspaceDescription description = workspace.getDescription(); +// String[] wksBuildOrder = description.getBuildOrder(); +// +// String[] newOrder; +// if (wksBuildOrder == null) { +// newOrder = javaBuildOrder; +// } else { +// // remove projects which are already mentionned in java builder +// // order +// int javaCount = javaBuildOrder.length; +// HashMap newSet = new HashMap(javaCount); // create a set for fast +// // check +// for (int i = 0; i < javaCount; i++) { +// newSet.put(javaBuildOrder[i], javaBuildOrder[i]); +// } +// int removed = 0; +// int oldCount = wksBuildOrder.length; +// for (int i = 0; i < oldCount; i++) { +// if (newSet.containsKey(wksBuildOrder[i])) { +// wksBuildOrder[i] = null; +// removed++; +// } +// } +// // add Java ones first +// newOrder = new String[oldCount - removed + javaCount]; +// System.arraycopy(javaBuildOrder, 0, newOrder, 0, javaCount); // java +// // projects +// // are +// // built +// // first +// +// // copy previous items in their respective order +// int index = javaCount; +// for (int i = 0; i < oldCount; i++) { +// if (wksBuildOrder[i] != null) { +// newOrder[index++] = wksBuildOrder[i]; +// } +// } +// } +// // commit the new build order out +// description.setBuildOrder(newOrder); +// try { +// workspace.setDescription(description); +// } catch (CoreException e) { +// throw new JavaModelException(e); +// } +// } /** * Sets the last built state for the given project, or null to reset it. @@ -2350,17 +2350,17 @@ public class JavaModelManager implements ISaveParticipant { * Turns the firing mode to on. That is, deltas that are/have been * registered will be fired. */ - public void startDeltas() { - this.isFiring = true; - } +// public void startDeltas() { +// this.isFiring = true; +// } /** * Turns the firing mode to off. That is, deltas that are/have been * registered will not be fired until deltas are started again. */ - public void stopDeltas() { - this.isFiring = false; - } +// public void stopDeltas() { +// this.isFiring = false; +// } /** * Update Java Model given some delta @@ -2382,42 +2382,42 @@ public class JavaModelManager implements ISaveParticipant { return (IPath) Variables.get(variableName); } - public static String[] variableNames() { - int length = Variables.size(); - String[] result = new String[length]; - Iterator vars = Variables.keySet().iterator(); - int index = 0; - while (vars.hasNext()) { - result[index++] = (String) vars.next(); - } - return result; - } - - public static void variablePut(String variableName, IPath variablePath) { - - // update cache - do not only rely on listener refresh - if (variablePath == null) { - Variables.remove(variableName); - PreviousSessionVariables.remove(variableName); - } else { - Variables.put(variableName, variablePath); - } - - // do not write out intermediate initialization value - if (variablePath == JavaModelManager.VariableInitializationInProgress) { - return; - } - Preferences preferences = JavaCore.getPlugin().getPluginPreferences(); - String variableKey = CP_VARIABLE_PREFERENCES_PREFIX + variableName; - String variableString = variablePath == null ? CP_ENTRY_IGNORE - : variablePath.toString(); - preferences.setDefault(variableKey, CP_ENTRY_IGNORE); // use this - // default to - // get rid of - // removed ones - preferences.setValue(variableKey, variableString); - JavaCore.getPlugin().savePluginPreferences(); - } +// public static String[] variableNames() { +// int length = Variables.size(); +// String[] result = new String[length]; +// Iterator vars = Variables.keySet().iterator(); +// int index = 0; +// while (vars.hasNext()) { +// result[index++] = (String) vars.next(); +// } +// return result; +// } + +// public static void variablePut(String variableName, IPath variablePath) { +// +// // update cache - do not only rely on listener refresh +// if (variablePath == null) { +// Variables.remove(variableName); +// PreviousSessionVariables.remove(variableName); +// } else { +// Variables.put(variableName, variablePath); +// } +// +// // do not write out intermediate initialization value +// if (variablePath == JavaModelManager.VariableInitializationInProgress) { +// return; +// } +// Preferences preferences = JavaCore.getPlugin().getPluginPreferences(); +// String variableKey = CP_VARIABLE_PREFERENCES_PREFIX + variableName; +// String variableString = variablePath == null ? CP_ENTRY_IGNORE +// : variablePath.toString(); +// preferences.setDefault(variableKey, CP_ENTRY_IGNORE); // use this +// // default to +// // get rid of +// // removed ones +// preferences.setValue(variableKey, variableString); +// JavaCore.getPlugin().savePluginPreferences(); +// } /* * Returns all the working copies which have the given owner. Adds the