codegen/syntax/EnumClassEnumerator.hack (260 lines of code) (raw):
/**
* This file is generated. Do not modify it manually!
*
* @generated SignedSource<<3fcdae586bf21cba57304c5d9792e15b>>
*/
namespace Facebook\HHAST;
use namespace Facebook\TypeAssert;
use namespace HH\Lib\Dict;
/* HHAST_IGNORE_ALL[5607] 5607 is ignored because of false positives when comparing a generic to a typed value */
/* HHAST_IGNORE_ALL[5624] HHAST_IGNORE_ALL[5639] 5624 and 5639 are ignored because they insist on using co(tra)variant generics. Could this break external consumers? */
<<__ConsistentConstruct>>
final class EnumClassEnumerator extends Node {
const string SYNTAX_KIND = 'enum_class_enumerator';
private ?NodeList<AbstractToken> $_modifiers;
private ISimpleCreationSpecifier $_type;
private NameToken $_name;
private ?SimpleInitializer $_initializer;
private SemicolonToken $_semicolon;
public function __construct(
?NodeList<AbstractToken> $modifiers,
ISimpleCreationSpecifier $type,
NameToken $name,
?SimpleInitializer $initializer,
SemicolonToken $semicolon,
?__Private\SourceRef $source_ref = null,
) {
$this->_modifiers = $modifiers;
$this->_type = $type;
$this->_name = $name;
$this->_initializer = $initializer;
$this->_semicolon = $semicolon;
parent::__construct($source_ref);
}
<<__Override>>
public static function fromJSON(
dict<arraykey, mixed> $json,
string $file,
int $initial_offset,
string $source,
string $_type_hint,
): this {
$offset = $initial_offset;
$modifiers = Node::fromJSON(
($json['enum_class_enumerator_modifiers'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'NodeList<AbstractToken>',
);
$offset += $modifiers?->getWidth() ?? 0;
$type = Node::fromJSON(
($json['enum_class_enumerator_type']) as dict<_, _>,
$file,
$offset,
$source,
'ISimpleCreationSpecifier',
);
$type = $type as nonnull;
$offset += $type->getWidth();
$name = Node::fromJSON(
($json['enum_class_enumerator_name']) as dict<_, _>,
$file,
$offset,
$source,
'NameToken',
);
$name = $name as nonnull;
$offset += $name->getWidth();
$initializer = Node::fromJSON(
($json['enum_class_enumerator_initializer'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'SimpleInitializer',
);
$offset += $initializer?->getWidth() ?? 0;
$semicolon = Node::fromJSON(
($json['enum_class_enumerator_semicolon']) as dict<_, _>,
$file,
$offset,
$source,
'SemicolonToken',
);
$semicolon = $semicolon as nonnull;
$offset += $semicolon->getWidth();
$source_ref = shape(
'file' => $file,
'source' => $source,
'offset' => $initial_offset,
'width' => $offset - $initial_offset,
);
return new static(
/* HH_IGNORE_ERROR[4110] */ $modifiers,
/* HH_IGNORE_ERROR[4110] */ $type,
/* HH_IGNORE_ERROR[4110] */ $name,
/* HH_IGNORE_ERROR[4110] */ $initializer,
/* HH_IGNORE_ERROR[4110] */ $semicolon,
$source_ref,
);
}
<<__Override>>
public function getChildren(): dict<string, Node> {
return dict[
'modifiers' => $this->_modifiers,
'type' => $this->_type,
'name' => $this->_name,
'initializer' => $this->_initializer,
'semicolon' => $this->_semicolon,
]
|> Dict\filter_nulls($$);
}
<<__Override>>
public function rewriteChildren<Tret as ?Node>(
(function(Node, vec<Node>): Tret) $rewriter,
vec<Node> $parents = vec[],
): this {
$parents[] = $this;
$modifiers = $this->_modifiers === null
? null
: $rewriter($this->_modifiers, $parents);
$type = $rewriter($this->_type, $parents);
$name = $rewriter($this->_name, $parents);
$initializer = $this->_initializer === null
? null
: $rewriter($this->_initializer, $parents);
$semicolon = $rewriter($this->_semicolon, $parents);
if (
$modifiers === $this->_modifiers &&
$type === $this->_type &&
$name === $this->_name &&
$initializer === $this->_initializer &&
$semicolon === $this->_semicolon
) {
return $this;
}
return new static(
/* HH_FIXME[4110] ?NodeList<AbstractToken> may not be enforceable */ $modifiers,
$type as ISimpleCreationSpecifier,
$name as NameToken,
$initializer as ?SimpleInitializer,
$semicolon as SemicolonToken,
);
}
public function getModifiersUNTYPED(): ?Node {
return $this->_modifiers;
}
public function withModifiers(?NodeList<AbstractToken> $value): this {
if ($value === $this->_modifiers) {
return $this;
}
return new static(
$value,
$this->_type,
$this->_name,
$this->_initializer,
$this->_semicolon,
);
}
public function hasModifiers(): bool {
return $this->_modifiers !== null;
}
/**
* @return NodeList<AbstractToken> | null
*/
public function getModifiers(): ?NodeList<AbstractToken> {
return $this->_modifiers;
}
/**
* @return NodeList<AbstractToken>
*/
public function getModifiersx(): NodeList<AbstractToken> {
return TypeAssert\not_null($this->getModifiers());
}
public function getTypeUNTYPED(): ?Node {
return $this->_type;
}
public function withType(ISimpleCreationSpecifier $value): this {
if ($value === $this->_type) {
return $this;
}
return new static(
$this->_modifiers,
$value,
$this->_name,
$this->_initializer,
$this->_semicolon,
);
}
public function hasType(): bool {
return true;
}
/**
* @return GenericTypeSpecifier | SimpleTypeSpecifier
*/
public function getType(): ISimpleCreationSpecifier {
return
TypeAssert\instance_of(ISimpleCreationSpecifier::class, $this->_type);
}
/**
* @return GenericTypeSpecifier | SimpleTypeSpecifier
*/
public function getTypex(): ISimpleCreationSpecifier {
return $this->getType();
}
public function getNameUNTYPED(): ?Node {
return $this->_name;
}
public function withName(NameToken $value): this {
if ($value === $this->_name) {
return $this;
}
return new static(
$this->_modifiers,
$this->_type,
$value,
$this->_initializer,
$this->_semicolon,
);
}
public function hasName(): bool {
return true;
}
/**
* @return NameToken
*/
public function getName(): NameToken {
return TypeAssert\instance_of(NameToken::class, $this->_name);
}
/**
* @return NameToken
*/
public function getNamex(): NameToken {
return $this->getName();
}
public function getInitializerUNTYPED(): ?Node {
return $this->_initializer;
}
public function withInitializer(?SimpleInitializer $value): this {
if ($value === $this->_initializer) {
return $this;
}
return new static(
$this->_modifiers,
$this->_type,
$this->_name,
$value,
$this->_semicolon,
);
}
public function hasInitializer(): bool {
return $this->_initializer !== null;
}
/**
* @return null | SimpleInitializer
*/
public function getInitializer(): ?SimpleInitializer {
return $this->_initializer;
}
/**
* @return SimpleInitializer
*/
public function getInitializerx(): SimpleInitializer {
return TypeAssert\not_null($this->getInitializer());
}
public function getSemicolonUNTYPED(): ?Node {
return $this->_semicolon;
}
public function withSemicolon(SemicolonToken $value): this {
if ($value === $this->_semicolon) {
return $this;
}
return new static(
$this->_modifiers,
$this->_type,
$this->_name,
$this->_initializer,
$value,
);
}
public function hasSemicolon(): bool {
return true;
}
/**
* @return SemicolonToken
*/
public function getSemicolon(): SemicolonToken {
return TypeAssert\instance_of(SemicolonToken::class, $this->_semicolon);
}
/**
* @return SemicolonToken
*/
public function getSemicolonx(): SemicolonToken {
return $this->getSemicolon();
}
}