Skip to content

Commit

Permalink
Merge TimeSource classes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 569659176
  • Loading branch information
Googler authored and copybara-github committed Sep 30, 2023
1 parent 688a7ff commit e0f851c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.idea.blaze.base.logging.utils.querysync.QuerySyncActionStats.Result;
import com.google.idea.blaze.base.scope.BlazeContext;
import com.google.idea.blaze.base.scope.BlazeScope;
import com.google.idea.blaze.common.TimeSource;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.vfs.VirtualFile;
import java.time.Duration;
Expand Down Expand Up @@ -107,12 +108,4 @@ public void onScopeEnd(BlazeContext context) {
.setResult(getSyncResult(context))
.build()));
}

/**
* Provider for the current value of "now" for users. This allows unit tests to set now
* specifically.
*/
public interface TimeSource {
Instant now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,17 @@

package com.google.idea.blaze.base.toolwindow;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.idea.blaze.base.scope.output.StateUpdate;
import com.google.idea.blaze.base.scope.output.StatusOutput;
import com.google.idea.blaze.common.PrintOutput;
import com.intellij.execution.filters.Filter;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.openapi.project.Project;
import java.time.Instant;

/** Service that controls the Blaze Outputs Tool Window. */
public interface TasksToolWindowService {

/** Provider for the current value of "now" for users of {@code java.time}. */
@FunctionalInterface
@VisibleForTesting
interface TimeSource {
/** Returns the current {@link Instant} according to this time source. */
Instant now();
}

static TasksToolWindowService getInstance(Project project) {
return project.getService(TasksToolWindowService.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.idea.blaze.base.scope.output.StateUpdate;
import com.google.idea.blaze.base.scope.output.StatusOutput;
import com.google.idea.blaze.common.PrintOutput;
import com.google.idea.blaze.common.TimeSource;
import com.intellij.execution.filters.Filter;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.openapi.Disposable;
Expand Down
27 changes: 27 additions & 0 deletions shared/java/com/google/idea/blaze/common/TimeSource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.common;

import com.google.common.annotations.VisibleForTesting;
import java.time.Instant;

/** Provider for the current value of "now" for users of {@code java.time}. */
@FunctionalInterface
@VisibleForTesting
public interface TimeSource {
/** Returns the current {@link Instant} according to this time source. */
Instant now();
}

0 comments on commit e0f851c

Please sign in to comment.