Remove feature to allow expansion flags to have values.

It was added as a potential fix for --config (an expansion flag with values), but this would have required forcing the parser to know the config's expansions at parsing time, which is not currently possible. Instead, we will use the new addition of option-location tracking to make sure we expand options at a the correct place, even if the expansion is triggered after the fact.

This is mostly a straight forward undoing of https://github.com/bazelbuild/bazel/commit/7c7255ec8d6da20526c2c4078c57aadaf3dd3612, except where the context has changed. Notably, implicit requirements are effectively treated like expansion flags, so special casing in OptionDescription could be removed.

RELNOTES: None.
PiperOrigin-RevId: 172514997
diff --git a/src/test/java/com/google/devtools/common/options/TestOptions.java b/src/test/java/com/google/devtools/common/options/TestOptions.java
index fe7b8e0..2067b28 100644
--- a/src/test/java/com/google/devtools/common/options/TestOptions.java
+++ b/src/test/java/com/google/devtools/common/options/TestOptions.java
@@ -237,45 +237,12 @@
   )
   public String testRecursiveImplicitRequirement;
 
-  public static final String TEST_EXPANSION_FUNCTION_ACCEPTED_VALUE = "valueA";
-  public static final String EXPANDED_D_EXPANSION_FUNCTION_VALUE = "expanded valueA";
-
-  /*
-   * Expansion function flags
-   */
-
-  /** Used for testing an expansion flag that requires a value. */
-  public static class TestExpansionFunction implements ExpansionFunction {
-    @Override
-    public ImmutableList<String> getExpansion(ExpansionContext expansionContext)
-        throws OptionsParsingException {
-      String value = expansionContext.getUnparsedValue();
-      if (value == null) {
-        throw new ExpansionNeedsValueException("Expansion value not set.");
-      } else if (value.equals(TEST_EXPANSION_FUNCTION_ACCEPTED_VALUE)) {
-        return ImmutableList.of("--expanded_d", EXPANDED_D_EXPANSION_FUNCTION_VALUE);
-      } else {
-        throw new OptionsParsingException("Unrecognized expansion value: " + value);
-      }
-    }
-  }
-
-  @Option(
-    name = "test_expansion_function",
-    defaultValue = "null",
-    documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
-    effectTags = {OptionEffectTag.NO_OP},
-    expansionFunction = TestExpansionFunction.class,
-    help = "this is for testing expansion-by-function functionality."
-  )
-  public Void testExpansionFunction;
-
   public static final String EXPANDED_D_VOID_EXPANSION_FUNCTION_VALUE = "void expanded";
 
   /** Used for testing an expansion flag that doesn't requires a value. */
   public static class TestVoidExpansionFunction implements ExpansionFunction {
     @Override
-    public ImmutableList<String> getExpansion(ExpansionContext expansionContext) {
+    public ImmutableList<String> getExpansion(IsolatedOptionsData optionsData) {
       return ImmutableList.of("--expanded_d", EXPANDED_D_VOID_EXPANSION_FUNCTION_VALUE);
     }
   }
@@ -303,9 +270,9 @@
    */
   public static class ExpansionDependsOnOtherOptionDefinitions implements ExpansionFunction {
     @Override
-    public ImmutableList<String> getExpansion(ExpansionContext context) {
+    public ImmutableList<String> getExpansion(IsolatedOptionsData optionsData) {
       TreeSet<String> flags = new TreeSet<>();
-      for (Map.Entry<String, ?> entry : context.getOptionsData().getAllOptionDefinitions()) {
+      for (Map.Entry<String, ?> entry : optionsData.getAllOptionDefinitions()) {
         if (entry.getKey().startsWith("specialexp_")) {
           flags.add("--" + entry.getKey());
         }
@@ -324,36 +291,6 @@
   )
   public Void specialExp;
 
-  /**
-   * Defines an expansion function that adapts its expansion to the value assigned to the original
-   * expansion option.
-   */
-  public static class ExpansionDependsOnFlagValue implements ExpansionFunction {
-    @Override
-    public ImmutableList<String> getExpansion(ExpansionContext context)
-        throws OptionsParsingException {
-      String value = context.getUnparsedValue();
-      if (value == null) {
-        throw new ExpansionNeedsValueException("Expansion value not set.");
-      }
-      if (value.equals("foo_bar")) {
-        return ImmutableList.<String>of("--specialexp_foo", "--specialexp_bar");
-      }
-
-      throw new OptionsParsingException("Unexpected expansion argument: " + value);
-    }
-  }
-
-  @Option(
-    name = "dynamicexp",
-    documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
-    effectTags = {OptionEffectTag.NO_OP},
-    defaultValue = "null",
-    expansionFunction = ExpansionDependsOnFlagValue.class,
-    help = "Expands depending on the value provided."
-  )
-  public Void variableExpansion;
-
   @Option(
     name = "specialexp_foo",
     documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,