diff options
author | ccalvarin <ccalvarin@google.com> | 2017-10-13 20:34:58 +0200 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-10-24 12:21:48 -0700 |
commit | f64b5709739598a3cd06a951af13a7e115559550 (patch) | |
tree | 3bde836bd8926f184b9434be1b6c25b725fcccb7 | |
parent | d5c73e06b8fb194cd8c2d9317ca8c65dfeff3d9d (diff) | |
download | desugar-f64b5709739598a3cd06a951af13a7e115559550.tar.gz |
Make option conflicts less spammy.
Remove an unnecessary warning and make all warnings for option conflicts print only if the option values are not equal.
RELNOTES: None.
PiperOrigin-RevId: 172124261
GitOrigin-RevId: 2553875c285dcca454ee830182d238296ce70aa2
Change-Id: I335a346ac2f8c92deba52fc3b5ce582f8d0fa20e
-rw-r--r-- | java/com/google/devtools/common/options/OptionValueDescription.java | 85 |
1 files changed, 40 insertions, 45 deletions
diff --git a/java/com/google/devtools/common/options/OptionValueDescription.java b/java/com/google/devtools/common/options/OptionValueDescription.java index aa808e2..886e97e 100644 --- a/java/com/google/devtools/common/options/OptionValueDescription.java +++ b/java/com/google/devtools/common/options/OptionValueDescription.java @@ -160,59 +160,54 @@ public abstract class OptionValueDescription { OptionDefinition optionThatExpandedToEffectiveValue = effectiveOptionInstance.getExpandedFrom(); - // Output warnings: - if ((implicitDependent != null) && (optionThatDependsOnEffectiveValue != null)) { - if (!implicitDependent.equals(optionThatDependsOnEffectiveValue)) { + Object newValue = parsedOption.getConvertedValue(); + // Output warnings if there is conflicting options set different values in a way that might + // not have been obvious to the user, such as through expansions and implicit requirements. + if (!effectiveValue.equals(newValue)) { + if ((implicitDependent != null) && (optionThatDependsOnEffectiveValue != null)) { + if (!implicitDependent.equals(optionThatDependsOnEffectiveValue)) { + warnings.add( + String.format( + "Option '%s' is implicitly defined by both option '%s' and option '%s'", + optionDefinition.getOptionName(), + optionThatDependsOnEffectiveValue.getOptionName(), + implicitDependent.getOptionName())); + } + } else if ((implicitDependent != null) + && parsedOption.getPriority().equals(effectiveOptionInstance.getPriority())) { warnings.add( String.format( - "Option '%s' is implicitly defined by both option '%s' and option '%s'", + "Option '%s' is implicitly defined by option '%s'; the implicitly set value " + + "overrides the previous one", + optionDefinition.getOptionName(), implicitDependent.getOptionName())); + } else if (optionThatDependsOnEffectiveValue != null) { + warnings.add( + String.format( + "A new value for option '%s' overrides a previous implicit setting of that " + + "option by option '%s'", + optionDefinition.getOptionName(), + optionThatDependsOnEffectiveValue.getOptionName())); + } else if ((parsedOption.getPriority() == effectiveOptionInstance.getPriority()) + && ((optionThatExpandedToEffectiveValue == null) && (expandedFrom != null))) { + // Create a warning if an expansion option overrides an explicit option: + warnings.add( + String.format( + "The option '%s' was expanded and now overrides a previous explicitly " + + "specified option '%s'", + expandedFrom.getOptionName(), optionDefinition.getOptionName())); + } else if ((optionThatExpandedToEffectiveValue != null) && (expandedFrom != null)) { + warnings.add( + String.format( + "The option '%s' was expanded to from both options '%s' and '%s'", optionDefinition.getOptionName(), - optionThatDependsOnEffectiveValue.getOptionName(), - implicitDependent.getOptionName())); + optionThatExpandedToEffectiveValue.getOptionName(), + expandedFrom.getOptionName())); } - } else if ((implicitDependent != null) - && parsedOption.getPriority().equals(effectiveOptionInstance.getPriority())) { - warnings.add( - String.format( - "Option '%s' is implicitly defined by option '%s'; the implicitly set value " - + "overrides the previous one", - optionDefinition.getOptionName(), implicitDependent.getOptionName())); - } else if (optionThatDependsOnEffectiveValue != null) { - warnings.add( - String.format( - "A new value for option '%s' overrides a previous implicit setting of that " - + "option by option '%s'", - optionDefinition.getOptionName(), - optionThatDependsOnEffectiveValue.getOptionName())); - } else if ((parsedOption.getPriority() == effectiveOptionInstance.getPriority()) - && ((optionThatExpandedToEffectiveValue == null) && (expandedFrom != null))) { - // Create a warning if an expansion option overrides an explicit option: - warnings.add( - String.format( - "The option '%s' was expanded and now overrides a previous explicitly specified " - + "option '%s'", - expandedFrom.getOptionName(), optionDefinition.getOptionName())); - } else if ((optionThatExpandedToEffectiveValue != null) && (expandedFrom != null)) { - warnings.add( - String.format( - "The option '%s' was expanded to from both options '%s' and '%s'", - optionDefinition.getOptionName(), - optionThatExpandedToEffectiveValue.getOptionName(), - expandedFrom.getOptionName())); } // Record the new value: effectiveOptionInstance = parsedOption; - effectiveValue = parsedOption.getConvertedValue(); - } else { - // The new value does not override the old value, as it has lower priority. - warnings.add( - String.format( - "The lower priority option '%s' (source %s) does not override the previous value " - + "'%s'", - parsedOption.getCommandLineForm(), - parsedOption.getSource(), - effectiveOptionInstance.getCommandLineForm())); + effectiveValue = newValue; } } |