### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v retrieving revision 1.338.4.2 diff -u -r1.338.4.2 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 10 Jan 2007 03:11:30 -0000 1.338.4.2 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 28 Mar 2007 14:38:03 -0000 @@ -2869,14 +2869,14 @@ } } - private void saveVariablesAndContainers() throws CoreException { + private void saveVariablesAndContainers(ISaveContext context) throws CoreException { File file = getVariableAndContainersFile(); DataOutputStream out = null; try { out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); out.writeInt(VARIABLES_AND_CONTAINERS_FILE_VERSION); if (VARIABLES_AND_CONTAINERS_FILE_VERSION != 1) - new VariablesAndContainersSaveHelper(out).save(); + new VariablesAndContainersSaveHelper(out).save(context); else { // old code retained for performance comparisons @@ -2967,27 +2967,39 @@ this.stringIds = new HashtableOfObjectToInt(); } - void save() throws IOException, JavaModelException { - saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects()); - - // remove variables that should not be saved - HashMap varsToSave = null; - Iterator iterator = JavaModelManager.this.variables.entrySet().iterator(); - IEclipsePreferences defaultPreferences = getDefaultPreferences(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String varName = (String) entry.getKey(); - if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null // don't save classpath variables from the default preferences as there is no delta if they are removed - || CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) { - - if (varsToSave == null) - varsToSave = new HashMap(JavaModelManager.this.variables); - varsToSave.remove(varName); - } - + void save(ISaveContext context) throws IOException, JavaModelException { + IProject project = context.getProject(); + if (project == null) { // save all projects if none specified (snapshot or full save) + saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects()); + } + else { + saveProjects(new IJavaProject[] {JavaCore.create(project)}); } - saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables); + switch (context.getKind()) { + case ISaveContext.FULL_SAVE : + // TODO (eric) - investigate after 3.3 if variables should be saved for a SNAPSHOT + case ISaveContext.SNAPSHOT : + // remove variables that should not be saved + HashMap varsToSave = null; + Iterator iterator = JavaModelManager.this.variables.entrySet().iterator(); + IEclipsePreferences defaultPreferences = getDefaultPreferences(); + while (iterator.hasNext()) { + Map.Entry entry = (Map.Entry) iterator.next(); + String varName = (String) entry.getKey(); + if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null // don't save classpath variables from the default preferences as there is no delta if they are removed + || CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) { + + if (varsToSave == null) + varsToSave = new HashMap(JavaModelManager.this.variables); + varsToSave.remove(varName); + } + } + saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables); + break; + default : + // do nothing + } } private void saveAccessRule(ClasspathAccessRule rule) throws IOException { @@ -3168,11 +3180,13 @@ */ public void saving(ISaveContext context) throws CoreException { - // save variable and container values on snapshot/full save - long start = -1; + long start = -1; if (VERBOSE) start = System.currentTimeMillis(); - saveVariablesAndContainers(); + + // save variable and container values on snapshot/full save + saveVariablesAndContainers(context); + if (VERBOSE) traceVariableAndContainers("Saved", start); //$NON-NLS-1$