Lines 1188-1228
Link Here
|
1188 |
return buffer.toString(); |
1188 |
return buffer.toString(); |
1189 |
} |
1189 |
} |
1190 |
|
1190 |
|
1191 |
public boolean writeAndCacheClasspath(final JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException { |
1191 |
public boolean writeAndCacheClasspath(JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException { |
1192 |
final boolean[] result = new boolean[1]; |
|
|
1193 |
try { |
1192 |
try { |
1194 |
// use a workspace runnable so that the notification of .classpath file change is done outside the synchronized block (to avoid deadlocks) |
1193 |
this.writtingRawClasspath = true; |
1195 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
1194 |
// write .classpath |
1196 |
workspace.run(new IWorkspaceRunnable() { |
1195 |
if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) { |
1197 |
public void run(IProgressMonitor monitor) throws CoreException { |
1196 |
return false; |
1198 |
// ensure that the writing of the .classpath file and the caching in memory are synchronized (see also readAnCacheClasspath which is synchronized) |
1197 |
} |
1199 |
try { |
1198 |
// store new raw classpath, new output and new status, and null out resolved info |
1200 |
PerProjectInfo.this.writtingRawClasspath = true; |
1199 |
setClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null); |
1201 |
synchronized (PerProjectInfo.this) { |
1200 |
} finally { |
1202 |
if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) { |
1201 |
this.writtingRawClasspath = false; |
1203 |
result[0] = false; |
|
|
1204 |
return; |
1205 |
} |
1206 |
// store new raw classpath, new output and new status, and null out resolved info |
1207 |
setClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null); |
1208 |
result[0] = true; |
1209 |
} |
1210 |
} finally { |
1211 |
PerProjectInfo.this.writtingRawClasspath = false; |
1212 |
} |
1213 |
} |
1214 |
}, |
1215 |
workspace.getRuleFactory().modifyRule(this.project), // use project modification rule as this is needed to create the .classpath file if it doesn't exist yet |
1216 |
IWorkspace.AVOID_UPDATE, |
1217 |
null); |
1218 |
} catch (JavaModelException e) { |
1219 |
// rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 ) |
1220 |
throw e; |
1221 |
} catch (CoreException e) { |
1222 |
// rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 ) |
1223 |
throw new JavaModelException(e); |
1224 |
} |
1202 |
} |
1225 |
return result[0]; |
1203 |
return true; |
1226 |
} |
1204 |
} |
1227 |
} |
1205 |
} |
1228 |
|
1206 |
|