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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SetClasspathOperation.java (+18 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.core.resources.IResourceRuleFactory;
14
import org.eclipse.core.resources.ResourcesPlugin;
13
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.jobs.ISchedulingRule;
17
import org.eclipse.core.runtime.jobs.MultiRule;
14
import org.eclipse.jdt.core.IClasspathEntry;
18
import org.eclipse.jdt.core.IClasspathEntry;
15
import org.eclipse.jdt.core.IJavaElement;
19
import org.eclipse.jdt.core.IJavaElement;
16
import org.eclipse.jdt.core.IJavaModelStatus;
20
import org.eclipse.jdt.core.IJavaModelStatus;
Lines 64-69 Link Here
64
			done();
68
			done();
65
		}
69
		}
66
	}
70
	}
71
	
72
	protected ISchedulingRule getSchedulingRule() {
73
		if (this.canChangeResources) {
74
			IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
75
			return new MultiRule(new ISchedulingRule[] {
76
				// use project modification rule as this is needed to create the .classpath file if it doesn't exist yet, or to update project references
77
				ruleFactory.modifyRule(this.project.getProject()),
78
				
79
				// and external project modification rule in case the external folders are modified
80
				ruleFactory.modifyRule(JavaModelManager.getExternalManager().getExternalFoldersProject())
81
			});
82
		}
83
		return super.getSchedulingRule();
84
	}
67
85
68
	public String toString(){
86
	public String toString(){
69
		StringBuffer buffer = new StringBuffer(20);
87
		StringBuffer buffer = new StringBuffer(20);
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-33 / +11 lines)
Lines 1221-1261 Link Here
1221
			return buffer.toString();
1221
			return buffer.toString();
1222
		}
1222
		}
1223
1223
1224
		public boolean writeAndCacheClasspath(final JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException {
1224
		public boolean writeAndCacheClasspath(JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException {
1225
			final boolean[] result = new boolean[1];
1226
			try {
1225
			try {
1227
				// use a workspace runnable so that the notification of .classpath file change is done outside the synchronized block (to avoid deadlocks)
1226
				this.writtingRawClasspath = true;
1228
				IWorkspace workspace = 	ResourcesPlugin.getWorkspace();
1227
				// write .classpath
1229
				workspace.run(new IWorkspaceRunnable() {
1228
				if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) {
1230
					public void run(IProgressMonitor monitor) throws CoreException {
1229
					return false;
1231
						// ensure that the writing of the .classpath file and the caching in memory are synchronized (see also readAnCacheClasspath which is synchronized)
1230
				}
1232
						try {
1231
				// store new raw classpath, new output and new status, and null out resolved info
1233
							PerProjectInfo.this.writtingRawClasspath = true;
1232
				setRawClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK);
1234
							synchronized (PerProjectInfo.this) {
1233
			} finally {
1235
								if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) {
1234
				this.writtingRawClasspath = false;
1236
									result[0] = false;
1237
									return;
1238
								}
1239
								// store new raw classpath, new output and new status, and null out resolved info
1240
								setRawClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK);
1241
								result[0] = true;
1242
							}
1243
						} finally {
1244
							PerProjectInfo.this.writtingRawClasspath = false;
1245
						}
1246
					}
1247
				},
1248
				workspace.getRuleFactory().modifyRule(this.project), // use project modification rule as this is needed to create the .classpath file if it doesn't exist yet
1249
				IWorkspace.AVOID_UPDATE,
1250
				null);
1251
			} catch (JavaModelException e) {
1252
			    // rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
1253
				throw e;
1254
			} catch (CoreException e) {
1255
			    // rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
1256
				throw new JavaModelException(e);
1257
			}
1235
			}
1258
			return result[0];
1236
			return true;
1259
		}
1237
		}
1260
	}
1238
	}
1261
1239

Return to bug 249930