function type_constant_from_ast()

in src/consumers/type_constant_from_ast.hack [15:40]


function type_constant_from_ast(
  ConsumerContext $context,
  HHAST\TypeConstDeclaration $node,
): ScannedTypeConstant {
  $is_abstract = C\any(
    $node->getModifiers()?->getChildren() ?? vec[],
    $t ==> $t is HHAST\AbstractToken,
  );
  return (
    new ScannedTypeConstant(
      $node,
      name_from_ast($node->getName()),
      context_with_node_position($context, $node)['definitionContext'],
      /* docblock = */ null,
      typehint_from_ast(
        $context,
        $is_abstract
          ? $node->getTypeConstraint()?->getType()
          : $node->getTypeSpecifier(),
      ),
      $is_abstract
        ? AbstractnessToken::IS_ABSTRACT
        : AbstractnessToken::NOT_ABSTRACT,
    )
  );
}