diff options
Diffstat (limited to 'java/com/google/devtools/common/options/OptionValueDescription.java')
-rw-r--r-- | java/com/google/devtools/common/options/OptionValueDescription.java | 70 |
1 files changed, 12 insertions, 58 deletions
diff --git a/java/com/google/devtools/common/options/OptionValueDescription.java b/java/com/google/devtools/common/options/OptionValueDescription.java index 616b3b5..11ad7fe 100644 --- a/java/com/google/devtools/common/options/OptionValueDescription.java +++ b/java/com/google/devtools/common/options/OptionValueDescription.java @@ -22,7 +22,7 @@ import com.google.devtools.common.options.OptionsParser.ConstructionException; import java.util.Collection; import java.util.Comparator; import java.util.List; -import java.util.Map.Entry; +import java.util.Map; import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -98,8 +98,6 @@ public abstract class OptionValueDescription { return new RepeatableOptionValueDescription(option); } else if (option.hasImplicitRequirements()) { return new OptionWithImplicitRequirementsValueDescription(option); - } else if (option.isWrapperOption()) { - return new WrapperOptionValueDescription(option); } else { return new SingleOptionValueDescription(option); } @@ -187,11 +185,11 @@ public abstract class OptionValueDescription { // log warnings describing the change. if (parsedOption.getPriority().compareTo(effectiveOptionInstance.getPriority()) >= 0) { // Identify the option that might have led to the current and new value of this option. - OptionDefinition implicitDependent = parsedOption.getImplicitDependent(); - OptionDefinition expandedFrom = parsedOption.getExpandedFrom(); - OptionDefinition optionThatDependsOnEffectiveValue = + ParsedOptionDescription implicitDependent = parsedOption.getImplicitDependent(); + ParsedOptionDescription expandedFrom = parsedOption.getExpandedFrom(); + ParsedOptionDescription optionThatDependsOnEffectiveValue = effectiveOptionInstance.getImplicitDependent(); - OptionDefinition optionThatExpandedToEffectiveValue = + ParsedOptionDescription optionThatExpandedToEffectiveValue = effectiveOptionInstance.getExpandedFrom(); Object newValue = parsedOption.getConvertedValue(); @@ -227,7 +225,7 @@ public abstract class OptionValueDescription { // Create a warning if an expansion option overrides an explicit option: warnings.add( String.format( - "%s was expanded and now overrides a previous explicitly specified %s with %s", + "%s was expanded and now overrides the explicit option %s with %s", expandedFrom, effectiveOptionInstance.getCommandLineForm(), parsedOption.getCommandLineForm())); @@ -278,8 +276,8 @@ public abstract class OptionValueDescription { .asMap() .entrySet() .stream() - .sorted(Comparator.comparing(Entry::getKey)) - .map(Entry::getValue) + .sorted(Comparator.comparing(Map.Entry::getKey)) + .map(Map.Entry::getValue) .flatMap(Collection::stream) .map(ParsedOptionDescription::getSource) .distinct() @@ -294,8 +292,8 @@ public abstract class OptionValueDescription { .asMap() .entrySet() .stream() - .sorted(Comparator.comparing(Entry::getKey)) - .map(Entry::getValue) + .sorted(Comparator.comparing(Map.Entry::getKey)) + .map(Map.Entry::getValue) .flatMap(Collection::stream) .collect(Collectors.toList()); } @@ -322,8 +320,8 @@ public abstract class OptionValueDescription { .asMap() .entrySet() .stream() - .sorted(Comparator.comparing(Entry::getKey)) - .map(Entry::getValue) + .sorted(Comparator.comparing(Map.Entry::getKey)) + .map(Map.Entry::getValue) .flatMap(Collection::stream) // Only provide the options that aren't implied elsewhere. .filter(optionDesc -> optionDesc.getImplicitDependent() == null) @@ -430,50 +428,6 @@ public abstract class OptionValueDescription { optionDefinition, parsedOption.getSource())); } } - - /** Form for options that contain other options in the value text to which they expand. */ - private static final class WrapperOptionValueDescription extends OptionValueDescription { - - WrapperOptionValueDescription(OptionDefinition optionDefinition) { - super(optionDefinition); - } - - @Override - public Object getValue() { - return null; - } - - @Override - public String getSourceString() { - return null; - } - - @Override - ExpansionBundle addOptionInstance(ParsedOptionDescription parsedOption, List<String> warnings) - throws OptionsParsingException { - if (!parsedOption.getUnconvertedValue().startsWith("-")) { - throw new OptionsParsingException( - String.format( - "Invalid value format for %s. You may have meant --%s=--%s", - optionDefinition, - optionDefinition.getOptionName(), - parsedOption.getUnconvertedValue())); - } - return new ExpansionBundle( - ImmutableList.of(parsedOption.getUnconvertedValue()), - (parsedOption.getSource() == null) - ? String.format("unwrapped from %s", optionDefinition) - : String.format( - "unwrapped from %s (source %s)", optionDefinition, parsedOption.getSource())); - } - - @Override - public ImmutableList<ParsedOptionDescription> getCanonicalInstances() { - // No wrapper options get listed in the canonical form - the options they are wrapping will - // be in the right place. - return ImmutableList.of(); - } - } } |