summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorccalvarin <ccalvarin@google.com>2017-09-21 02:33:41 +0200
committerIvan Gavrilovic <gavra@google.com>2017-09-22 23:29:17 +0100
commite8f68b52a82cfa851157237899b267fe0db253a1 (patch)
treeddef8e09e0d29ec27ee2a610b50cdcc35806892d /java
parent55cf690e724bfc6ef5bd22ae8dccf4737f5c05c2 (diff)
downloaddesugar-e8f68b52a82cfa851157237899b267fe0db253a1.tar.gz
Deprecate wrapperOptions.
In order to discourage new uses (there shouldn't be any, but just in case), make it illegal to set wrapperOption=true for non deprecated options. RELNOTES: None. PiperOrigin-RevId: 169477990 GitOrigin-RevId: 125e88d693f04df7f9039906dc7bb03245fb61f7 Change-Id: Iab3e66245c1cfb53aada05654cc304a4334ddd9a
Diffstat (limited to 'java')
-rw-r--r--java/com/google/devtools/common/options/Option.java1
-rw-r--r--java/com/google/devtools/common/options/processor/OptionProcessor.java25
2 files changed, 26 insertions, 0 deletions
diff --git a/java/com/google/devtools/common/options/Option.java b/java/com/google/devtools/common/options/Option.java
index 4a65f69..92436fd 100644
--- a/java/com/google/devtools/common/options/Option.java
+++ b/java/com/google/devtools/common/options/Option.java
@@ -197,5 +197,6 @@ public @interface Option {
* expansion flags to other flags, or as implicit requirements to other flags. Use the inner flags
* instead.
*/
+ @Deprecated
boolean wrapperOption() default false;
}
diff --git a/java/com/google/devtools/common/options/processor/OptionProcessor.java b/java/com/google/devtools/common/options/processor/OptionProcessor.java
index 5ccb868..fd7c023 100644
--- a/java/com/google/devtools/common/options/processor/OptionProcessor.java
+++ b/java/com/google/devtools/common/options/processor/OptionProcessor.java
@@ -488,6 +488,30 @@ public final class OptionProcessor extends AbstractProcessor {
}
}
+ /**
+ * Some flags wrap other flags. They are objectively useless, as there is no difference between
+ * passing --wrapper=--foo and --foo other than the "source" information tracked. This
+ * functionality comes from requiring compatibility at some past point in time, but is actively
+ * being deprecated. No non-deprecated flag can use this feature.
+ */
+ private void checkWrapperOptions(VariableElement optionField) throws OptionProcessorException {
+ Option annotation = optionField.getAnnotation(Option.class);
+ if (annotation.wrapperOption()) {
+ if (annotation.deprecationWarning().isEmpty()) {
+ throw new OptionProcessorException(
+ optionField,
+ "Can't have non deprecated wrapper options, this feature is deprecated. "
+ + "Please add a deprecationWarning.");
+ }
+ if (!ImmutableList.copyOf(annotation.metadataTags()).contains(OptionMetadataTag.DEPRECATED)) {
+ throw new OptionProcessorException(
+ optionField,
+ "Can't have non deprecated wrapper options, this feature is deprecated. "
+ + "Please add the metadata tag DEPRECATED.");
+ }
+ }
+ }
+
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element annotatedElement : roundEnv.getElementsAnnotatedWith(Option.class)) {
@@ -504,6 +528,7 @@ public final class OptionProcessor extends AbstractProcessor {
checkConverter(optionField);
checkEffectTagRationality(optionField);
checkMetadataTagAndCategoryRationality(optionField);
+ checkWrapperOptions(optionField);
} catch (OptionProcessorException e) {
error(e.getElementInError(), e.getMessage());
}