private function getCSSClassesForTrace()

in src/InspectorCLI.hack [171:203]


  private function getCSSClassesForTrace(
    vec<(HHAST\Node, arraykey)> $trace,
    HHAST\Node $innermost,
  ): string {
    // This returns anything we might want for highlighting; this includes:
    // - selection highlighting for parent AST nodes. As the parent
    //   AST nodes do not have a DOM node, every DOM node that would be part of
    //   that AST node needs a class indicating that node
    // - selection highlighting for a particular AST field: this introduces the
    //   need for (id, field), including in parents
    // - syntax highlighting; this introduces the need for:
    //   - (class)
    //   - (class, field)
    $trace = Vec\map($trace, $entry ==> {
      list($node, $field) = $entry;
      $class = \get_class($node) |> Str\split($$, '\\') |> C\lastx($$);
      return Str\format(
        'hs-%s hs-%s-%s hs-id-%d hs-id-%d-%s',
        $class,
        $class,
        (string)$field,
        $node->getUniqueID(),
        $node->getUniqueID(),
        (string)$field,
      );
    });
    $trace[] = Str\format(
      'hs-%s hs-id-%d',
      \get_class($innermost) |> Str\split($$, '\\') |> C\lastx($$),
      $innermost->getUniqueID(),
    );
    return Str\join($trace, ' ');
  }