codegen/syntax/SwitchStatement.hack (353 lines of code) (raw):
/**
* This file is generated. Do not modify it manually!
*
* @generated SignedSource<<68cbbbb7f14b956ef08aa3fb1575c7db>>
*/
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 SwitchStatement
extends Node
implements IControlFlowStatement, IStatement {
const string SYNTAX_KIND = 'switch_statement';
private SwitchToken $_keyword;
private LeftParenToken $_left_paren;
private IExpression $_expression;
private RightParenToken $_right_paren;
private LeftBraceToken $_left_brace;
private NodeList<SwitchSection> $_sections;
private RightBraceToken $_right_brace;
public function __construct(
SwitchToken $keyword,
LeftParenToken $left_paren,
IExpression $expression,
RightParenToken $right_paren,
LeftBraceToken $left_brace,
NodeList<SwitchSection> $sections,
RightBraceToken $right_brace,
?__Private\SourceRef $source_ref = null,
) {
$this->_keyword = $keyword;
$this->_left_paren = $left_paren;
$this->_expression = $expression;
$this->_right_paren = $right_paren;
$this->_left_brace = $left_brace;
$this->_sections = $sections;
$this->_right_brace = $right_brace;
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;
$keyword = Node::fromJSON(
($json['switch_keyword']) as dict<_, _>,
$file,
$offset,
$source,
'SwitchToken',
);
$keyword = $keyword as nonnull;
$offset += $keyword->getWidth();
$left_paren = Node::fromJSON(
($json['switch_left_paren']) as dict<_, _>,
$file,
$offset,
$source,
'LeftParenToken',
);
$left_paren = $left_paren as nonnull;
$offset += $left_paren->getWidth();
$expression = Node::fromJSON(
($json['switch_expression']) as dict<_, _>,
$file,
$offset,
$source,
'IExpression',
);
$expression = $expression as nonnull;
$offset += $expression->getWidth();
$right_paren = Node::fromJSON(
($json['switch_right_paren']) as dict<_, _>,
$file,
$offset,
$source,
'RightParenToken',
);
$right_paren = $right_paren as nonnull;
$offset += $right_paren->getWidth();
$left_brace = Node::fromJSON(
($json['switch_left_brace']) as dict<_, _>,
$file,
$offset,
$source,
'LeftBraceToken',
);
$left_brace = $left_brace as nonnull;
$offset += $left_brace->getWidth();
$sections = Node::fromJSON(
($json['switch_sections']) as dict<_, _>,
$file,
$offset,
$source,
'NodeList<SwitchSection>',
);
$sections = $sections as nonnull;
$offset += $sections->getWidth();
$right_brace = Node::fromJSON(
($json['switch_right_brace']) as dict<_, _>,
$file,
$offset,
$source,
'RightBraceToken',
);
$right_brace = $right_brace as nonnull;
$offset += $right_brace->getWidth();
$source_ref = shape(
'file' => $file,
'source' => $source,
'offset' => $initial_offset,
'width' => $offset - $initial_offset,
);
return new static(
/* HH_IGNORE_ERROR[4110] */ $keyword,
/* HH_IGNORE_ERROR[4110] */ $left_paren,
/* HH_IGNORE_ERROR[4110] */ $expression,
/* HH_IGNORE_ERROR[4110] */ $right_paren,
/* HH_IGNORE_ERROR[4110] */ $left_brace,
/* HH_IGNORE_ERROR[4110] */ $sections,
/* HH_IGNORE_ERROR[4110] */ $right_brace,
$source_ref,
);
}
<<__Override>>
public function getChildren(): dict<string, Node> {
return dict[
'keyword' => $this->_keyword,
'left_paren' => $this->_left_paren,
'expression' => $this->_expression,
'right_paren' => $this->_right_paren,
'left_brace' => $this->_left_brace,
'sections' => $this->_sections,
'right_brace' => $this->_right_brace,
]
|> Dict\filter_nulls($$);
}
<<__Override>>
public function rewriteChildren<Tret as ?Node>(
(function(Node, vec<Node>): Tret) $rewriter,
vec<Node> $parents = vec[],
): this {
$parents[] = $this;
$keyword = $rewriter($this->_keyword, $parents);
$left_paren = $rewriter($this->_left_paren, $parents);
$expression = $rewriter($this->_expression, $parents);
$right_paren = $rewriter($this->_right_paren, $parents);
$left_brace = $rewriter($this->_left_brace, $parents);
$sections = $rewriter($this->_sections, $parents);
$right_brace = $rewriter($this->_right_brace, $parents);
if (
$keyword === $this->_keyword &&
$left_paren === $this->_left_paren &&
$expression === $this->_expression &&
$right_paren === $this->_right_paren &&
$left_brace === $this->_left_brace &&
$sections === $this->_sections &&
$right_brace === $this->_right_brace
) {
return $this;
}
return new static(
$keyword as SwitchToken,
$left_paren as LeftParenToken,
$expression as IExpression,
$right_paren as RightParenToken,
$left_brace as LeftBraceToken,
/* HH_FIXME[4110] NodeList<SwitchSection> may not be enforceable */ $sections,
$right_brace as RightBraceToken,
);
}
public function getKeywordUNTYPED(): ?Node {
return $this->_keyword;
}
public function withKeyword(SwitchToken $value): this {
if ($value === $this->_keyword) {
return $this;
}
return new static(
$value,
$this->_left_paren,
$this->_expression,
$this->_right_paren,
$this->_left_brace,
$this->_sections,
$this->_right_brace,
);
}
public function hasKeyword(): bool {
return true;
}
/**
* @return SwitchToken
*/
public function getKeyword(): SwitchToken {
return TypeAssert\instance_of(SwitchToken::class, $this->_keyword);
}
/**
* @return SwitchToken
*/
public function getKeywordx(): SwitchToken {
return $this->getKeyword();
}
public function getLeftParenUNTYPED(): ?Node {
return $this->_left_paren;
}
public function withLeftParen(LeftParenToken $value): this {
if ($value === $this->_left_paren) {
return $this;
}
return new static(
$this->_keyword,
$value,
$this->_expression,
$this->_right_paren,
$this->_left_brace,
$this->_sections,
$this->_right_brace,
);
}
public function hasLeftParen(): bool {
return true;
}
/**
* @return LeftParenToken
*/
public function getLeftParen(): LeftParenToken {
return TypeAssert\instance_of(LeftParenToken::class, $this->_left_paren);
}
/**
* @return LeftParenToken
*/
public function getLeftParenx(): LeftParenToken {
return $this->getLeftParen();
}
public function getExpressionUNTYPED(): ?Node {
return $this->_expression;
}
public function withExpression(IExpression $value): this {
if ($value === $this->_expression) {
return $this;
}
return new static(
$this->_keyword,
$this->_left_paren,
$value,
$this->_right_paren,
$this->_left_brace,
$this->_sections,
$this->_right_brace,
);
}
public function hasExpression(): bool {
return true;
}
/**
* @return BinaryExpression | CastExpression | FunctionCallExpression |
* LiteralExpression | MemberSelectionExpression | ObjectCreationExpression |
* PrefixUnaryExpression | SubscriptExpression | VariableExpression
*/
public function getExpression(): IExpression {
return TypeAssert\instance_of(IExpression::class, $this->_expression);
}
/**
* @return BinaryExpression | CastExpression | FunctionCallExpression |
* LiteralExpression | MemberSelectionExpression | ObjectCreationExpression |
* PrefixUnaryExpression | SubscriptExpression | VariableExpression
*/
public function getExpressionx(): IExpression {
return $this->getExpression();
}
public function getRightParenUNTYPED(): ?Node {
return $this->_right_paren;
}
public function withRightParen(RightParenToken $value): this {
if ($value === $this->_right_paren) {
return $this;
}
return new static(
$this->_keyword,
$this->_left_paren,
$this->_expression,
$value,
$this->_left_brace,
$this->_sections,
$this->_right_brace,
);
}
public function hasRightParen(): bool {
return true;
}
/**
* @return RightParenToken
*/
public function getRightParen(): RightParenToken {
return TypeAssert\instance_of(RightParenToken::class, $this->_right_paren);
}
/**
* @return RightParenToken
*/
public function getRightParenx(): RightParenToken {
return $this->getRightParen();
}
public function getLeftBraceUNTYPED(): ?Node {
return $this->_left_brace;
}
public function withLeftBrace(LeftBraceToken $value): this {
if ($value === $this->_left_brace) {
return $this;
}
return new static(
$this->_keyword,
$this->_left_paren,
$this->_expression,
$this->_right_paren,
$value,
$this->_sections,
$this->_right_brace,
);
}
public function hasLeftBrace(): bool {
return true;
}
/**
* @return LeftBraceToken
*/
public function getLeftBrace(): LeftBraceToken {
return TypeAssert\instance_of(LeftBraceToken::class, $this->_left_brace);
}
/**
* @return LeftBraceToken
*/
public function getLeftBracex(): LeftBraceToken {
return $this->getLeftBrace();
}
public function getSectionsUNTYPED(): ?Node {
return $this->_sections;
}
public function withSections(NodeList<SwitchSection> $value): this {
if ($value === $this->_sections) {
return $this;
}
return new static(
$this->_keyword,
$this->_left_paren,
$this->_expression,
$this->_right_paren,
$this->_left_brace,
$value,
$this->_right_brace,
);
}
public function hasSections(): bool {
return true;
}
/**
* @return NodeList<SwitchSection>
*/
public function getSections(): NodeList<SwitchSection> {
return TypeAssert\instance_of(NodeList::class, $this->_sections);
}
/**
* @return NodeList<SwitchSection>
*/
public function getSectionsx(): NodeList<SwitchSection> {
return $this->getSections();
}
public function getRightBraceUNTYPED(): ?Node {
return $this->_right_brace;
}
public function withRightBrace(RightBraceToken $value): this {
if ($value === $this->_right_brace) {
return $this;
}
return new static(
$this->_keyword,
$this->_left_paren,
$this->_expression,
$this->_right_paren,
$this->_left_brace,
$this->_sections,
$value,
);
}
public function hasRightBrace(): bool {
return true;
}
/**
* @return RightBraceToken
*/
public function getRightBrace(): RightBraceToken {
return TypeAssert\instance_of(RightBraceToken::class, $this->_right_brace);
}
/**
* @return RightBraceToken
*/
public function getRightBracex(): RightBraceToken {
return $this->getRightBrace();
}
}