summaryrefslogtreecommitdiff
path: root/java/com/google/devtools/common/options/OptionsParserImpl.java
diff options
context:
space:
mode:
authorccalvarin <ccalvarin@google.com>2017-04-19 20:18:57 +0200
committerColin Cross <ccross@android.com>2017-04-27 09:53:00 -0700
commite9535994a47759cb1a280e2581200268990f6511 (patch)
tree9941bff65c22086573f17e284d848f82d22d7f33 /java/com/google/devtools/common/options/OptionsParserImpl.java
parent110f4821ced42d63a15726374370e06a5cdc520e (diff)
downloaddesugar-e9535994a47759cb1a280e2581200268990f6511.tar.gz
Don't hard remove --no_, give a warning first.
PiperOrigin-RevId: 153610163 GitOrigin-RevId: f9efa42113c5bcf0aaadb73fbc3822b389cc5c96 Change-Id: Id19ba95070a42d783154732bbd50daa9d147d440
Diffstat (limited to 'java/com/google/devtools/common/options/OptionsParserImpl.java')
-rw-r--r--java/com/google/devtools/common/options/OptionsParserImpl.java14
1 files changed, 5 insertions, 9 deletions
diff --git a/java/com/google/devtools/common/options/OptionsParserImpl.java b/java/com/google/devtools/common/options/OptionsParserImpl.java
index c5f31c4..a4d905a 100644
--- a/java/com/google/devtools/common/options/OptionsParserImpl.java
+++ b/java/com/google/devtools/common/options/OptionsParserImpl.java
@@ -620,18 +620,14 @@ class OptionsParserImpl {
// Look for a "no"-prefixed option name: "no<optionName>".
if (field == null && name.startsWith("no")) {
// Give a nice error if someone is using the deprecated --no_ prefix.
- // Note: With this check in place, is impossible to specify "--no_foo" for a flag named
- // "--_foo", if a --foo flag also exists, since that'll be interpreted as the "no_"
- // negating prefix for "--foo". Let that be a warning to anyone wanting to make flags that
- // start with underscores.
// TODO(Bazel-team): Remove the --no_ check when sufficient time has passed for users of
// that feature to have stopped using it.
- if (name.startsWith("no_") && optionsData.getFieldFromName(name.substring(3)) != null) {
- throw new OptionsParsingException(
- "'no_' prefixes are no longer accepted, --no<flag> is an accepted alternative.",
- name.substring(3));
- }
name = name.substring(2);
+ if (name.startsWith("_") && optionsData.getFieldFromName(name.substring(1)) != null) {
+ name = name.substring(1);
+ warnings.add("Option '" + name + "' is specified using the deprecated --no_ prefix. "
+ + "Use --no without the underscore instead.");
+ }
field = optionsData.getFieldFromName(name);
booleanValue = false;
if (field != null) {