aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/common/options/OptionsParser.java
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-09-11 20:03:02 +0200
committerGravatar Philipp Wollermann <philwo@google.com>2017-09-12 14:05:08 +0200
commit1dce09721f8361240bbf056fd508f1ac5fdcfd32 (patch)
tree2406d3ab794db15d509adc842121bfa9f6c6eb84 /src/main/java/com/google/devtools/common/options/OptionsParser.java
parent5a77f426e0896031973ce1dc965f05e014ee9a24 (diff)
Replace referrals to options by their name to option definitions.
Now that we have a standard way of referring to an option, remove all of the places that we were referring to them by their name. Since options can have multiple names, this is more clear and provides the additional information needed to understand the option. It also stops the habit of requesting unqualified strings, which was hard to read. RELNOTES: None. PiperOrigin-RevId: 168254584
Diffstat (limited to 'src/main/java/com/google/devtools/common/options/OptionsParser.java')
-rw-r--r--src/main/java/com/google/devtools/common/options/OptionsParser.java49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/main/java/com/google/devtools/common/options/OptionsParser.java b/src/main/java/com/google/devtools/common/options/OptionsParser.java
index 54642a135d..5bf1b4d4ac 100644
--- a/src/main/java/com/google/devtools/common/options/OptionsParser.java
+++ b/src/main/java/com/google/devtools/common/options/OptionsParser.java
@@ -278,8 +278,8 @@ public class OptionsParser implements OptionsProvider {
@Nullable private final Object value;
@Nullable private final OptionPriority priority;
@Nullable private final String source;
- @Nullable private final String implicitDependant;
- @Nullable private final String expandedFrom;
+ @Nullable private final OptionDefinition implicitDependant;
+ @Nullable private final OptionDefinition expandedFrom;
private OptionValueDescription(
OptionDefinition optionDefinition,
@@ -288,8 +288,8 @@ public class OptionsParser implements OptionsProvider {
@Nullable Object value,
@Nullable OptionPriority priority,
@Nullable String source,
- @Nullable String implicitDependant,
- @Nullable String expandedFrom) {
+ @Nullable OptionDefinition implicitDependant,
+ @Nullable OptionDefinition expandedFrom) {
this.optionDefinition = optionDefinition;
this.isDefaultValue = isDefaultValue;
this.originalValueString = originalValueString;
@@ -306,8 +306,8 @@ public class OptionsParser implements OptionsProvider {
@Nullable Object value,
@Nullable OptionPriority priority,
@Nullable String source,
- @Nullable String implicitDependant,
- @Nullable String expandedFrom) {
+ @Nullable OptionDefinition implicitDependant,
+ @Nullable OptionDefinition expandedFrom) {
return new OptionValueDescription(
optionDefinition,
false,
@@ -377,7 +377,7 @@ public class OptionsParser implements OptionsProvider {
return source;
}
- public String getImplicitDependant() {
+ public OptionDefinition getImplicitDependant() {
return implicitDependant;
}
@@ -385,7 +385,7 @@ public class OptionsParser implements OptionsProvider {
return implicitDependant != null;
}
- public String getExpansionParent() {
+ public OptionDefinition getExpansionParent() {
return expandedFrom;
}
@@ -443,6 +443,7 @@ public class OptionsParser implements OptionsProvider {
* <p>Note that the unparsed value and the source parameters can both be null.
*/
public static class UnparsedOptionValueDescription {
+
private final OptionDefinition optionDefinition;
@Nullable private final String unparsedValue;
private final OptionPriority priority;
@@ -672,15 +673,15 @@ public class OptionsParser implements OptionsProvider {
}
/**
- * Returns a description of the options values that get expanded from this flag with the given
- * flag value.
+ * Returns a description of the options values that get expanded from this option with the given
+ * value.
*
* @return The {@link ImmutableList<OptionValueDescription>} for the option, or null if there is
* no option by the given name.
*/
ImmutableList<OptionValueDescription> getExpansionOptionValueDescriptions(
- String flagName, @Nullable String flagValue) throws OptionsParsingException {
- return impl.getExpansionOptionValueDescriptions(flagName, flagValue);
+ OptionDefinition option, @Nullable String optionValue) throws OptionsParsingException {
+ return impl.getExpansionOptionValueDescriptions(option, optionValue);
}
/**
@@ -729,15 +730,14 @@ public class OptionsParser implements OptionsProvider {
}
/**
- * Parses {@code args}, using the classes registered with this parser.
- * {@link #getOptions(Class)} and {@link #getResidue()} return the results. May be called
- * multiple times; later options override existing ones if they have equal or higher priority.
- * The source of options is given as a function that maps option names to the source of the
- * option. Strings that cannot be parsed as options accumulates as* residue, if this parser
- * allows it.
+ * Parses {@code args}, using the classes registered with this parser. {@link #getOptions(Class)}
+ * and {@link #getResidue()} return the results. May be called multiple times; later options
+ * override existing ones if they have equal or higher priority. The source of options is given as
+ * a function that maps option names to the source of the option. Strings that cannot be parsed as
+ * options accumulates as* residue, if this parser allows it.
*/
- public void parseWithSourceFunction(OptionPriority priority,
- Function<? super String, String> sourceFunction, List<String> args)
+ public void parseWithSourceFunction(
+ OptionPriority priority, Function<OptionDefinition, String> sourceFunction, List<String> args)
throws OptionsParsingException {
Preconditions.checkNotNull(priority);
Preconditions.checkArgument(priority != OptionPriority.DEFAULT);
@@ -754,13 +754,12 @@ public class OptionsParser implements OptionsProvider {
* <p>This will not affect options objects that have already been retrieved from this parser
* through {@link #getOptions(Class)}.
*
- * @param optionName The full name of the option to clear.
- * @return A map of an option name to the old value of the options that were cleared.
+ * @param option The option to clear.
+ * @return The old value of the option that was cleared.
* @throws IllegalArgumentException If the flag does not exist.
*/
- public OptionValueDescription clearValue(String optionName)
- throws OptionsParsingException {
- return impl.clearValue(optionName);
+ public OptionValueDescription clearValue(OptionDefinition option) throws OptionsParsingException {
+ return impl.clearValue(option);
}
@Override