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 |
|