use of com.intellij.debugger.impl.HotSwapProgress in project intellij by bazelbuild.
the class ClassFileManifestBuilder method buildManifest.
/**
* Builds a .class file manifest, then diffs against any previously calculated manifest for this
* debugging session.
*
* @return null if no diff is available (either no manifest could be calculated, or no previously
* calculated manifest is available.
*/
@Nullable
public static ClassFileManifest.Diff buildManifest(ExecutionEnvironment env, @Nullable HotSwapProgress progress) throws ExecutionException {
if (!HotSwapUtils.canHotSwap(env)) {
return null;
}
BlazeCommandRunConfiguration configuration = getConfiguration(env);
Project project = configuration.getProject();
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
throw new ExecutionException("Not synced yet; please sync project");
}
JavaClasspathAspectStrategy aspectStrategy = JavaClasspathAspectStrategy.findStrategy(projectData.blazeVersionData);
if (aspectStrategy == null) {
return null;
}
try (BuildResultHelper buildResultHelper = BuildResultHelper.forFiles(file -> true)) {
ListenableFuture<BuildResult> buildOperation = BlazeBeforeRunCommandHelper.runBlazeBuild(configuration, buildResultHelper, aspectStrategy.getBuildFlags(), ImmutableList.of(), "Building debug binary");
if (progress != null) {
progress.setCancelWorker(() -> buildOperation.cancel(true));
}
try {
SaveUtil.saveAllFiles();
BuildResult result = buildOperation.get();
if (result.status != BuildResult.Status.SUCCESS) {
throw new ExecutionException("Blaze failure building debug binary");
}
} catch (InterruptedException | CancellationException e) {
buildOperation.cancel(true);
throw new RunCanceledByUserException();
} catch (java.util.concurrent.ExecutionException e) {
throw new ExecutionException(e);
}
ImmutableList<File> jars = buildResultHelper.getArtifactsForOutputGroups(ImmutableSet.of(JavaClasspathAspectStrategy.OUTPUT_GROUP)).stream().filter(f -> f.getName().endsWith(".jar")).collect(toImmutableList());
ClassFileManifest oldManifest = getManifest(env);
ClassFileManifest newManifest = ClassFileManifest.build(jars, oldManifest);
env.getCopyableUserData(MANIFEST_KEY).set(newManifest);
return oldManifest != null ? ClassFileManifest.modifiedClasses(oldManifest, newManifest) : null;
}
}
Aggregations