From 2891ec527eed27d0c6460d66f51cb66a43373b6a Mon Sep 17 00:00:00 2001 From: Ulf Adams Date: Thu, 13 Oct 2016 11:56:18 +0000 Subject: Make --watchfs a common command option. Adding an options parameter to DiffAwareness#getCurrentView seems like the simplest way to achieve that. Alternatives considered: 1. Making the diff awareness modules stateful. However, I did not want to do so as I've also been working on improving the module API to reduce state, or at least to have a proper lifecycle management for any necessary state. 2. Making the watchFs flag a constructor parameter. However, that would also invalidate any implementations that don't use the flag (of which we have several). 3. Only passing in a single boolean flag instead of an options class provider; however, this is a more principled, futureproof API, which allows other modules / awareness implementations to use their own options. RELNOTES: --watchfs is now a command option; the startup option of the same name is deprecated. I.e., use bazel build --watchfs, not blaze --watchfs build. -- MOS_MIGRATED_REVID=136026835 --- .../google/devtools/common/options/OptionsClassProvider.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/google/devtools/common') diff --git a/src/main/java/com/google/devtools/common/options/OptionsClassProvider.java b/src/main/java/com/google/devtools/common/options/OptionsClassProvider.java index 90e7d48d1c..b28c29d3dc 100644 --- a/src/main/java/com/google/devtools/common/options/OptionsClassProvider.java +++ b/src/main/java/com/google/devtools/common/options/OptionsClassProvider.java @@ -13,11 +13,20 @@ // limitations under the License. package com.google.devtools.common.options; +import javax.annotation.Nullable; + /** * A read-only interface for options parser results, which only allows to query the options of * a specific class, but not e.g. the residue any other information pertaining to the command line. */ public interface OptionsClassProvider { + public static final OptionsClassProvider EMPTY = new OptionsClassProvider() { + @Override @Nullable + public O getOptions(Class optionsClass) { + return null; + } + }; + /** * Returns the options instance for the given {@code optionsClass}, that is, * the parsed options, or null if it is not among those available. @@ -25,5 +34,5 @@ public interface OptionsClassProvider { *

The returned options should be treated by library code as immutable and * a provider is permitted to return the same options instance multiple times. */ - O getOptions(Class optionsClass); + @Nullable O getOptions(Class optionsClass); } -- cgit v1.2.3