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 3019-3032 Link Here
3019
		}
3019
		}
3020
	}
3020
	}
3021
	
3021
	
3022
	private void saveVariablesAndContainers() throws CoreException {
3022
	private void saveVariablesAndContainers(ISaveContext context) throws CoreException {
3023
		File file = getVariableAndContainersFile();
3023
		File file = getVariableAndContainersFile();
3024
		DataOutputStream out = null;
3024
		DataOutputStream out = null;
3025
		try {
3025
		try {
3026
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
3026
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
3027
			out.writeInt(VARIABLES_AND_CONTAINERS_FILE_VERSION);
3027
			out.writeInt(VARIABLES_AND_CONTAINERS_FILE_VERSION);
3028
			if (VARIABLES_AND_CONTAINERS_FILE_VERSION != 1)
3028
			if (VARIABLES_AND_CONTAINERS_FILE_VERSION != 1)
3029
				new VariablesAndContainersSaveHelper(out).save();
3029
				new VariablesAndContainersSaveHelper(out).save(context);
3030
			else {
3030
			else {
3031
				// old code retained for performance comparisons
3031
				// old code retained for performance comparisons
3032
    			
3032
    			
Lines 3120-3146 Link Here
3120
			this.stringIds = new HashtableOfObjectToInt();
3120
			this.stringIds = new HashtableOfObjectToInt();
3121
		}
3121
		}
3122
3122
3123
		void save() throws IOException, JavaModelException {
3123
		void save(ISaveContext context) throws IOException, JavaModelException {
3124
			saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects());
3124
			IProject project = context.getProject();
3125
			
3125
			if (project == null) { // save all projects if none specified (snapshot or full save)
3126
			// remove variables that should not be saved
3126
				saveProjects(JavaModelManager.this.getJavaModel().getJavaProjects());
3127
			HashMap varsToSave = null;
3127
			}
3128
			Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
3128
			else {
3129
			IEclipsePreferences defaultPreferences = getDefaultPreferences();
3129
				saveProjects(new IJavaProject[] {JavaCore.create(project)});
3130
			while (iterator.hasNext()) {
3131
				Map.Entry entry = (Map.Entry) iterator.next();
3132
				String varName = (String) entry.getKey();
3133
				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
3134
					|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {
3135
					
3136
					if (varsToSave == null)
3137
						varsToSave = new HashMap(JavaModelManager.this.variables);
3138
					varsToSave.remove(varName);
3139
				}
3140
					
3141
			}
3130
			}
3142
			
3131
			
3143
			saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables);
3132
			switch (context.getKind()) {
3133
				case ISaveContext.FULL_SAVE :
3134
					// TODO (eric) - investigate after 3.3 if variables should be saved for a SNAPSHOT
3135
				case ISaveContext.SNAPSHOT :
3136
					// remove variables that should not be saved
3137
					HashMap varsToSave = null;
3138
					Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
3139
					IEclipsePreferences defaultPreferences = getDefaultPreferences();
3140
					while (iterator.hasNext()) {
3141
						Map.Entry entry = (Map.Entry) iterator.next();
3142
						String varName = (String) entry.getKey();
3143
						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
3144
								|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {
3145
						
3146
							if (varsToSave == null)
3147
								varsToSave = new HashMap(JavaModelManager.this.variables);
3148
							varsToSave.remove(varName);
3149
						}
3150
					}				
3151
					saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables);
3152
					break;
3153
				default :
3154
					// do nothing
3155
			}
3144
		}
3156
		}
3145
3157
3146
		private void saveAccessRule(ClasspathAccessRule rule) throws IOException {
3158
		private void saveAccessRule(ClasspathAccessRule rule) throws IOException {
Lines 3321-3331 Link Here
3321
	 */
3333
	 */
3322
	public void saving(ISaveContext context) throws CoreException {
3334
	public void saving(ISaveContext context) throws CoreException {
3323
		
3335
		
3324
	    // save variable and container values on snapshot/full save
3336
	    long start = -1;
3325
		long start = -1;
3326
		if (VERBOSE)
3337
		if (VERBOSE)
3327
			start = System.currentTimeMillis();
3338
			start = System.currentTimeMillis();
3328
		saveVariablesAndContainers();
3339
3340
		// save variable and container values on snapshot/full save
3341
		saveVariablesAndContainers(context);
3342
3329
		if (VERBOSE)
3343
		if (VERBOSE)
3330
			traceVariableAndContainers("Saved", start); //$NON-NLS-1$
3344
			traceVariableAndContainers("Saved", start); //$NON-NLS-1$
3331
		
3345
		

Return to bug 174920