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 |
case ISaveContext.SNAPSHOT : |
3135 |
// remove variables that should not be saved |
3136 |
HashMap varsToSave = null; |
3137 |
Iterator iterator = JavaModelManager.this.variables.entrySet().iterator(); |
3138 |
IEclipsePreferences defaultPreferences = getDefaultPreferences(); |
3139 |
while (iterator.hasNext()) { |
3140 |
Map.Entry entry = (Map.Entry) iterator.next(); |
3141 |
String varName = (String) entry.getKey(); |
3142 |
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 |
3143 |
|| CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) { |
3144 |
|
3145 |
if (varsToSave == null) |
3146 |
varsToSave = new HashMap(JavaModelManager.this.variables); |
3147 |
varsToSave.remove(varName); |
3148 |
} |
3149 |
} |
3150 |
saveVariables(varsToSave != null ? varsToSave : JavaModelManager.this.variables); |
3151 |
|
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 |
|