summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Adams <ulfjack@google.com>2016-10-14 14:20:31 +0000
committerColin Cross <ccross@android.com>2017-02-16 22:38:59 -0800
commite90ef10c448d8dddefe672283686ce350c5f9632 (patch)
tree9866f0a445bf1a74907788412bc80df9f31c4cd3
parent465318af57dd7859ef8e1137b2fdb6bb00ea2c96 (diff)
downloaddesugar-e90ef10c448d8dddefe672283686ce350c5f9632.tar.gz
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=136154395 GitOrigin-RevId: de14adebfcc0d66ff48aec9ace3a4d36343200f5 Change-Id: Ia2e84aaaf72e0053f1faba3cd981dcfbd5e2ea6a
-rw-r--r--java/com/google/devtools/common/options/OptionsClassProvider.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/java/com/google/devtools/common/options/OptionsClassProvider.java b/java/com/google/devtools/common/options/OptionsClassProvider.java
index 90e7d48..b28c29d 100644
--- a/java/com/google/devtools/common/options/OptionsClassProvider.java
+++ b/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 extends OptionsBase> O getOptions(Class<O> 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 {
* <p>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 extends OptionsBase> O getOptions(Class<O> optionsClass);
+ @Nullable <O extends OptionsBase> O getOptions(Class<O> optionsClass);
}