Skip to content

Commit

Permalink
Fix code warnings in UiEventHandler.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 726514686
Change-Id: I401ca2d39056606d294bc02f09a96e3997bde21e
  • Loading branch information
justinhorvitz authored and copybara-github committed Feb 13, 2025
1 parent 6982c14 commit 9b211de
Showing 1 changed file with 16 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ public final class UiEventHandler implements EventHandler {
private final boolean showTimestamp;
private final OutErr outErr;
private final ImmutableSet<EventKind> filteredEventKinds;
private long progressRateLimitMillis;
private long minimalUpdateInterval;
private final long progressRateLimitMillis;
private final long minimalUpdateInterval;
private long lastRefreshMillis;
private long mustRefreshAfterMillis;
private boolean dateShown;
private int numLinesProgressBar;
private boolean buildRunning;
// Number of open build even protocol transports.
private boolean progressBarNeedsRefresh;
private volatile boolean shutdown;
private final AtomicReference<Thread> updateThread;
Expand Down Expand Up @@ -163,7 +162,7 @@ public void flush() throws IOException {
}
}

public UiEventHandler(
UiEventHandler(
OutErr outErr,
UiOptions options,
boolean quiet,
Expand Down Expand Up @@ -430,10 +429,7 @@ private void handleInternal(Event event) {
EventKind eventKind = event.getKind();
if (quiet) {
switch (eventKind) {
case ERROR -> {}
case FATAL -> {}
case STDOUT -> {}
case STDERR -> {}
case ERROR, FATAL, STDOUT, STDERR -> {}
default -> {
return;
}
Expand Down Expand Up @@ -525,27 +521,15 @@ private boolean writeToStream(OutputStream stream, EventKind eventKind, byte[] m

private void setEventKindColor(EventKind kind) throws IOException {
switch (kind) {
case FATAL:
case ERROR:
case FAIL:
case FATAL, ERROR, FAIL -> {
terminal.setTextColor(Color.RED);
terminal.textBold();
break;
case WARNING:
case CANCELLED:
terminal.setTextColor(Color.MAGENTA);
break;
case INFO:
terminal.setTextColor(Color.GREEN);
break;
case DEBUG:
terminal.setTextColor(Color.YELLOW);
break;
case SUBCOMMAND:
terminal.setTextColor(Color.BLUE);
break;
default:
terminal.resetTerminal();
}
case WARNING, CANCELLED -> terminal.setTextColor(Color.MAGENTA);
case INFO -> terminal.setTextColor(Color.GREEN);
case DEBUG -> terminal.setTextColor(Color.YELLOW);
case SUBCOMMAND -> terminal.setTextColor(Color.BLUE);
default -> terminal.resetTerminal();
}
}

Expand Down Expand Up @@ -600,7 +584,7 @@ public void loadingComplete(LoadingPhaseCompleteEvent event) {
@Subscribe
public synchronized void analysisComplete(AnalysisPhaseCompleteEvent event) {
String analysisSummary = stateTracker.analysisComplete();
handle(Event.info(null, analysisSummary));
handle(Event.info(analysisSummary));
}

@Subscribe
Expand Down Expand Up @@ -881,19 +865,19 @@ public synchronized void testSummary(TestSummary summary) {
public synchronized void buildEventTransportsAnnounced(AnnounceBuildEventTransportsEvent event) {
stateTracker.buildEventTransportsAnnounced(event);
if (debugAllEvents) {
String message = "Transports announced:";
StringBuilder message = new StringBuilder("Transports announced:");
for (BuildEventTransport transport : event.transports()) {
message += " " + transport.name();
message.append(" ").append(transport.name());
}
this.handle(Event.info(null, message));
this.handle(Event.info(message.toString()));
}
}

@Subscribe
public void buildEventTransportClosed(BuildEventTransportClosedEvent event) {
stateTracker.buildEventTransportClosed(event);
if (debugAllEvents) {
this.handle(Event.info(null, "Transport " + event.transport().name() + " closed"));
this.handle(Event.info("Transport " + event.transport().name() + " closed"));
}

checkActivities();
Expand Down

0 comments on commit 9b211de

Please sign in to comment.