View | Details | Raw Unified | Return to bug 271102
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-2 / +1 lines)
Lines 1151-1158 Link Here
1151
		protected ClasspathChange addClasspathChange() {
1151
		protected ClasspathChange addClasspathChange() {
1152
			// remember old info
1152
			// remember old info
1153
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1153
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
1154
			DeltaProcessor deltaProcessor = manager.deltaState.getDeltaProcessor();
1154
			ClasspathChange classpathChange = manager.deltaState.addClasspathChange(this.project, this.rawClasspath, this.outputLocation, this.resolvedClasspath);
1155
			ClasspathChange classpathChange = deltaProcessor.addClasspathChange(this.project, this.rawClasspath, this.outputLocation, this.resolvedClasspath);
1156
			return classpathChange;
1155
			return classpathChange;
1157
		}
1156
		}
1158
1157
(-)model/org/eclipse/jdt/internal/core/DeltaProcessingState.java (+33 lines)
Lines 87-92 Link Here
87
	/* A table from file system absoulte path (String) to timestamp (Long) */
87
	/* A table from file system absoulte path (String) to timestamp (Long) */
88
	public Hashtable externalTimeStamps;
88
	public Hashtable externalTimeStamps;
89
89
90
	/*
91
	 * Map from IProject to ClasspathChange
92
	 * Note these changes need to be kept on the delta processing state to ensure we don't loose them
93
	 * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=271102 Java model corrupt after switching target platform)
94
	 */
95
	private HashMap classpathChanges = new HashMap();
96
90
	/* A table from JavaProject to ClasspathValidation */
97
	/* A table from JavaProject to ClasspathValidation */
91
	private HashMap classpathValidations = new HashMap();
98
	private HashMap classpathValidations = new HashMap();
92
99
Lines 171-176 Link Here
171
		return deltaProcessor;
178
		return deltaProcessor;
172
	}
179
	}
173
180
181
	public synchronized ClasspathChange addClasspathChange(IProject project, IClasspathEntry[] oldRawClasspath, IPath oldOutputLocation, IClasspathEntry[] oldResolvedClasspath) {
182
		ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project);
183
		if (change == null) {
184
			change = new ClasspathChange((JavaProject) JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(project), oldRawClasspath, oldOutputLocation, oldResolvedClasspath);
185
			this.classpathChanges.put(project, change);
186
		} else {
187
			if (change.oldRawClasspath == null)
188
				change.oldRawClasspath = oldRawClasspath;
189
			if (change.oldOutputLocation == null)
190
				change.oldOutputLocation = oldOutputLocation;
191
			if (change.oldResolvedClasspath == null)
192
				change.oldResolvedClasspath = oldResolvedClasspath;
193
		}
194
		return change;
195
	}
196
	
197
	public synchronized ClasspathChange getClasspathChange(IProject project) {
198
		return (ClasspathChange) this.classpathChanges.get(project);
199
	}
200
	
201
	public synchronized HashMap removeAllClasspathChanges() {
202
		HashMap result = this.classpathChanges;
203
		this.classpathChanges = new HashMap(result.size());
204
		return result;
205
	}
206
174
	public synchronized ClasspathValidation addClasspathValidation(JavaProject project) {
207
	public synchronized ClasspathValidation addClasspathValidation(JavaProject project) {
175
		ClasspathValidation validation = (ClasspathValidation) this.classpathValidations.get(project);
208
		ClasspathValidation validation = (ClasspathValidation) this.classpathValidations.get(project);
176
		if (validation == null) {
209
		if (validation == null) {
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-26 / +5 lines)
Lines 252-283 Link Here
252
	 */
252
	 */
253
	private SourceElementParser sourceElementParserCache;
253
	private SourceElementParser sourceElementParserCache;
254
254
255
	/*
256
	 * Map from IProject to ClasspathChange
257
	 */
258
	public HashMap classpathChanges = new HashMap();
259
260
	public DeltaProcessor(DeltaProcessingState state, JavaModelManager manager) {
255
	public DeltaProcessor(DeltaProcessingState state, JavaModelManager manager) {
261
		this.state = state;
256
		this.state = state;
262
		this.manager = manager;
257
		this.manager = manager;
263
	}
258
	}
264
259
265
	public ClasspathChange addClasspathChange(IProject project, IClasspathEntry[] oldRawClasspath, IPath oldOutputLocation, IClasspathEntry[] oldResolvedClasspath) {
266
		ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project);
267
		if (change == null) {
268
			change = new ClasspathChange((JavaProject) this.manager.getJavaModel().getJavaProject(project), oldRawClasspath, oldOutputLocation, oldResolvedClasspath);
269
			this.classpathChanges.put(project, change);
270
		} else {
271
			if (change.oldRawClasspath == null)
272
				change.oldRawClasspath = oldRawClasspath;
273
			if (change.oldOutputLocation == null)
274
				change.oldOutputLocation = oldOutputLocation;
275
			if (change.oldResolvedClasspath == null)
276
				change.oldResolvedClasspath = oldResolvedClasspath;
277
		}
278
		return change;
279
	}
280
281
	/*
260
	/*
282
	 * Adds the dependents of the given project to the list of the projects
261
	 * Adds the dependents of the given project to the list of the projects
283
	 * to update.
262
	 * to update.
Lines 487-498 Link Here
487
	}
466
	}
488
467
489
	private void checkExternalFolderChange(IProject project, JavaProject javaProject) {
468
	private void checkExternalFolderChange(IProject project, JavaProject javaProject) {
490
		ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project);
469
		ClasspathChange change = this.state.getClasspathChange(project);
491
		this.state.addExternalFolderChange(javaProject, change == null ? null : change.oldResolvedClasspath);
470
		this.state.addExternalFolderChange(javaProject, change == null ? null : change.oldResolvedClasspath);
492
	}
471
	}
493
472
494
	private void checkProjectReferenceChange(IProject project, JavaProject javaProject) {
473
	private void checkProjectReferenceChange(IProject project, JavaProject javaProject) {
495
		ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project);
474
		ClasspathChange change = this.state.getClasspathChange(project);
496
		this.state.addProjectReferenceChange(javaProject, change == null ? null : change.oldResolvedClasspath);
475
		this.state.addProjectReferenceChange(javaProject, change == null ? null : change.oldResolvedClasspath);
497
	}
476
	}
498
477
Lines 1927-1936 Link Here
1927
							}
1906
							}
1928
1907
1929
							// generate classpath change deltas
1908
							// generate classpath change deltas
1930
							if (this.classpathChanges.size() > 0) {
1909
							HashMap classpathChanges = this.state.removeAllClasspathChanges();
1910
							if (classpathChanges.size() > 0) {
1931
								boolean hasDelta = this.currentDelta != null;
1911
								boolean hasDelta = this.currentDelta != null;
1932
								JavaElementDelta javaDelta = currentDelta();
1912
								JavaElementDelta javaDelta = currentDelta();
1933
								Iterator changes = this.classpathChanges.values().iterator();
1913
								Iterator changes = classpathChanges.values().iterator();
1934
								while (changes.hasNext()) {
1914
								while (changes.hasNext()) {
1935
									ClasspathChange change = (ClasspathChange) changes.next();
1915
									ClasspathChange change = (ClasspathChange) changes.next();
1936
									int result = change.generateDelta(javaDelta);
1916
									int result = change.generateDelta(javaDelta);
Lines 1955-1961 Link Here
1955
								if (elementsToRefresh != null) {
1935
								if (elementsToRefresh != null) {
1956
									hasDelta |= createExternalArchiveDelta(elementsToRefresh, null);
1936
									hasDelta |= createExternalArchiveDelta(elementsToRefresh, null);
1957
								}
1937
								}
1958
								this.classpathChanges.clear();
1959
								if (!hasDelta)
1938
								if (!hasDelta)
1960
									this.currentDelta = null;
1939
									this.currentDelta = null;
1961
							}
1940
							}

Return to bug 271102