-
Notifications
You must be signed in to change notification settings - Fork 42
/
ClassishDeclaration.hack
811 lines (743 loc) · 20.9 KB
/
ClassishDeclaration.hack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
/**
* This file is generated. Do not modify it manually!
*
* @generated SignedSource<<efaed262dbcaf1bee37262fcfc534a14>>
*/
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 ClassishDeclaration
extends Node
implements IDeclaration, IHasAttributeSpec {
use AttributeAsAttributeSpecTrait;
const string SYNTAX_KIND = 'classish_declaration';
private ?OldAttributeSpecification $_attribute;
private ?NodeList<Token> $_modifiers;
private ?Node $_xhp;
private Token $_keyword;
private Token $_name;
private ?TypeParameters $_type_parameters;
private ?ExtendsToken $_extends_keyword;
private ?NodeList<ListItem<ISimpleCreationSpecifier>> $_extends_list;
private ?ImplementsToken $_implements_keyword;
private ?NodeList<ListItem<ISimpleCreationSpecifier>> $_implements_list;
private ?Node $_where_clause;
private ClassishBody $_body;
public function __construct(
?OldAttributeSpecification $attribute,
?NodeList<Token> $modifiers,
?Node $xhp,
Token $keyword,
Token $name,
?TypeParameters $type_parameters,
?ExtendsToken $extends_keyword,
?NodeList<ListItem<ISimpleCreationSpecifier>> $extends_list,
?ImplementsToken $implements_keyword,
?NodeList<ListItem<ISimpleCreationSpecifier>> $implements_list,
?Node $where_clause,
ClassishBody $body,
?__Private\SourceRef $source_ref = null,
) {
$this->_attribute = $attribute;
$this->_modifiers = $modifiers;
$this->_xhp = $xhp;
$this->_keyword = $keyword;
$this->_name = $name;
$this->_type_parameters = $type_parameters;
$this->_extends_keyword = $extends_keyword;
$this->_extends_list = $extends_list;
$this->_implements_keyword = $implements_keyword;
$this->_implements_list = $implements_list;
$this->_where_clause = $where_clause;
$this->_body = $body;
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;
$attribute = Node::fromJSON(
($json['classish_attribute'] ?? dict['kind' => 'missing']) as dict<_, _>,
$file,
$offset,
$source,
'OldAttributeSpecification',
);
$offset += $attribute?->getWidth() ?? 0;
$modifiers = Node::fromJSON(
($json['classish_modifiers'] ?? dict['kind' => 'missing']) as dict<_, _>,
$file,
$offset,
$source,
'NodeList<Token>',
);
$offset += $modifiers?->getWidth() ?? 0;
$xhp = Node::fromJSON(
($json['classish_xhp'] ?? dict['kind' => 'missing']) as dict<_, _>,
$file,
$offset,
$source,
'Node',
);
$offset += $xhp?->getWidth() ?? 0;
$keyword = Node::fromJSON(
($json['classish_keyword']) as dict<_, _>,
$file,
$offset,
$source,
'Token',
);
$keyword = $keyword as nonnull;
$offset += $keyword->getWidth();
$name = Node::fromJSON(
($json['classish_name']) as dict<_, _>,
$file,
$offset,
$source,
'Token',
);
$name = $name as nonnull;
$offset += $name->getWidth();
$type_parameters = Node::fromJSON(
($json['classish_type_parameters'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'TypeParameters',
);
$offset += $type_parameters?->getWidth() ?? 0;
$extends_keyword = Node::fromJSON(
($json['classish_extends_keyword'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'ExtendsToken',
);
$offset += $extends_keyword?->getWidth() ?? 0;
$extends_list = Node::fromJSON(
($json['classish_extends_list'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'NodeList<ListItem<ISimpleCreationSpecifier>>',
);
$offset += $extends_list?->getWidth() ?? 0;
$implements_keyword = Node::fromJSON(
($json['classish_implements_keyword'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'ImplementsToken',
);
$offset += $implements_keyword?->getWidth() ?? 0;
$implements_list = Node::fromJSON(
($json['classish_implements_list'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'NodeList<ListItem<ISimpleCreationSpecifier>>',
);
$offset += $implements_list?->getWidth() ?? 0;
$where_clause = Node::fromJSON(
($json['classish_where_clause'] ?? dict['kind' => 'missing'])
as dict<_, _>,
$file,
$offset,
$source,
'Node',
);
$offset += $where_clause?->getWidth() ?? 0;
$body = Node::fromJSON(
($json['classish_body']) as dict<_, _>,
$file,
$offset,
$source,
'ClassishBody',
);
$body = $body as nonnull;
$offset += $body->getWidth();
$source_ref = shape(
'file' => $file,
'source' => $source,
'offset' => $initial_offset,
'width' => $offset - $initial_offset,
);
return new static(
/* HH_IGNORE_ERROR[4110] */ $attribute,
/* HH_IGNORE_ERROR[4110] */ $modifiers,
/* HH_IGNORE_ERROR[4110] */ $xhp,
/* HH_IGNORE_ERROR[4110] */ $keyword,
/* HH_IGNORE_ERROR[4110] */ $name,
/* HH_IGNORE_ERROR[4110] */ $type_parameters,
/* HH_IGNORE_ERROR[4110] */ $extends_keyword,
/* HH_IGNORE_ERROR[4110] */ $extends_list,
/* HH_IGNORE_ERROR[4110] */ $implements_keyword,
/* HH_IGNORE_ERROR[4110] */ $implements_list,
/* HH_IGNORE_ERROR[4110] */ $where_clause,
/* HH_IGNORE_ERROR[4110] */ $body,
$source_ref,
);
}
<<__Override>>
public function getChildren(): dict<string, Node> {
return dict[
'attribute' => $this->_attribute,
'modifiers' => $this->_modifiers,
'xhp' => $this->_xhp,
'keyword' => $this->_keyword,
'name' => $this->_name,
'type_parameters' => $this->_type_parameters,
'extends_keyword' => $this->_extends_keyword,
'extends_list' => $this->_extends_list,
'implements_keyword' => $this->_implements_keyword,
'implements_list' => $this->_implements_list,
'where_clause' => $this->_where_clause,
'body' => $this->_body,
]
|> Dict\filter_nulls($$);
}
<<__Override>>
public function rewriteChildren<Tret as ?Node>(
(function(Node, vec<Node>): Tret) $rewriter,
vec<Node> $parents = vec[],
): this {
$parents[] = $this;
$attribute = $this->_attribute === null
? null
: $rewriter($this->_attribute, $parents);
$modifiers = $this->_modifiers === null
? null
: $rewriter($this->_modifiers, $parents);
$xhp = $this->_xhp === null ? null : $rewriter($this->_xhp, $parents);
$keyword = $rewriter($this->_keyword, $parents);
$name = $rewriter($this->_name, $parents);
$type_parameters = $this->_type_parameters === null
? null
: $rewriter($this->_type_parameters, $parents);
$extends_keyword = $this->_extends_keyword === null
? null
: $rewriter($this->_extends_keyword, $parents);
$extends_list = $this->_extends_list === null
? null
: $rewriter($this->_extends_list, $parents);
$implements_keyword = $this->_implements_keyword === null
? null
: $rewriter($this->_implements_keyword, $parents);
$implements_list = $this->_implements_list === null
? null
: $rewriter($this->_implements_list, $parents);
$where_clause = $this->_where_clause === null
? null
: $rewriter($this->_where_clause, $parents);
$body = $rewriter($this->_body, $parents);
if (
$attribute === $this->_attribute &&
$modifiers === $this->_modifiers &&
$xhp === $this->_xhp &&
$keyword === $this->_keyword &&
$name === $this->_name &&
$type_parameters === $this->_type_parameters &&
$extends_keyword === $this->_extends_keyword &&
$extends_list === $this->_extends_list &&
$implements_keyword === $this->_implements_keyword &&
$implements_list === $this->_implements_list &&
$where_clause === $this->_where_clause &&
$body === $this->_body
) {
return $this;
}
return new static(
$attribute as ?OldAttributeSpecification,
/* HH_FIXME[4110] ?NodeList<Token> may not be enforceable */ $modifiers,
$xhp as ?Node,
$keyword as Token,
$name as Token,
$type_parameters as ?TypeParameters,
$extends_keyword as ?ExtendsToken,
/* HH_FIXME[4110] ?NodeList<ListItem<ISimpleCreationSpecifier>> may not be enforceable */ $extends_list,
$implements_keyword as ?ImplementsToken,
/* HH_FIXME[4110] ?NodeList<ListItem<ISimpleCreationSpecifier>> may not be enforceable */ $implements_list,
$where_clause as ?Node,
$body as ClassishBody,
);
}
<<__Override>>
public function getAttributeUNTYPED(): ?Node {
return $this->_attribute;
}
public function withAttribute(?OldAttributeSpecification $value): this {
if ($value === $this->_attribute) {
return $this;
}
return new static(
$value,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
<<__Override>>
public function hasAttribute(): bool {
return $this->_attribute !== null;
}
/**
* @return null | OldAttributeSpecification
*/
<<__Override>>
public function getAttribute(): ?OldAttributeSpecification {
return $this->_attribute;
}
/**
* @return OldAttributeSpecification
*/
<<__Override>>
public function getAttributex(): OldAttributeSpecification {
return TypeAssert\not_null($this->getAttribute());
}
public function getModifiersUNTYPED(): ?Node {
return $this->_modifiers;
}
public function withModifiers(?NodeList<Token> $value): this {
if ($value === $this->_modifiers) {
return $this;
}
return new static(
$this->_attribute,
$value,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasModifiers(): bool {
return $this->_modifiers !== null;
}
/**
* @return NodeList<AbstractToken> | NodeList<Token> | NodeList<FinalToken> |
* NodeList<InternalToken> | NodeList<PublicToken> | null
*/
public function getModifiers(): ?NodeList<Token> {
return $this->_modifiers;
}
/**
* @return NodeList<AbstractToken> | NodeList<Token> | NodeList<FinalToken> |
* NodeList<InternalToken> | NodeList<PublicToken>
*/
public function getModifiersx(): NodeList<Token> {
return TypeAssert\not_null($this->getModifiers());
}
public function getXhpUNTYPED(): ?Node {
return $this->_xhp;
}
public function withXhp(?Node $value): this {
if ($value === $this->_xhp) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$value,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasXhp(): bool {
return $this->_xhp !== null;
}
/**
* @return null
*/
public function getXhp(): ?Node {
return $this->_xhp;
}
/**
* @return
*/
public function getXhpx(): Node {
return TypeAssert\not_null($this->getXhp());
}
public function getKeywordUNTYPED(): ?Node {
return $this->_keyword;
}
public function withKeyword(Token $value): this {
if ($value === $this->_keyword) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$value,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasKeyword(): bool {
return true;
}
/**
* @return ClassToken | InterfaceToken | TraitToken
*/
public function getKeyword(): Token {
return TypeAssert\instance_of(Token::class, $this->_keyword);
}
/**
* @return ClassToken | InterfaceToken | TraitToken
*/
public function getKeywordx(): Token {
return $this->getKeyword();
}
public function getNameUNTYPED(): ?Node {
return $this->_name;
}
public function withName(Token $value): this {
if ($value === $this->_name) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$value,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasName(): bool {
return true;
}
/**
* @return XHPClassNameToken | NameToken
*/
public function getName(): Token {
return TypeAssert\instance_of(Token::class, $this->_name);
}
/**
* @return XHPClassNameToken | NameToken
*/
public function getNamex(): Token {
return $this->getName();
}
public function getTypeParametersUNTYPED(): ?Node {
return $this->_type_parameters;
}
public function withTypeParameters(?TypeParameters $value): this {
if ($value === $this->_type_parameters) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$value,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasTypeParameters(): bool {
return $this->_type_parameters !== null;
}
/**
* @return null | TypeParameters
*/
public function getTypeParameters(): ?TypeParameters {
return $this->_type_parameters;
}
/**
* @return TypeParameters
*/
public function getTypeParametersx(): TypeParameters {
return TypeAssert\not_null($this->getTypeParameters());
}
public function getExtendsKeywordUNTYPED(): ?Node {
return $this->_extends_keyword;
}
public function withExtendsKeyword(?ExtendsToken $value): this {
if ($value === $this->_extends_keyword) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$value,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasExtendsKeyword(): bool {
return $this->_extends_keyword !== null;
}
/**
* @return null | ExtendsToken
*/
public function getExtendsKeyword(): ?ExtendsToken {
return $this->_extends_keyword;
}
/**
* @return ExtendsToken
*/
public function getExtendsKeywordx(): ExtendsToken {
return TypeAssert\not_null($this->getExtendsKeyword());
}
public function getExtendsListUNTYPED(): ?Node {
return $this->_extends_list;
}
public function withExtendsList(
?NodeList<ListItem<ISimpleCreationSpecifier>> $value,
): this {
if ($value === $this->_extends_list) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$value,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasExtendsList(): bool {
return $this->_extends_list !== null;
}
/**
* @return NodeList<ListItem<GenericTypeSpecifier>> |
* NodeList<ListItem<ISimpleCreationSpecifier>> |
* NodeList<ListItem<SimpleTypeSpecifier>> | null
*/
public function getExtendsList(
): ?NodeList<ListItem<ISimpleCreationSpecifier>> {
return $this->_extends_list;
}
/**
* @return NodeList<ListItem<GenericTypeSpecifier>> |
* NodeList<ListItem<ISimpleCreationSpecifier>> |
* NodeList<ListItem<SimpleTypeSpecifier>>
*/
public function getExtendsListx(
): NodeList<ListItem<ISimpleCreationSpecifier>> {
return TypeAssert\not_null($this->getExtendsList());
}
public function getImplementsKeywordUNTYPED(): ?Node {
return $this->_implements_keyword;
}
public function withImplementsKeyword(?ImplementsToken $value): this {
if ($value === $this->_implements_keyword) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$value,
$this->_implements_list,
$this->_where_clause,
$this->_body,
);
}
public function hasImplementsKeyword(): bool {
return $this->_implements_keyword !== null;
}
/**
* @return null | ImplementsToken
*/
public function getImplementsKeyword(): ?ImplementsToken {
return $this->_implements_keyword;
}
/**
* @return ImplementsToken
*/
public function getImplementsKeywordx(): ImplementsToken {
return TypeAssert\not_null($this->getImplementsKeyword());
}
public function getImplementsListUNTYPED(): ?Node {
return $this->_implements_list;
}
public function withImplementsList(
?NodeList<ListItem<ISimpleCreationSpecifier>> $value,
): this {
if ($value === $this->_implements_list) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$value,
$this->_where_clause,
$this->_body,
);
}
public function hasImplementsList(): bool {
return $this->_implements_list !== null;
}
/**
* @return NodeList<ListItem<GenericTypeSpecifier>> |
* NodeList<ListItem<ISimpleCreationSpecifier>> |
* NodeList<ListItem<SimpleTypeSpecifier>> | null
*/
public function getImplementsList(
): ?NodeList<ListItem<ISimpleCreationSpecifier>> {
return $this->_implements_list;
}
/**
* @return NodeList<ListItem<GenericTypeSpecifier>> |
* NodeList<ListItem<ISimpleCreationSpecifier>> |
* NodeList<ListItem<SimpleTypeSpecifier>>
*/
public function getImplementsListx(
): NodeList<ListItem<ISimpleCreationSpecifier>> {
return TypeAssert\not_null($this->getImplementsList());
}
public function getWhereClauseUNTYPED(): ?Node {
return $this->_where_clause;
}
public function withWhereClause(?Node $value): this {
if ($value === $this->_where_clause) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$value,
$this->_body,
);
}
public function hasWhereClause(): bool {
return $this->_where_clause !== null;
}
/**
* @return null
*/
public function getWhereClause(): ?Node {
return $this->_where_clause;
}
/**
* @return
*/
public function getWhereClausex(): Node {
return TypeAssert\not_null($this->getWhereClause());
}
public function getBodyUNTYPED(): ?Node {
return $this->_body;
}
public function withBody(ClassishBody $value): this {
if ($value === $this->_body) {
return $this;
}
return new static(
$this->_attribute,
$this->_modifiers,
$this->_xhp,
$this->_keyword,
$this->_name,
$this->_type_parameters,
$this->_extends_keyword,
$this->_extends_list,
$this->_implements_keyword,
$this->_implements_list,
$this->_where_clause,
$value,
);
}
public function hasBody(): bool {
return true;
}
/**
* @return ClassishBody
*/
public function getBody(): ClassishBody {
return TypeAssert\instance_of(ClassishBody::class, $this->_body);
}
/**
* @return ClassishBody
*/
public function getBodyx(): ClassishBody {
return $this->getBody();
}
}