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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-31 / +16 lines)
Lines 3965-4002 Link Here
3965
		}
3965
		}
3966
3966
3967
		void save(ISaveContext context) throws IOException, JavaModelException {
3967
		void save(ISaveContext context) throws IOException, JavaModelException {
3968
			IProject project = context.getProject();
3968
			saveProjects(getJavaModel().getJavaProjects());
3969
			if (project == null) { // save all projects if none specified (snapshot or full save)
3969
			// remove variables that should not be saved
3970
				saveProjects(getJavaModel().getJavaProjects());
3970
			HashMap varsToSave = null;
3971
			}
3971
			Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
3972
			else {
3972
			IEclipsePreferences defaultPreferences = getDefaultPreferences();
3973
				saveProjects(new IJavaProject[] {JavaCore.create(project)});
3973
			while (iterator.hasNext()) {
3974
			}
3974
				Map.Entry entry = (Map.Entry) iterator.next();
3975
3975
				String varName = (String) entry.getKey();
3976
			switch (context.getKind()) {
3976
				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
3977
				case ISaveContext.FULL_SAVE :
3977
						|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {
3978
					// TODO (eric) - investigate after 3.3 if variables should be saved for a SNAPSHOT
3978
3979
				case ISaveContext.SNAPSHOT :
3979
					if (varsToSave == null)
3980
					// remove variables that should not be saved
3980
						varsToSave = new HashMap(JavaModelManager.this.variables);
3981
					HashMap varsToSave = null;
3981
					varsToSave.remove(varName);
3982
					Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
3982
				}
3983
					IEclipsePreferences defaultPreferences = getDefaultPreferences();
3984
					while (iterator.hasNext()) {
3985
						Map.Entry entry = (Map.Entry) iterator.next();
3986
						String varName = (String) entry.getKey();
3987
						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
3988
								|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {
3989
3990
							if (varsToSave == null)
3991
								varsToSave = new HashMap(JavaModelManager.this.variables);
3992
							varsToSave.remove(varName);
3993
						}
3994
					}
3995
					saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables);
3996
					break;
3997
				default :
3998
					// do nothing
3999
			}
3983
			}
3984
			saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables);
4000
		}
3985
		}
4001
3986
4002
		private void saveAccessRule(ClasspathAccessRule rule) throws IOException {
3987
		private void saveAccessRule(ClasspathAccessRule rule) throws IOException {
(-)src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java (-1 / +32 lines)
Lines 77-83 Link Here
77
// All specified tests which do not belong to the class are skipped...
77
// All specified tests which do not belong to the class are skipped...
78
static {
78
static {
79
	// Names of tests to run: can be "testBugXXXX" or "BugXXXX")
79
	// Names of tests to run: can be "testBugXXXX" or "BugXXXX")
80
//		TESTS_NAMES = new String[] { "testContainerInitializer12" };
80
		TESTS_NAMES = new String[] { "testContainerInitializer26" };
81
	// Numbers of tests to run: "test<number>" will be run for each number of this array
81
	// Numbers of tests to run: "test<number>" will be run for each number of this array
82
//		TESTS_NUMBERS = new int[] { 2, 12 };
82
//		TESTS_NUMBERS = new int[] { 2, 12 };
83
	// Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last }
83
	// Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last }
Lines 1034-1039 Link Here
1034
	}
1034
	}
1035
}
1035
}
1036
1036
1037
1038
/*
1039
 * Ensures that the project references are updated on startup if the initializer gives a different value.
1040
 */
1041
public void testContainerInitializer26() throws CoreException {
1042
	try {
1043
		createProject("P1");
1044
		createFile("/P1/lib.jar", "");
1045
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1/lib.jar"}));
1046
		IJavaProject p2 = createJavaProject(
1047
				"P2",
1048
				new String[] {},
1049
				new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"},
1050
				"");
1051
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P2", "/P1"}));
1052
		
1053
		waitForAutoBuild();
1054
		getWorkspace().save(true/*full save*/, null/*no progress*/);		
1055
		p2.getProject().close(null); // close the project after the save and before the shutdown
1056
		JavaModelManager.getJavaModelManager().shutdown();
1057
		
1058
		startLogListening();
1059
		simulateRestart();
1060
		assertLogEquals(""); // there should be no log
1061
1062
	} finally {
1063
		stopLogListening();
1064
		deleteProject("P1");
1065
		deleteProject("P2");
1066
	}
1067
}
1037
public void testVariableInitializer01() throws CoreException {
1068
public void testVariableInitializer01() throws CoreException {
1038
	try {
1069
	try {
1039
		createProject("P1");
1070
		createProject("P1");

Return to bug 327471