aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java14
-rw-r--r--src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java38
-rw-r--r--src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java4
-rw-r--r--src/main/java/com/google/devtools/common/options/OptionDefinition.java4
-rw-r--r--src/main/java/com/google/devtools/common/options/OptionsParser.java14
-rw-r--r--src/main/java/com/google/devtools/common/options/OptionsParserImpl.java149
-rw-r--r--src/main/java/com/google/devtools/common/options/OptionsUsage.java4
-rw-r--r--src/main/java/com/google/devtools/common/options/UnparsedOptionValueDescription.java33
8 files changed, 149 insertions, 111 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java b/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java
index ab4872aa08..56f4d961be 100644
--- a/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java
@@ -43,7 +43,7 @@ public final class OptionsUtils {
if (result.length() != 0) {
result.append(' ');
}
- String value = option.getUnparsedValue();
+ String value = option.getUnconvertedValue();
if (option.isBooleanOption()) {
boolean isEnabled = false;
try {
@@ -51,9 +51,11 @@ public final class OptionsUtils {
} catch (OptionsParsingException e) {
throw new RuntimeException("Unexpected parsing exception", e);
}
- result.append(isEnabled ? "--" : "--no").append(option.getName());
+ result
+ .append(isEnabled ? "--" : "--no")
+ .append(option.getOptionDefinition().getOptionName());
} else {
- result.append("--").append(option.getName());
+ result.append("--").append(option.getOptionDefinition().getOptionName());
if (value != null) { // Can be null for Void options.
result.append("=").append(ShellEscaper.escapeString(value));
}
@@ -80,7 +82,7 @@ public final class OptionsUtils {
if (option.isHidden()) {
continue;
}
- String value = option.getUnparsedValue();
+ String value = option.getUnconvertedValue();
if (option.isBooleanOption()) {
boolean isEnabled = false;
try {
@@ -88,9 +90,9 @@ public final class OptionsUtils {
} catch (OptionsParsingException e) {
throw new RuntimeException("Unexpected parsing exception", e);
}
- builder.add((isEnabled ? "--" : "--no") + option.getName());
+ builder.add((isEnabled ? "--" : "--no") + option.getOptionDefinition().getOptionName());
} else {
- String optionString = "--" + option.getName();
+ String optionString = "--" + option.getOptionDefinition().getOptionName();
if (value != null) { // Can be null for Void options.
optionString += "=" + value;
}
diff --git a/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java b/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java
index e8a84f032a..8b5ba08fee 100644
--- a/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java
+++ b/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java
@@ -51,9 +51,9 @@ public final class InvocationPolicyEnforcer {
private static final Logger logger = Logger.getLogger(InvocationPolicyEnforcer.class.getName());
- private static final Function<OptionDefinition, String> INVOCATION_POLICY_SOURCE =
- o -> "Invocation policy";
-
+ private static final String INVOCATION_POLICY_SOURCE = "Invocation policy";
+ private static final Function<OptionDefinition, String> INVOCATION_POLICY_SOURCE_FUNCTION =
+ o -> INVOCATION_POLICY_SOURCE;
@Nullable private final InvocationPolicy invocationPolicy;
/**
@@ -114,8 +114,10 @@ public final class InvocationPolicyEnforcer {
continue;
}
- OptionDescription optionDescription = parser.getOptionDescription(flagName);
- // extractOptionDefinition() will return null if the option does not exist, however
+ OptionDescription optionDescription =
+ parser.getOptionDescription(
+ flagName, OptionPriority.INVOCATION_POLICY, INVOCATION_POLICY_SOURCE);
+ // getOptionDescription() will return null if the option does not exist, however
// getOptionValueDescription() above would have thrown an IllegalArgumentException if that
// were the case.
Verify.verifyNotNull(optionDescription);
@@ -255,19 +257,28 @@ public final class InvocationPolicyEnforcer {
for (String value : setValue.getFlagValueList()) {
resultsBuilder.addAll(
parser.getExpansionOptionValueDescriptions(
- optionDescription.getOptionDefinition(), value));
+ optionDescription.getOptionDefinition(),
+ value,
+ OptionPriority.INVOCATION_POLICY,
+ INVOCATION_POLICY_SOURCE));
}
} else {
resultsBuilder.addAll(
parser.getExpansionOptionValueDescriptions(
- optionDescription.getOptionDefinition(), null));
+ optionDescription.getOptionDefinition(),
+ null,
+ OptionPriority.INVOCATION_POLICY,
+ INVOCATION_POLICY_SOURCE));
}
}
break;
case USE_DEFAULT:
resultsBuilder.addAll(
parser.getExpansionOptionValueDescriptions(
- optionDescription.getOptionDefinition(), null));
+ optionDescription.getOptionDefinition(),
+ null,
+ OptionPriority.INVOCATION_POLICY,
+ INVOCATION_POLICY_SOURCE));
break;
case ALLOW_VALUES:
// All expansions originally given to the parser have been expanded by now, so these two
@@ -307,7 +318,10 @@ public final class InvocationPolicyEnforcer {
List<FlagPolicy> expandedPolicies = new ArrayList<>();
OptionDescription originalOptionDescription =
- parser.getOptionDescription(originalPolicy.getFlagName());
+ parser.getOptionDescription(
+ originalPolicy.getFlagName(),
+ OptionPriority.INVOCATION_POLICY,
+ INVOCATION_POLICY_SOURCE);
if (originalOptionDescription == null) {
// InvocationPolicy ignores policy on non-existing flags by design, for version compatibility.
return expandedPolicies;
@@ -574,7 +588,9 @@ public final class InvocationPolicyEnforcer {
String originalValue = clearedValueDescription.getValue().toString();
String source = clearedValueDescription.getSource();
- OptionDescription desc = parser.getOptionDescription(clearedFlagName);
+ OptionDescription desc =
+ parser.getOptionDescription(
+ clearedFlagName, OptionPriority.INVOCATION_POLICY, INVOCATION_POLICY_SOURCE);
Object clearedFlagDefaultValue = null;
if (desc != null) {
clearedFlagDefaultValue = desc.getOptionDefinition().getDefaultValue();
@@ -794,7 +810,7 @@ public final class InvocationPolicyEnforcer {
parser.parseWithSourceFunction(
OptionPriority.INVOCATION_POLICY,
- INVOCATION_POLICY_SOURCE,
+ INVOCATION_POLICY_SOURCE_FUNCTION,
ImmutableList.of(String.format("--%s=%s", flag.getOptionName(), flagValue)));
}
}
diff --git a/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java b/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java
index 57b4d232c1..58eb07d370 100644
--- a/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java
+++ b/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java
@@ -259,7 +259,7 @@ public class IsolatedOptionsData extends OpaqueOptionsData {
optionName,
"option name collision with another option's old name");
checkForBooleanAliasCollisions(booleanAliasMap, optionName, "option");
- if (optionDefinition.isBooleanField()) {
+ if (optionDefinition.usesBooleanValueSyntax()) {
checkAndUpdateBooleanAliases(
nameToFieldBuilder, oldNameToFieldBuilder, booleanAliasMap, optionName);
}
@@ -277,7 +277,7 @@ public class IsolatedOptionsData extends OpaqueOptionsData {
"old option name collision with another old option name");
checkForBooleanAliasCollisions(booleanAliasMap, oldName, "old option name");
// If boolean, repeat the alias dance for the old name.
- if (optionDefinition.isBooleanField()) {
+ if (optionDefinition.usesBooleanValueSyntax()) {
checkAndUpdateBooleanAliases(
nameToFieldBuilder, oldNameToFieldBuilder, booleanAliasMap, oldName);
}
diff --git a/src/main/java/com/google/devtools/common/options/OptionDefinition.java b/src/main/java/com/google/devtools/common/options/OptionDefinition.java
index a42a624cf7..e2ea084791 100644
--- a/src/main/java/com/google/devtools/common/options/OptionDefinition.java
+++ b/src/main/java/com/google/devtools/common/options/OptionDefinition.java
@@ -210,7 +210,7 @@ public class OptionDefinition {
*
* <p>Memoizes the converter-finding logic to avoid repeating the computation.
*/
- Converter<?> getConverter() {
+ public Converter<?> getConverter() {
if (converter != null) {
return converter;
}
@@ -240,7 +240,7 @@ public class OptionDefinition {
*
* <p>Can be used for usage help and controlling whether the "no" prefix is allowed.
*/
- boolean isBooleanField() {
+ public boolean usesBooleanValueSyntax() {
return getType().equals(boolean.class)
|| getType().equals(TriState.class)
|| getConverter() instanceof BoolOrEnumConverter;
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 1d41e3dfbf..68a9f02100 100644
--- a/src/main/java/com/google/devtools/common/options/OptionsParser.java
+++ b/src/main/java/com/google/devtools/common/options/OptionsParser.java
@@ -405,20 +405,22 @@ public class OptionsParser implements OptionsProvider {
* @return The {@link OptionDescription} for the option, or null if there is no option by the
* given name.
*/
- OptionDescription getOptionDescription(String name) throws OptionsParsingException {
- return impl.getOptionDescription(name);
+ OptionDescription getOptionDescription(String name, OptionPriority priority, String source)
+ throws OptionsParsingException {
+ return impl.getOptionDescription(name, priority, source);
}
/**
* Returns a description of the options values that get expanded from this option with the given
* value.
*
- * @return The {@link com.google.devtools.common.options.OptionValueDescriptionlueDescription>}
- * for the option, or null if there is no option by the given name.
+ * @return The {@link com.google.devtools.common.options.OptionValueDescription>} for the option,
+ * or null if there is no option by the given name.
*/
ImmutableList<OptionValueDescription> getExpansionOptionValueDescriptions(
- OptionDefinition option, @Nullable String optionValue) throws OptionsParsingException {
- return impl.getExpansionOptionValueDescriptions(option, optionValue);
+ OptionDefinition option, @Nullable String optionValue, OptionPriority priority, String source)
+ throws OptionsParsingException {
+ return impl.getExpansionOptionValueDescriptions(option, optionValue, priority, source);
}
/**
diff --git a/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java b/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java
index 3ac891000f..5e584357c4 100644
--- a/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java
+++ b/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java
@@ -153,11 +153,18 @@ class OptionsParserImpl {
if (v2.isImplicitRequirement()) {
return -1;
}
- return v1.getName().compareTo(v2.getName());
+ return v1.getOptionDefinition()
+ .getOptionName()
+ .compareTo(v2.getOptionDefinition().getOptionName());
})
// Ignore expansion options.
.filter(value -> !value.isExpansion())
- .map(value -> "--" + value.getName() + "=" + value.getUnparsedValue())
+ .map(
+ value ->
+ "--"
+ + value.getOptionDefinition().getOptionName()
+ + "="
+ + value.getUnconvertedValue())
.collect(toCollection(ArrayList::new));
}
@@ -304,7 +311,8 @@ class OptionsParserImpl {
return parsedValues.get(optionDefinition);
}
- OptionDescription getOptionDescription(String name) throws OptionsParsingException {
+ OptionDescription getOptionDescription(String name, OptionPriority priority, String source)
+ throws OptionsParsingException {
OptionDefinition optionDefinition = optionsData.getOptionDefinitionFromName(name);
if (optionDefinition == null) {
return null;
@@ -314,31 +322,39 @@ class OptionsParserImpl {
optionDefinition,
optionsData.getExpansionDataForField(optionDefinition),
getImplicitDependantDescriptions(
- ImmutableList.copyOf(optionDefinition.getImplicitRequirements()), optionDefinition));
+ ImmutableList.copyOf(optionDefinition.getImplicitRequirements()),
+ optionDefinition,
+ priority,
+ source));
}
- /**
- * @return A list of the descriptions corresponding to the implicit dependant flags passed in.
- * These descriptions are are divorced from the command line - there is no correct priority or
- * source for these, as they are not actually set values. The value itself is also a string,
- * no conversion has taken place.
- */
+ /** @return A list of the descriptions corresponding to the implicit dependant flags passed in. */
private ImmutableList<OptionValueDescription> getImplicitDependantDescriptions(
- ImmutableList<String> options, OptionDefinition implicitDependant)
+ ImmutableList<String> options,
+ OptionDefinition implicitDependant,
+ OptionPriority priority,
+ String source)
throws OptionsParsingException {
ImmutableList.Builder<OptionValueDescription> builder = ImmutableList.builder();
Iterator<String> optionsIterator = options.iterator();
+ Function<OptionDefinition, String> sourceFunction =
+ o ->
+ String.format(
+ "implicitely required for option %s (source: %s)",
+ implicitDependant.getOptionName(), source);
while (optionsIterator.hasNext()) {
String unparsedFlagExpression = optionsIterator.next();
- ParseOptionResult parseResult = parseOption(unparsedFlagExpression, optionsIterator);
+ UnparsedOptionValueDescription unparsedOption =
+ identifyOptionAndPossibleArgument(
+ unparsedFlagExpression, optionsIterator, priority, sourceFunction, false);
builder.add(
OptionValueDescription.newOptionValue(
- parseResult.optionDefinition,
- parseResult.value,
+ unparsedOption.getOptionDefinition(),
+ unparsedOption.getUnconvertedValue(),
/* value */ null,
- /* priority */ null,
- /* source */ null,
+ unparsedOption.getPriority(),
+ unparsedOption.getSource(),
implicitDependant,
/* expendedFrom */ null));
}
@@ -352,22 +368,29 @@ class OptionsParserImpl {
* is also a string, no conversion has taken place.
*/
ImmutableList<OptionValueDescription> getExpansionOptionValueDescriptions(
- OptionDefinition expansionFlag, @Nullable String flagValue) throws OptionsParsingException {
+ OptionDefinition expansionFlag,
+ @Nullable String flagValue,
+ OptionPriority priority,
+ String source)
+ throws OptionsParsingException {
ImmutableList.Builder<OptionValueDescription> builder = ImmutableList.builder();
ImmutableList<String> options = optionsData.getEvaluatedExpansion(expansionFlag, flagValue);
Iterator<String> optionsIterator = options.iterator();
-
+ Function<OptionDefinition, String> sourceFunction =
+ o -> String.format("expanded from %s (source: %s)", expansionFlag.getOptionName(), source);
while (optionsIterator.hasNext()) {
String unparsedFlagExpression = optionsIterator.next();
- ParseOptionResult parseResult = parseOption(unparsedFlagExpression, optionsIterator);
+ UnparsedOptionValueDescription unparsedOption =
+ identifyOptionAndPossibleArgument(
+ unparsedFlagExpression, optionsIterator, priority, sourceFunction, false);
builder.add(
OptionValueDescription.newOptionValue(
- parseResult.optionDefinition,
- parseResult.value,
+ unparsedOption.getOptionDefinition(),
+ unparsedOption.getUnconvertedValue(),
/* value */ null,
- /* priority */ null,
- /* source */ null,
+ unparsedOption.getPriority(),
+ unparsedOption.getSource(),
/* implicitDependant */ null,
expansionFlag));
}
@@ -408,7 +431,7 @@ class OptionsParserImpl {
OptionDefinition expandedFrom,
List<String> args)
throws OptionsParsingException {
-
+ boolean isExplicit = expandedFrom == null && implicitDependent == null;
List<String> unparsedArgs = new ArrayList<>();
LinkedHashMap<OptionDefinition, List<String>> implicitRequirements = new LinkedHashMap<>();
@@ -426,12 +449,14 @@ class OptionsParserImpl {
break;
}
- ParseOptionResult parseOptionResult = parseOption(arg, argsIterator);
- OptionDefinition optionDefinition = parseOptionResult.optionDefinition;
- @Nullable String value = parseOptionResult.value;
+ UnparsedOptionValueDescription unparsedOption =
+ identifyOptionAndPossibleArgument(
+ arg, argsIterator, priority, sourceFunction, isExplicit);
+ OptionDefinition optionDefinition = unparsedOption.getOptionDefinition();
+ @Nullable String unconvertedValue = unparsedOption.getUnconvertedValue();
if (optionDefinition.isWrapperOption()) {
- if (value.startsWith("-")) {
+ if (unconvertedValue.startsWith("-")) {
String sourceMessage =
"Unwrapped from wrapper option --" + optionDefinition.getOptionName();
List<String> unparsed =
@@ -440,7 +465,7 @@ class OptionsParserImpl {
o -> sourceMessage,
null, // implicitDependent
null, // expandedFrom
- ImmutableList.of(value));
+ ImmutableList.of(unconvertedValue));
if (!unparsed.isEmpty()) {
throw new OptionsParsingException(
@@ -463,7 +488,7 @@ class OptionsParserImpl {
+ "You may have meant --"
+ optionDefinition.getOptionName()
+ "=--"
- + value);
+ + unconvertedValue);
}
}
@@ -471,26 +496,18 @@ class OptionsParserImpl {
// Log explicit options and expanded options in the order they are parsed (can be sorted
// later). Also remember whether they were expanded or not. This information is needed to
// correctly canonicalize flags.
- UnparsedOptionValueDescription unparsedOptionValueDescription =
- new UnparsedOptionValueDescription(
- optionDefinition,
- value,
- priority,
- sourceFunction.apply(optionDefinition),
- expandedFrom == null);
- unparsedValues.add(unparsedOptionValueDescription);
+ unparsedValues.add(unparsedOption);
if (optionDefinition.allowsMultiple()) {
- canonicalizeValues.put(optionDefinition, unparsedOptionValueDescription);
+ canonicalizeValues.put(optionDefinition, unparsedOption);
} else {
- canonicalizeValues.replaceValues(
- optionDefinition, ImmutableList.of(unparsedOptionValueDescription));
+ canonicalizeValues.replaceValues(optionDefinition, ImmutableList.of(unparsedOption));
}
}
// Handle expansion options.
if (optionDefinition.isExpansionOption()) {
ImmutableList<String> expansion =
- optionsData.getEvaluatedExpansion(optionDefinition, value);
+ optionsData.getEvaluatedExpansion(optionDefinition, unconvertedValue);
String sourceMessage =
"expanded from option --"
@@ -502,8 +519,8 @@ class OptionsParserImpl {
List<String> unparsed =
parse(priority, expansionSourceFunction, null, optionDefinition, expansion);
if (!unparsed.isEmpty()) {
- // Throw an assertion, because this indicates an error in the code that specified the
- // expansion for the current option.
+ // Throw an assertion, because this indicates an error in the definition of this
+ // option's expansion, not with the input as provided by the user.
throw new AssertionError(
"Unparsed options remain after parsing expansion of "
+ arg
@@ -514,7 +531,7 @@ class OptionsParserImpl {
Converter<?> converter = optionDefinition.getConverter();
Object convertedValue;
try {
- convertedValue = converter.convert(value);
+ convertedValue = converter.convert(unconvertedValue);
} catch (OptionsParsingException e) {
// The converter doesn't know the option name, so we supply it here by
// re-throwing:
@@ -580,20 +597,15 @@ class OptionsParserImpl {
return unparsedArgs;
}
- private static final class ParseOptionResult {
- final OptionDefinition optionDefinition;
- @Nullable final String value;
-
- ParseOptionResult(OptionDefinition optionDefinition, @Nullable String value) {
- this.optionDefinition = optionDefinition;
- this.value = value;
- }
- }
-
- private ParseOptionResult parseOption(String arg, Iterator<String> nextArgs)
+ private UnparsedOptionValueDescription identifyOptionAndPossibleArgument(
+ String arg,
+ Iterator<String> nextArgs,
+ OptionPriority priority,
+ Function<OptionDefinition, String> sourceFunction,
+ boolean explicit)
throws OptionsParsingException {
- String value = null;
+ String unparsedValue = null;
OptionDefinition optionDefinition;
boolean booleanValue = true;
@@ -615,7 +627,7 @@ class OptionsParserImpl {
if (name.trim().isEmpty()) {
throw new OptionsParsingException("Invalid options syntax: " + arg, arg);
}
- value = equalsAt == -1 ? null : arg.substring(equalsAt + 1);
+ unparsedValue = equalsAt == -1 ? null : arg.substring(equalsAt + 1);
optionDefinition = optionsData.getOptionDefinitionFromName(name);
// Look for a "no"-prefixed option name: "no<optionName>".
@@ -625,16 +637,16 @@ class OptionsParserImpl {
booleanValue = false;
if (optionDefinition != null) {
// TODO(bazel-team): Add tests for these cases.
- if (!optionDefinition.isBooleanField()) {
+ if (!optionDefinition.usesBooleanValueSyntax()) {
throw new OptionsParsingException(
"Illegal use of 'no' prefix on non-boolean option: " + arg, arg);
}
- if (value != null) {
+ if (unparsedValue != null) {
throw new OptionsParsingException(
"Unexpected value after boolean option: " + arg, arg);
}
// "no<optionname>" signifies a boolean option w/ false value
- value = "0";
+ unparsedValue = "0";
}
}
} else {
@@ -648,21 +660,26 @@ class OptionsParserImpl {
throw new OptionsParsingException("Unrecognized option: " + arg, arg);
}
- if (value == null) {
+ if (unparsedValue == null) {
// Special-case boolean to supply value based on presence of "no" prefix.
- if (optionDefinition.isBooleanField()) {
- value = booleanValue ? "1" : "0";
+ if (optionDefinition.usesBooleanValueSyntax()) {
+ unparsedValue = booleanValue ? "1" : "0";
} else if (optionDefinition.getType().equals(Void.class)
&& !optionDefinition.isWrapperOption()) {
// This is expected, Void type options have no args (unless they're wrapper options).
} else if (nextArgs.hasNext()) {
- value = nextArgs.next(); // "--flag value" form
+ unparsedValue = nextArgs.next(); // "--flag value" form
} else {
throw new OptionsParsingException("Expected value after " + arg);
}
}
- return new ParseOptionResult(optionDefinition, value);
+ return new UnparsedOptionValueDescription(
+ optionDefinition,
+ unparsedValue,
+ priority,
+ sourceFunction.apply(optionDefinition),
+ explicit);
}
/**
diff --git a/src/main/java/com/google/devtools/common/options/OptionsUsage.java b/src/main/java/com/google/devtools/common/options/OptionsUsage.java
index 88da29f6cc..f481734097 100644
--- a/src/main/java/com/google/devtools/common/options/OptionsUsage.java
+++ b/src/main/java/com/google/devtools/common/options/OptionsUsage.java
@@ -168,7 +168,7 @@ class OptionsUsage {
String typeDescription = getTypeDescription(optionDefinition);
usage.append("<dt><code><a name=\"flag--").append(plainFlagName).append("\"></a>--");
usage.append(flagName);
- if (optionDefinition.isBooleanField() || optionDefinition.isVoidField()) {
+ if (optionDefinition.usesBooleanValueSyntax() || optionDefinition.isVoidField()) {
// Nothing for boolean, tristate, boolean_or_enum, or void options.
} else if (!valueDescription.isEmpty()) {
usage.append("=").append(escaper.escape(valueDescription));
@@ -285,6 +285,6 @@ class OptionsUsage {
static String getFlagName(OptionDefinition optionDefinition) {
String name = optionDefinition.getOptionName();
- return optionDefinition.isBooleanField() ? "[no]" + name : name;
+ return optionDefinition.usesBooleanValueSyntax() ? "[no]" + name : name;
}
}
diff --git a/src/main/java/com/google/devtools/common/options/UnparsedOptionValueDescription.java b/src/main/java/com/google/devtools/common/options/UnparsedOptionValueDescription.java
index 4f63d0d2bd..8cd858a8f9 100644
--- a/src/main/java/com/google/devtools/common/options/UnparsedOptionValueDescription.java
+++ b/src/main/java/com/google/devtools/common/options/UnparsedOptionValueDescription.java
@@ -18,37 +18,39 @@ import com.google.common.collect.ImmutableList;
import javax.annotation.Nullable;
/**
- * The name and unparsed value of an option with additional metadata describing its priority,
- * source, whether it was set via an implicit dependency, and if so, by which other option.
+ * The value of an option with additional metadata describing its origin.
*
- * <p>Note that the unparsed value and the source parameters can both be null.
+ * <p>This class represents an option as the parser received it, which is distinct from the final
+ * value of an option, as these values may be overridden or combined in some way.
+ *
+ * <p>The origin includes the value it was set to, its priority, a message about where it came
+ * from, and whether it was set explicitly or expanded/implied by other flags.
*/
public final class UnparsedOptionValueDescription {
-
private final OptionDefinition optionDefinition;
- @Nullable private final String unparsedValue;
+ @Nullable private final String unconvertedValue;
private final OptionPriority priority;
@Nullable private final String source;
+
+ // Whether this flag was explicitly given, as opposed to having been added by an expansion flag
+ // or an implicit dependency. Notice that this does NOT mean it was explicitly given by the
+ // user, for that to be true, it needs the right combination of explicit & priority.
private final boolean explicit;
public UnparsedOptionValueDescription(
OptionDefinition optionDefinition,
- @Nullable String unparsedValue,
+ @Nullable String unconvertedValue,
OptionPriority priority,
@Nullable String source,
boolean explicit) {
this.optionDefinition = optionDefinition;
- this.unparsedValue = unparsedValue;
+ this.unconvertedValue = unconvertedValue;
this.priority = priority;
this.source = source;
this.explicit = explicit;
}
- public String getName() {
- return optionDefinition.getOptionName();
- }
-
- OptionDefinition getOptionDefinition() {
+ public OptionDefinition getOptionDefinition() {
return optionDefinition;
}
@@ -81,8 +83,8 @@ public final class UnparsedOptionValueDescription {
return optionDefinition.getImplicitRequirements().length > 0;
}
- public String getUnparsedValue() {
- return unparsedValue;
+ public String getUnconvertedValue() {
+ return unconvertedValue;
}
OptionPriority getPriority() {
@@ -101,7 +103,7 @@ public final class UnparsedOptionValueDescription {
public String toString() {
StringBuilder result = new StringBuilder();
result.append("option '").append(optionDefinition.getOptionName()).append("' ");
- result.append("set to '").append(unparsedValue).append("' ");
+ result.append("set to '").append(unconvertedValue).append("' ");
result.append("with priority ").append(priority);
if (source != null) {
result.append(" and source '").append(source).append("'");
@@ -109,4 +111,3 @@ public final class UnparsedOptionValueDescription {
return result.toString();
}
}
-