Search in sources :

Example 1 with ProjectTargetData

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);
    }
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) Instant(java.time.Instant) SyncStats(com.google.idea.blaze.base.logging.utils.SyncStats) ProjectTargetData(com.google.idea.blaze.base.model.ProjectTargetData) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) TimedEvent(com.google.idea.blaze.base.scope.scopes.TimingScopeListener.TimedEvent)

Example 2 with ProjectTargetData

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);
    }
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) SyncStats(com.google.idea.blaze.base.logging.utils.SyncStats) ProjectTargetData(com.google.idea.blaze.base.model.ProjectTargetData) TimedEvent(com.google.idea.blaze.base.scope.scopes.TimingScopeListener.TimedEvent) SyncFailedException(com.google.idea.blaze.base.sync.SyncScope.SyncFailedException)

Example 3 with ProjectTargetData

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);
}
Also used : ProjectTargetData(com.google.idea.blaze.base.model.ProjectTargetData) RemoteOutputArtifacts(com.google.idea.blaze.base.model.RemoteOutputArtifacts) Nullable(javax.annotation.Nullable)

Aggregations

ProjectTargetData (com.google.idea.blaze.base.model.ProjectTargetData)3 SyncStats (com.google.idea.blaze.base.logging.utils.SyncStats)2 TimingScope (com.google.idea.blaze.base.scope.scopes.TimingScope)2 TimedEvent (com.google.idea.blaze.base.scope.scopes.TimingScopeListener.TimedEvent)2 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)1 RemoteOutputArtifacts (com.google.idea.blaze.base.model.RemoteOutputArtifacts)1 SyncFailedException (com.google.idea.blaze.base.sync.SyncScope.SyncFailedException)1 Instant (java.time.Instant)1 Nullable (javax.annotation.Nullable)1