use of com.google.idea.blaze.base.model.ProjectTargetData in project intellij by bazelbuild.
the class SyncPhaseCoordinator method doFilterProjectTargets.
private void doFilterProjectTargets(BlazeSyncParams params, Predicate<TargetKey> filter, BlazeContext context) {
Instant startTime = Instant.now();
SyncResult syncResult = SyncResult.FAILURE;
SyncStats.Builder stats = SyncStats.builder();
try {
SaveUtil.saveAllFiles();
onSyncStart(project, context, params.syncMode());
if (!context.shouldContinue()) {
return;
}
BlazeProjectData oldProjectData = getOldProjectData(context, params.syncMode());
if (oldProjectData == null) {
String message = "Can't filter project targets: project has never been synced.";
context.output(PrintOutput.error(message));
IssueOutput.warn(message).submit(context);
return;
}
List<TimedEvent> timedEvents = SyncScope.runWithTiming(context, childContext -> {
SyncProjectState projectState = ProjectStateSyncTask.collectProjectState(project, context);
if (projectState == null) {
return;
}
ProjectTargetData targetData = oldProjectData.getTargetData().filter(filter, projectState.getLanguageSettings());
fillInBuildStats(stats, projectState, /* buildResult= */
null);
ProjectUpdateSyncTask.runProjectUpdatePhase(project, params.syncMode(), projectState, targetData, childContext);
}, new TimingScope("Filtering project targets", EventType.Other));
stats.addTimedEvents(timedEvents);
syncResult = context.shouldContinue() ? SyncResult.SUCCESS : context.isCancelled() ? SyncResult.CANCELLED : SyncResult.FAILURE;
} catch (Throwable e) {
logSyncError(context, e);
} finally {
finishSync(params, startTime, context, ProjectViewManager.getInstance(project).getProjectViewSet(), ImmutableSet.of(), syncResult, stats);
}
}
use of com.google.idea.blaze.base.model.ProjectTargetData in project intellij by bazelbuild.
the class SyncPhaseCoordinator method updateProjectAndFinishSync.
private void updateProjectAndFinishSync(UpdatePhaseTask updateTask, BlazeContext context) {
SyncStats.Builder stats = SyncStats.builder();
SyncResult syncResult = updateTask.syncResult();
try {
fillInBuildStats(stats, updateTask.projectState(), updateTask.buildResult());
if (!syncResult.successful() || !updateTask.buildResult().isValid()) {
return;
}
List<TimedEvent> timedEvents = SyncScope.runWithTiming(context, childContext -> {
ProjectTargetData targetData = updateTargetData(updateTask, childContext);
if (targetData == null) {
childContext.setHasError();
throw new SyncFailedException();
}
ProjectUpdateSyncTask.runProjectUpdatePhase(project, updateTask.syncParams().syncMode(), updateTask.projectState(), targetData, childContext);
}, new TimingScope("Project update phase", EventType.Other));
stats.addTimedEvents(timedEvents);
if (!context.shouldContinue()) {
syncResult = context.isCancelled() ? SyncResult.CANCELLED : SyncResult.FAILURE;
}
} catch (Throwable e) {
logSyncError(context, e);
syncResult = SyncResult.FAILURE;
} finally {
SyncProjectState projectState = updateTask.projectState();
finishSync(updateTask.syncParams(), updateTask.startTime(), context, projectState != null ? projectState.getProjectViewSet() : null, updateTask.buildIds(), syncResult, stats);
}
}
use of com.google.idea.blaze.base.model.ProjectTargetData in project intellij by bazelbuild.
the class BlazeIdeInterfaceAspectsImpl method updateTargetData.
@Override
@Nullable
public ProjectTargetData updateTargetData(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, SyncProjectState projectState, BlazeBuildOutputs buildResult, boolean mergeWithOldState, @Nullable BlazeProjectData oldProjectData) {
TargetMapAndInterfaceState state = updateTargetMap(project, context, workspaceRoot, projectState, buildResult, mergeWithOldState, oldProjectData);
if (state == null) {
return null;
}
context.output(PrintOutput.log("Target map size: " + state.targetMap.targets().size()));
RemoteOutputArtifacts oldRemoteOutputs = RemoteOutputArtifacts.fromProjectData(oldProjectData);
// combine outputs map, then filter to remove out-of-date / unnecessary items
RemoteOutputArtifacts newRemoteOutputs = oldRemoteOutputs.appendNewOutputs(getTrackedOutputs(buildResult)).removeUntrackedOutputs(state.targetMap, projectState.getLanguageSettings());
return new ProjectTargetData(state.targetMap, state.state, newRemoteOutputs);
}
Aggregations