private function getXHPForNode()

in src/InspectorCLI.hack [205:255]


  private function getXHPForNode(
    HHAST\Node $node,
    vec<(HHAST\Node, arraykey)> $trace = vec[],
  ): x\node {
    $class = \get_class($node) |> Str\split($$, '\\') |> C\lastx($$);
    if ($node is HHAST\Trivia) {
      return
        <span
          id={'hs-id-'.$node->getUniqueID()}
          class={$this->getCSSClassesForTrace($trace, $node)}
          data-kind={$class}
          data-trace={$this->getDataForTrace($trace)}>
          {$node->getCode()}
        </span>;
    }

    if ($node is HHAST\Token) {
      return
        <x:frag>
          {
            $this->getXHPForNode(
              $node->getLeading(),
              Vec\concat($trace, vec[tuple($node, 'leading')]),
            )
          }
          <span
            id={'hs-id-'.$node->getUniqueID()}
            class={$this->getCSSClassesForTrace($trace, $node)}
            data-kind={$class}
            data-trace={$this->getDataForTrace($trace)}>
            {$node->getText()}
          </span>
          {
            $this->getXHPForNode(
              $node->getTrailing(),
              Vec\concat($trace, vec[tuple($node, 'trailing')]),
            )
          }
        </x:frag>;
    }

    return $node->getChildren()
      |> Dict\map_with_key(
        $$,
        ($key, $child) ==> $this->getXHPForNode(
          $child,
          Vec\concat($trace, vec[tuple($node, $key)]),
        ),
      )
      |> <x:frag>{$$}</x:frag>;
  }