View | Details | Raw Unified | Return to bug 174920 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-24 / +38 lines)
Lines 2869-2882 Link Here
2869
		}
2869
		}
2870
	}
2870
	}
2871
	
2871
	
2872
	private void saveVariablesAndContainers() throws CoreException {
2872
	private void saveVariablesAndContainers(ISaveContext context) throws CoreException {
2873
		File file = getVariableAndContainersFile();
2873
		File file = getVariableAndContainersFile();
2874
		DataOutputStream out = null;
2874
		DataOutputStream out = null;
2875
		try {
2875
		try {
2876
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
2876
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
2877
			out.writeInt(VARIABLES_AND_CONTAINERS_FILE_VERSION);
2877
			out.writeInt(VARIABLES_AND_CONTAINERS_FILE_VERSION);
2878
			if (VARIABLES_AND_CONTAINERS_FILE_VERSION != 1)
2878
			if (VARIABLES_AND_CONTAINERS_FILE_VERSION != 1)
2879
				new VariablesAndContainersSaveHelper(out).save();
2879
				new VariablesAndContainersSaveHelper(out).save(context);
2880
			else {
2880
			else {
2881
				// old code retained for performance comparisons
2881
				// old code retained for performance comparisons
2882
			
2882
			
Lines 2967-2993 Link Here
2967
			this.stringIds = new HashtableOfObjectToInt();
2967
			this.stringIds = new HashtableOfObjectToInt();
2968
		}
2968
		}
2969
2969
2970
		void save() throws IOException, JavaModelException {
2970
		void save(ISaveContext context) throws IOException, JavaModelException {
2971
			saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects());
2971
			IProject project = context.getProject();
2972
			
2972
			if (project == null) { // save all projects if none specified (snapshot or full save)
2973
			// remove variables that should not be saved
2973
				saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects());
2974
			HashMap varsToSave = null;
2974
			}
2975
			Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
2975
			else {
2976
			IEclipsePreferences defaultPreferences = getDefaultPreferences();
2976
				saveProjects(new IJavaProject[] {JavaCore.create(project)});
2977
			while (iterator.hasNext()) {
2978
				Map.Entry entry = (Map.Entry) iterator.next();
2979
				String varName = (String) entry.getKey();
2980
				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
2981
					|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {
2982
					
2983
					if (varsToSave == null)
2984
						varsToSave = new HashMap(JavaModelManager.this.variables);
2985
					varsToSave.remove(varName);
2986
				}
2987
					
2988
			}
2977
			}
2989
			
2978
			
2990
			saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables);
2979
			switch (context.getKind()) {
2980
				case ISaveContext.FULL_SAVE :
2981
					// TODO (eric) - investigate after 3.3 if variables should be saved for a SNAPSHOT
2982
				case ISaveContext.SNAPSHOT :
2983
					// remove variables that should not be saved
2984
					HashMap varsToSave = null;
2985
					Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
2986
					IEclipsePreferences defaultPreferences = getDefaultPreferences();
2987
					while (iterator.hasNext()) {
2988
						Map.Entry entry = (Map.Entry) iterator.next();
2989
						String varName = (String) entry.getKey();
2990
						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
2991
								|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {
2992
						
2993
							if (varsToSave == null)
2994
								varsToSave = new HashMap(JavaModelManager.this.variables);
2995
							varsToSave.remove(varName);
2996
						}
2997
					}				
2998
					saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables);
2999
					break;
3000
				default :
3001
					// do nothing
3002
			}
2991
		}
3003
		}
2992
3004
2993
		private void saveAccessRule(ClasspathAccessRule rule) throws IOException {
3005
		private void saveAccessRule(ClasspathAccessRule rule) throws IOException {
Lines 3168-3178 Link Here
3168
	 */
3180
	 */
3169
	public void saving(ISaveContext context) throws CoreException {
3181
	public void saving(ISaveContext context) throws CoreException {
3170
		
3182
		
3171
	    // save variable and container values on snapshot/full save
3183
	    long start = -1;
3172
		long start = -1;
3173
		if (VERBOSE)
3184
		if (VERBOSE)
3174
			start = System.currentTimeMillis();
3185
			start = System.currentTimeMillis();
3175
		saveVariablesAndContainers();
3186
3187
		// save variable and container values on snapshot/full save
3188
		saveVariablesAndContainers(context);
3189
3176
		if (VERBOSE)
3190
		if (VERBOSE)
3177
			traceVariableAndContainers("Saved", start); //$NON-NLS-1$
3191
			traceVariableAndContainers("Saved", start); //$NON-NLS-1$
3178
		
3192
		

Return to bug 174920