Skip to content

Add ambiguity resolution policies #451

Description

@theron-wang

Consider using:

package org.checkerframework.specimin;

import com.google.common.base.Ascii;

/** Represents the different ambiguity resolution policies. */
public enum AmbiguityResolutionPolicy {
  /** Generates all alternates */
  All,
  /** Generates the best effort alternates */
  BestEffort,
  /** Outputs the best set of alternates based on an input condition */
  InputCondition;

  /**
   * Gets the corresponding ambiguity resolution policy based on the input. Throws if invalid.
   *
   * @param input The input; accepts all, best-effort, and input-condition.
   * @return The enum value, if valid, or else an exception
   */
  public static AmbiguityResolutionPolicy parse(String input) {
    return switch (Ascii.toLowerCase(input)) {
      case "all" -> AmbiguityResolutionPolicy.All;
      case "best-effort" -> AmbiguityResolutionPolicy.BestEffort;
      case "input-condition" -> AmbiguityResolutionPolicy.InputCondition;
      default ->
          throw new RuntimeException(
              "Unsupported ambiguity resolution policy. Options are: \"all\", \"best-effort\","
                  + " \"input-condition\"");
    };
  }
}

best-effort is Specimin's current behavior.

Modify UnsolvedSymbolEnumerator to add the other policies. Consider using JavaParserUtil#generateAllCombinations or a similar method to generate all combinations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions