private function getHackAPILinks()

in src/build/UnifiedAPIIndexBuildStep.php [98:137]


  private function getHackAPILinks(
    APIProduct $product,
  ): ImmMap<string, string> {
    Log::v("\nProcessing %s API Index", $product);

    $out = Map {};
    $maybe_set = (string $name, string $url) ==> {
      if (
        (!C\contains_key($out, $name)) ||
        Str\length($out[$name]) > Str\length($url)
      ) {
        $out[$name] = $url;
      }
    };

    foreach (APIDefinitionType::getValues() as $type) {
      $defs = APIIndex::get($product)->getIndexForType($type);
      foreach ($defs as $_ => $def) {
        $name = $def['name'];
        $maybe_set($name, $def['urlPath']);

        if ($type === APIDefinitionType::FUNCTION_DEF) {
          continue;
        }

        $def = TypeAssert\matches_type_structure(
          type_alias_structure(APIClassIndexEntry::class),
          $def,
        );

        $methods = $def['methods'];

        foreach ($methods as $_ => $method) {
          $name = $method['className'].'::'.$method['name'];
          $maybe_set($name, $method['urlPath']);
        }
      }
    }
    return $out->toImmMap();
  }