@herb-tools/core 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/herb-core.browser.js +1223 -432
- package/dist/herb-core.browser.js.map +1 -1
- package/dist/herb-core.cjs +1314 -432
- package/dist/herb-core.cjs.map +1 -1
- package/dist/herb-core.esm.js +1223 -432
- package/dist/herb-core.esm.js.map +1 -1
- package/dist/herb-core.umd.js +1314 -432
- package/dist/herb-core.umd.js.map +1 -1
- package/dist/types/ast-utils.d.ts +74 -0
- package/dist/types/backend.d.ts +2 -1
- package/dist/types/herb-backend.d.ts +3 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/node-type-guards.d.ts +434 -0
- package/dist/types/nodes.d.ts +149 -97
- package/dist/types/parser-options.d.ts +4 -0
- package/dist/types/visitor.d.ts +3 -2
- package/package.json +1 -1
- package/src/ast-utils.ts +191 -0
- package/src/backend.ts +2 -1
- package/src/errors.ts +1 -1
- package/src/herb-backend.ts +7 -2
- package/src/index.ts +3 -0
- package/src/node-type-guards.ts +876 -0
- package/src/nodes.ts +300 -251
- package/src/parser-options.ts +7 -0
- package/src/visitor.ts +11 -6
package/src/nodes.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/nodes.ts.erb
|
|
3
3
|
|
|
4
4
|
import { Location } from "./location.js"
|
|
5
5
|
import { Token, SerializedToken } from "./token.js"
|
|
@@ -183,8 +183,6 @@ export class DocumentNode extends Node {
|
|
|
183
183
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
184
184
|
output += `└── children: ${this.inspectArray(this.children, " ")}`;
|
|
185
185
|
|
|
186
|
-
// output += "\n";
|
|
187
|
-
|
|
188
186
|
return output
|
|
189
187
|
}
|
|
190
188
|
}
|
|
@@ -249,8 +247,6 @@ export class LiteralNode extends Node {
|
|
|
249
247
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
250
248
|
output += `└── content: ${this.content ? JSON.stringify(this.content) : "∅"}\n`;
|
|
251
249
|
|
|
252
|
-
// output += "\n";
|
|
253
|
-
|
|
254
250
|
return output
|
|
255
251
|
}
|
|
256
252
|
}
|
|
@@ -345,8 +341,6 @@ export class HTMLOpenTagNode extends Node {
|
|
|
345
341
|
output += `├── children: ${this.inspectArray(this.children, "│ ")}`;
|
|
346
342
|
output += `└── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`;
|
|
347
343
|
|
|
348
|
-
// output += "\n";
|
|
349
|
-
|
|
350
344
|
return output
|
|
351
345
|
}
|
|
352
346
|
}
|
|
@@ -355,18 +349,21 @@ export interface SerializedHTMLCloseTagNode extends SerializedNode {
|
|
|
355
349
|
type: "AST_HTML_CLOSE_TAG_NODE";
|
|
356
350
|
tag_opening: SerializedToken | null;
|
|
357
351
|
tag_name: SerializedToken | null;
|
|
352
|
+
children: SerializedNode[];
|
|
358
353
|
tag_closing: SerializedToken | null;
|
|
359
354
|
}
|
|
360
355
|
|
|
361
356
|
export interface HTMLCloseTagNodeProps extends BaseNodeProps {
|
|
362
357
|
tag_opening: Token | null;
|
|
363
358
|
tag_name: Token | null;
|
|
359
|
+
children: Node[];
|
|
364
360
|
tag_closing: Token | null;
|
|
365
361
|
}
|
|
366
362
|
|
|
367
363
|
export class HTMLCloseTagNode extends Node {
|
|
368
364
|
readonly tag_opening: Token | null;
|
|
369
365
|
readonly tag_name: Token | null;
|
|
366
|
+
readonly children: Node[];
|
|
370
367
|
readonly tag_closing: Token | null;
|
|
371
368
|
|
|
372
369
|
static from(data: SerializedHTMLCloseTagNode): HTMLCloseTagNode {
|
|
@@ -376,6 +373,7 @@ export class HTMLCloseTagNode extends Node {
|
|
|
376
373
|
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
377
374
|
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
378
375
|
tag_name: data.tag_name ? Token.from(data.tag_name) : null,
|
|
376
|
+
children: (data.children || []).map(node => fromSerializedNode(node)),
|
|
379
377
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
380
378
|
})
|
|
381
379
|
}
|
|
@@ -384,6 +382,7 @@ export class HTMLCloseTagNode extends Node {
|
|
|
384
382
|
super(props.type, props.location, props.errors);
|
|
385
383
|
this.tag_opening = props.tag_opening;
|
|
386
384
|
this.tag_name = props.tag_name;
|
|
385
|
+
this.children = props.children;
|
|
387
386
|
this.tag_closing = props.tag_closing;
|
|
388
387
|
}
|
|
389
388
|
|
|
@@ -393,6 +392,7 @@ export class HTMLCloseTagNode extends Node {
|
|
|
393
392
|
|
|
394
393
|
childNodes(): (Node | null | undefined)[] {
|
|
395
394
|
return [
|
|
395
|
+
...this.children,
|
|
396
396
|
];
|
|
397
397
|
}
|
|
398
398
|
|
|
@@ -403,6 +403,7 @@ export class HTMLCloseTagNode extends Node {
|
|
|
403
403
|
recursiveErrors(): HerbError[] {
|
|
404
404
|
return [
|
|
405
405
|
...this.errors,
|
|
406
|
+
...this.children.map(node => node.recursiveErrors()),
|
|
406
407
|
].flat();
|
|
407
408
|
}
|
|
408
409
|
|
|
@@ -412,6 +413,7 @@ export class HTMLCloseTagNode extends Node {
|
|
|
412
413
|
type: "AST_HTML_CLOSE_TAG_NODE",
|
|
413
414
|
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
414
415
|
tag_name: this.tag_name ? this.tag_name.toJSON() : null,
|
|
416
|
+
children: this.children.map(node => node.toJSON()),
|
|
415
417
|
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
416
418
|
};
|
|
417
419
|
}
|
|
@@ -423,132 +425,35 @@ export class HTMLCloseTagNode extends Node {
|
|
|
423
425
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
424
426
|
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
425
427
|
output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`;
|
|
428
|
+
output += `├── children: ${this.inspectArray(this.children, "│ ")}`;
|
|
426
429
|
output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
427
430
|
|
|
428
|
-
// output += "\n";
|
|
429
|
-
|
|
430
|
-
return output
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
export interface SerializedHTMLSelfCloseTagNode extends SerializedNode {
|
|
435
|
-
type: "AST_HTML_SELF_CLOSE_TAG_NODE";
|
|
436
|
-
tag_opening: SerializedToken | null;
|
|
437
|
-
tag_name: SerializedToken | null;
|
|
438
|
-
attributes: SerializedNode[];
|
|
439
|
-
tag_closing: SerializedToken | null;
|
|
440
|
-
is_void: boolean;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
export interface HTMLSelfCloseTagNodeProps extends BaseNodeProps {
|
|
444
|
-
tag_opening: Token | null;
|
|
445
|
-
tag_name: Token | null;
|
|
446
|
-
attributes: any[];
|
|
447
|
-
tag_closing: Token | null;
|
|
448
|
-
is_void: boolean;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
export class HTMLSelfCloseTagNode extends Node {
|
|
452
|
-
readonly tag_opening: Token | null;
|
|
453
|
-
readonly tag_name: Token | null;
|
|
454
|
-
readonly attributes: any[];
|
|
455
|
-
readonly tag_closing: Token | null;
|
|
456
|
-
readonly is_void: boolean;
|
|
457
|
-
|
|
458
|
-
static from(data: SerializedHTMLSelfCloseTagNode): HTMLSelfCloseTagNode {
|
|
459
|
-
return new HTMLSelfCloseTagNode({
|
|
460
|
-
type: data.type,
|
|
461
|
-
location: Location.from(data.location),
|
|
462
|
-
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
463
|
-
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
464
|
-
tag_name: data.tag_name ? Token.from(data.tag_name) : null,
|
|
465
|
-
attributes: (data.attributes || []).map(node => fromSerializedNode(node)),
|
|
466
|
-
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
467
|
-
is_void: data.is_void,
|
|
468
|
-
})
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
constructor(props: HTMLSelfCloseTagNodeProps) {
|
|
472
|
-
super(props.type, props.location, props.errors);
|
|
473
|
-
this.tag_opening = props.tag_opening;
|
|
474
|
-
this.tag_name = props.tag_name;
|
|
475
|
-
this.attributes = props.attributes;
|
|
476
|
-
this.tag_closing = props.tag_closing;
|
|
477
|
-
this.is_void = props.is_void;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
accept(visitor: Visitor): void {
|
|
481
|
-
visitor.visitHTMLSelfCloseTagNode(this)
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
childNodes(): (Node | null | undefined)[] {
|
|
485
|
-
return [
|
|
486
|
-
...this.attributes,
|
|
487
|
-
];
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
compactChildNodes(): Node[] {
|
|
491
|
-
return this.childNodes().filter(node => node !== null && node !== undefined)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
recursiveErrors(): HerbError[] {
|
|
495
|
-
return [
|
|
496
|
-
...this.errors,
|
|
497
|
-
...this.attributes.map(node => node.recursiveErrors()),
|
|
498
|
-
].flat();
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
toJSON(): SerializedHTMLSelfCloseTagNode {
|
|
502
|
-
return {
|
|
503
|
-
...super.toJSON(),
|
|
504
|
-
type: "AST_HTML_SELF_CLOSE_TAG_NODE",
|
|
505
|
-
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
506
|
-
tag_name: this.tag_name ? this.tag_name.toJSON() : null,
|
|
507
|
-
attributes: this.attributes.map(node => node.toJSON()),
|
|
508
|
-
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
509
|
-
is_void: this.is_void,
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
treeInspect(): string {
|
|
514
|
-
let output = "";
|
|
515
|
-
|
|
516
|
-
output += `@ HTMLSelfCloseTagNode ${this.location.treeInspectWithLabel()}\n`;
|
|
517
|
-
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
518
|
-
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
519
|
-
output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`;
|
|
520
|
-
output += `├── attributes: ${this.inspectArray(this.attributes, "│ ")}`;
|
|
521
|
-
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
522
|
-
output += `└── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`;
|
|
523
|
-
|
|
524
|
-
// output += "\n";
|
|
525
|
-
|
|
526
431
|
return output
|
|
527
432
|
}
|
|
528
433
|
}
|
|
529
434
|
|
|
530
435
|
export interface SerializedHTMLElementNode extends SerializedNode {
|
|
531
436
|
type: "AST_HTML_ELEMENT_NODE";
|
|
532
|
-
open_tag:
|
|
437
|
+
open_tag: SerializedHTMLOpenTagNode | null;
|
|
533
438
|
tag_name: SerializedToken | null;
|
|
534
439
|
body: SerializedNode[];
|
|
535
|
-
close_tag:
|
|
440
|
+
close_tag: SerializedHTMLCloseTagNode | null;
|
|
536
441
|
is_void: boolean;
|
|
537
442
|
}
|
|
538
443
|
|
|
539
444
|
export interface HTMLElementNodeProps extends BaseNodeProps {
|
|
540
|
-
open_tag:
|
|
445
|
+
open_tag: HTMLOpenTagNode | null;
|
|
541
446
|
tag_name: Token | null;
|
|
542
447
|
body: Node[];
|
|
543
|
-
close_tag:
|
|
448
|
+
close_tag: HTMLCloseTagNode | null;
|
|
544
449
|
is_void: boolean;
|
|
545
450
|
}
|
|
546
451
|
|
|
547
452
|
export class HTMLElementNode extends Node {
|
|
548
|
-
readonly open_tag:
|
|
453
|
+
readonly open_tag: HTMLOpenTagNode | null;
|
|
549
454
|
readonly tag_name: Token | null;
|
|
550
455
|
readonly body: Node[];
|
|
551
|
-
readonly close_tag:
|
|
456
|
+
readonly close_tag: HTMLCloseTagNode | null;
|
|
552
457
|
readonly is_void: boolean;
|
|
553
458
|
|
|
554
459
|
static from(data: SerializedHTMLElementNode): HTMLElementNode {
|
|
@@ -556,10 +461,10 @@ export class HTMLElementNode extends Node {
|
|
|
556
461
|
type: data.type,
|
|
557
462
|
location: Location.from(data.location),
|
|
558
463
|
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
559
|
-
open_tag: data.open_tag ? fromSerializedNode((data.open_tag
|
|
464
|
+
open_tag: data.open_tag ? fromSerializedNode((data.open_tag)) : null,
|
|
560
465
|
tag_name: data.tag_name ? Token.from(data.tag_name) : null,
|
|
561
466
|
body: (data.body || []).map(node => fromSerializedNode(node)),
|
|
562
|
-
close_tag: data.close_tag ? fromSerializedNode((data.close_tag
|
|
467
|
+
close_tag: data.close_tag ? fromSerializedNode((data.close_tag)) : null,
|
|
563
468
|
is_void: data.is_void,
|
|
564
469
|
})
|
|
565
470
|
}
|
|
@@ -621,8 +526,6 @@ export class HTMLElementNode extends Node {
|
|
|
621
526
|
output += `├── close_tag: ${this.inspectNode(this.close_tag, "│ ")}`;
|
|
622
527
|
output += `└── is_void: ${typeof this.is_void === 'boolean' ? String(this.is_void) : "∅"}\n`;
|
|
623
528
|
|
|
624
|
-
// output += "\n";
|
|
625
|
-
|
|
626
529
|
return output
|
|
627
530
|
}
|
|
628
531
|
}
|
|
@@ -710,36 +613,34 @@ export class HTMLAttributeValueNode extends Node {
|
|
|
710
613
|
output += `├── close_quote: ${this.close_quote ? this.close_quote.treeInspect() : "∅"}\n`;
|
|
711
614
|
output += `└── quoted: ${typeof this.quoted === 'boolean' ? String(this.quoted) : "∅"}\n`;
|
|
712
615
|
|
|
713
|
-
// output += "\n";
|
|
714
|
-
|
|
715
616
|
return output
|
|
716
617
|
}
|
|
717
618
|
}
|
|
718
619
|
|
|
719
620
|
export interface SerializedHTMLAttributeNameNode extends SerializedNode {
|
|
720
621
|
type: "AST_HTML_ATTRIBUTE_NAME_NODE";
|
|
721
|
-
|
|
622
|
+
children: SerializedNode[];
|
|
722
623
|
}
|
|
723
624
|
|
|
724
625
|
export interface HTMLAttributeNameNodeProps extends BaseNodeProps {
|
|
725
|
-
|
|
626
|
+
children: Node[];
|
|
726
627
|
}
|
|
727
628
|
|
|
728
629
|
export class HTMLAttributeNameNode extends Node {
|
|
729
|
-
readonly
|
|
630
|
+
readonly children: Node[];
|
|
730
631
|
|
|
731
632
|
static from(data: SerializedHTMLAttributeNameNode): HTMLAttributeNameNode {
|
|
732
633
|
return new HTMLAttributeNameNode({
|
|
733
634
|
type: data.type,
|
|
734
635
|
location: Location.from(data.location),
|
|
735
636
|
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
736
|
-
|
|
637
|
+
children: (data.children || []).map(node => fromSerializedNode(node)),
|
|
737
638
|
})
|
|
738
639
|
}
|
|
739
640
|
|
|
740
641
|
constructor(props: HTMLAttributeNameNodeProps) {
|
|
741
642
|
super(props.type, props.location, props.errors);
|
|
742
|
-
this.
|
|
643
|
+
this.children = props.children;
|
|
743
644
|
}
|
|
744
645
|
|
|
745
646
|
accept(visitor: Visitor): void {
|
|
@@ -748,6 +649,7 @@ export class HTMLAttributeNameNode extends Node {
|
|
|
748
649
|
|
|
749
650
|
childNodes(): (Node | null | undefined)[] {
|
|
750
651
|
return [
|
|
652
|
+
...this.children,
|
|
751
653
|
];
|
|
752
654
|
}
|
|
753
655
|
|
|
@@ -758,6 +660,7 @@ export class HTMLAttributeNameNode extends Node {
|
|
|
758
660
|
recursiveErrors(): HerbError[] {
|
|
759
661
|
return [
|
|
760
662
|
...this.errors,
|
|
663
|
+
...this.children.map(node => node.recursiveErrors()),
|
|
761
664
|
].flat();
|
|
762
665
|
}
|
|
763
666
|
|
|
@@ -765,7 +668,7 @@ export class HTMLAttributeNameNode extends Node {
|
|
|
765
668
|
return {
|
|
766
669
|
...super.toJSON(),
|
|
767
670
|
type: "AST_HTML_ATTRIBUTE_NAME_NODE",
|
|
768
|
-
|
|
671
|
+
children: this.children.map(node => node.toJSON()),
|
|
769
672
|
};
|
|
770
673
|
}
|
|
771
674
|
|
|
@@ -774,9 +677,7 @@ export class HTMLAttributeNameNode extends Node {
|
|
|
774
677
|
|
|
775
678
|
output += `@ HTMLAttributeNameNode ${this.location.treeInspectWithLabel()}\n`;
|
|
776
679
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
777
|
-
output += `└──
|
|
778
|
-
|
|
779
|
-
// output += "\n";
|
|
680
|
+
output += `└── children: ${this.inspectArray(this.children, " ")}`;
|
|
780
681
|
|
|
781
682
|
return output
|
|
782
683
|
}
|
|
@@ -784,30 +685,30 @@ export class HTMLAttributeNameNode extends Node {
|
|
|
784
685
|
|
|
785
686
|
export interface SerializedHTMLAttributeNode extends SerializedNode {
|
|
786
687
|
type: "AST_HTML_ATTRIBUTE_NODE";
|
|
787
|
-
name:
|
|
688
|
+
name: SerializedHTMLAttributeNameNode | null;
|
|
788
689
|
equals: SerializedToken | null;
|
|
789
|
-
value:
|
|
690
|
+
value: SerializedHTMLAttributeValueNode | null;
|
|
790
691
|
}
|
|
791
692
|
|
|
792
693
|
export interface HTMLAttributeNodeProps extends BaseNodeProps {
|
|
793
|
-
name:
|
|
694
|
+
name: HTMLAttributeNameNode | null;
|
|
794
695
|
equals: Token | null;
|
|
795
|
-
value:
|
|
696
|
+
value: HTMLAttributeValueNode | null;
|
|
796
697
|
}
|
|
797
698
|
|
|
798
699
|
export class HTMLAttributeNode extends Node {
|
|
799
|
-
readonly name:
|
|
700
|
+
readonly name: HTMLAttributeNameNode | null;
|
|
800
701
|
readonly equals: Token | null;
|
|
801
|
-
readonly value:
|
|
702
|
+
readonly value: HTMLAttributeValueNode | null;
|
|
802
703
|
|
|
803
704
|
static from(data: SerializedHTMLAttributeNode): HTMLAttributeNode {
|
|
804
705
|
return new HTMLAttributeNode({
|
|
805
706
|
type: data.type,
|
|
806
707
|
location: Location.from(data.location),
|
|
807
708
|
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
808
|
-
name: data.name ? fromSerializedNode((data.name
|
|
709
|
+
name: data.name ? fromSerializedNode((data.name)) : null,
|
|
809
710
|
equals: data.equals ? Token.from(data.equals) : null,
|
|
810
|
-
value: data.value ? fromSerializedNode((data.value
|
|
711
|
+
value: data.value ? fromSerializedNode((data.value)) : null,
|
|
811
712
|
})
|
|
812
713
|
}
|
|
813
714
|
|
|
@@ -860,8 +761,6 @@ export class HTMLAttributeNode extends Node {
|
|
|
860
761
|
output += `├── equals: ${this.equals ? this.equals.treeInspect() : "∅"}\n`;
|
|
861
762
|
output += `└── value: ${this.inspectNode(this.value, " ")}`;
|
|
862
763
|
|
|
863
|
-
// output += "\n";
|
|
864
|
-
|
|
865
764
|
return output
|
|
866
765
|
}
|
|
867
766
|
}
|
|
@@ -926,8 +825,6 @@ export class HTMLTextNode extends Node {
|
|
|
926
825
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
927
826
|
output += `└── content: ${this.content ? JSON.stringify(this.content) : "∅"}\n`;
|
|
928
827
|
|
|
929
|
-
// output += "\n";
|
|
930
|
-
|
|
931
828
|
return output
|
|
932
829
|
}
|
|
933
830
|
}
|
|
@@ -1008,8 +905,6 @@ export class HTMLCommentNode extends Node {
|
|
|
1008
905
|
output += `├── children: ${this.inspectArray(this.children, "│ ")}`;
|
|
1009
906
|
output += `└── comment_end: ${this.comment_end ? this.comment_end.treeInspect() : "∅"}\n`;
|
|
1010
907
|
|
|
1011
|
-
// output += "\n";
|
|
1012
|
-
|
|
1013
908
|
return output
|
|
1014
909
|
}
|
|
1015
910
|
}
|
|
@@ -1090,7 +985,165 @@ export class HTMLDoctypeNode extends Node {
|
|
|
1090
985
|
output += `├── children: ${this.inspectArray(this.children, "│ ")}`;
|
|
1091
986
|
output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
1092
987
|
|
|
1093
|
-
|
|
988
|
+
return output
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
export interface SerializedXMLDeclarationNode extends SerializedNode {
|
|
993
|
+
type: "AST_XML_DECLARATION_NODE";
|
|
994
|
+
tag_opening: SerializedToken | null;
|
|
995
|
+
children: SerializedNode[];
|
|
996
|
+
tag_closing: SerializedToken | null;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
export interface XMLDeclarationNodeProps extends BaseNodeProps {
|
|
1000
|
+
tag_opening: Token | null;
|
|
1001
|
+
children: Node[];
|
|
1002
|
+
tag_closing: Token | null;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
export class XMLDeclarationNode extends Node {
|
|
1006
|
+
readonly tag_opening: Token | null;
|
|
1007
|
+
readonly children: Node[];
|
|
1008
|
+
readonly tag_closing: Token | null;
|
|
1009
|
+
|
|
1010
|
+
static from(data: SerializedXMLDeclarationNode): XMLDeclarationNode {
|
|
1011
|
+
return new XMLDeclarationNode({
|
|
1012
|
+
type: data.type,
|
|
1013
|
+
location: Location.from(data.location),
|
|
1014
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
1015
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
1016
|
+
children: (data.children || []).map(node => fromSerializedNode(node)),
|
|
1017
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1018
|
+
})
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
constructor(props: XMLDeclarationNodeProps) {
|
|
1022
|
+
super(props.type, props.location, props.errors);
|
|
1023
|
+
this.tag_opening = props.tag_opening;
|
|
1024
|
+
this.children = props.children;
|
|
1025
|
+
this.tag_closing = props.tag_closing;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
accept(visitor: Visitor): void {
|
|
1029
|
+
visitor.visitXMLDeclarationNode(this)
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
childNodes(): (Node | null | undefined)[] {
|
|
1033
|
+
return [
|
|
1034
|
+
...this.children,
|
|
1035
|
+
];
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
compactChildNodes(): Node[] {
|
|
1039
|
+
return this.childNodes().filter(node => node !== null && node !== undefined)
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
recursiveErrors(): HerbError[] {
|
|
1043
|
+
return [
|
|
1044
|
+
...this.errors,
|
|
1045
|
+
...this.children.map(node => node.recursiveErrors()),
|
|
1046
|
+
].flat();
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
toJSON(): SerializedXMLDeclarationNode {
|
|
1050
|
+
return {
|
|
1051
|
+
...super.toJSON(),
|
|
1052
|
+
type: "AST_XML_DECLARATION_NODE",
|
|
1053
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
1054
|
+
children: this.children.map(node => node.toJSON()),
|
|
1055
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
treeInspect(): string {
|
|
1060
|
+
let output = "";
|
|
1061
|
+
|
|
1062
|
+
output += `@ XMLDeclarationNode ${this.location.treeInspectWithLabel()}\n`;
|
|
1063
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
1064
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
1065
|
+
output += `├── children: ${this.inspectArray(this.children, "│ ")}`;
|
|
1066
|
+
output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
1067
|
+
|
|
1068
|
+
return output
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
export interface SerializedCDATANode extends SerializedNode {
|
|
1073
|
+
type: "AST_CDATA_NODE";
|
|
1074
|
+
tag_opening: SerializedToken | null;
|
|
1075
|
+
children: SerializedNode[];
|
|
1076
|
+
tag_closing: SerializedToken | null;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
export interface CDATANodeProps extends BaseNodeProps {
|
|
1080
|
+
tag_opening: Token | null;
|
|
1081
|
+
children: Node[];
|
|
1082
|
+
tag_closing: Token | null;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
export class CDATANode extends Node {
|
|
1086
|
+
readonly tag_opening: Token | null;
|
|
1087
|
+
readonly children: Node[];
|
|
1088
|
+
readonly tag_closing: Token | null;
|
|
1089
|
+
|
|
1090
|
+
static from(data: SerializedCDATANode): CDATANode {
|
|
1091
|
+
return new CDATANode({
|
|
1092
|
+
type: data.type,
|
|
1093
|
+
location: Location.from(data.location),
|
|
1094
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
1095
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
1096
|
+
children: (data.children || []).map(node => fromSerializedNode(node)),
|
|
1097
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1098
|
+
})
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
constructor(props: CDATANodeProps) {
|
|
1102
|
+
super(props.type, props.location, props.errors);
|
|
1103
|
+
this.tag_opening = props.tag_opening;
|
|
1104
|
+
this.children = props.children;
|
|
1105
|
+
this.tag_closing = props.tag_closing;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
accept(visitor: Visitor): void {
|
|
1109
|
+
visitor.visitCDATANode(this)
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
childNodes(): (Node | null | undefined)[] {
|
|
1113
|
+
return [
|
|
1114
|
+
...this.children,
|
|
1115
|
+
];
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
compactChildNodes(): Node[] {
|
|
1119
|
+
return this.childNodes().filter(node => node !== null && node !== undefined)
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
recursiveErrors(): HerbError[] {
|
|
1123
|
+
return [
|
|
1124
|
+
...this.errors,
|
|
1125
|
+
...this.children.map(node => node.recursiveErrors()),
|
|
1126
|
+
].flat();
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
toJSON(): SerializedCDATANode {
|
|
1130
|
+
return {
|
|
1131
|
+
...super.toJSON(),
|
|
1132
|
+
type: "AST_CDATA_NODE",
|
|
1133
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
1134
|
+
children: this.children.map(node => node.toJSON()),
|
|
1135
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
treeInspect(): string {
|
|
1140
|
+
let output = "";
|
|
1141
|
+
|
|
1142
|
+
output += `@ CDATANode ${this.location.treeInspectWithLabel()}\n`;
|
|
1143
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
1144
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
1145
|
+
output += `├── children: ${this.inspectArray(this.children, "│ ")}`;
|
|
1146
|
+
output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
1094
1147
|
|
|
1095
1148
|
return output
|
|
1096
1149
|
}
|
|
@@ -1156,8 +1209,6 @@ export class WhitespaceNode extends Node {
|
|
|
1156
1209
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
1157
1210
|
output += `└── value: ${this.value ? this.value.treeInspect() : "∅"}\n`;
|
|
1158
1211
|
|
|
1159
|
-
// output += "\n";
|
|
1160
|
-
|
|
1161
1212
|
return output
|
|
1162
1213
|
}
|
|
1163
1214
|
}
|
|
@@ -1257,8 +1308,6 @@ export class ERBContentNode extends Node {
|
|
|
1257
1308
|
output += `├── parsed: ${typeof this.parsed === 'boolean' ? String(this.parsed) : "∅"}\n`;
|
|
1258
1309
|
output += `└── valid: ${typeof this.valid === 'boolean' ? String(this.valid) : "∅"}\n`;
|
|
1259
1310
|
|
|
1260
|
-
// output += "\n";
|
|
1261
|
-
|
|
1262
1311
|
return output
|
|
1263
1312
|
}
|
|
1264
1313
|
}
|
|
@@ -1337,8 +1386,6 @@ export class ERBEndNode extends Node {
|
|
|
1337
1386
|
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
1338
1387
|
output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
1339
1388
|
|
|
1340
|
-
// output += "\n";
|
|
1341
|
-
|
|
1342
1389
|
return output
|
|
1343
1390
|
}
|
|
1344
1391
|
}
|
|
@@ -1426,8 +1473,6 @@ export class ERBElseNode extends Node {
|
|
|
1426
1473
|
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
1427
1474
|
output += `└── statements: ${this.inspectArray(this.statements, " ")}`;
|
|
1428
1475
|
|
|
1429
|
-
// output += "\n";
|
|
1430
|
-
|
|
1431
1476
|
return output
|
|
1432
1477
|
}
|
|
1433
1478
|
}
|
|
@@ -1439,7 +1484,7 @@ export interface SerializedERBIfNode extends SerializedNode {
|
|
|
1439
1484
|
tag_closing: SerializedToken | null;
|
|
1440
1485
|
statements: SerializedNode[];
|
|
1441
1486
|
subsequent: SerializedNode | null;
|
|
1442
|
-
end_node:
|
|
1487
|
+
end_node: SerializedERBEndNode | null;
|
|
1443
1488
|
}
|
|
1444
1489
|
|
|
1445
1490
|
export interface ERBIfNodeProps extends BaseNodeProps {
|
|
@@ -1448,7 +1493,7 @@ export interface ERBIfNodeProps extends BaseNodeProps {
|
|
|
1448
1493
|
tag_closing: Token | null;
|
|
1449
1494
|
statements: Node[];
|
|
1450
1495
|
subsequent: Node | null;
|
|
1451
|
-
end_node:
|
|
1496
|
+
end_node: ERBEndNode | null;
|
|
1452
1497
|
}
|
|
1453
1498
|
|
|
1454
1499
|
export class ERBIfNode extends Node {
|
|
@@ -1457,7 +1502,7 @@ export class ERBIfNode extends Node {
|
|
|
1457
1502
|
readonly tag_closing: Token | null;
|
|
1458
1503
|
readonly statements: Node[];
|
|
1459
1504
|
readonly subsequent: Node | null;
|
|
1460
|
-
readonly end_node:
|
|
1505
|
+
readonly end_node: ERBEndNode | null;
|
|
1461
1506
|
|
|
1462
1507
|
static from(data: SerializedERBIfNode): ERBIfNode {
|
|
1463
1508
|
return new ERBIfNode({
|
|
@@ -1468,8 +1513,8 @@ export class ERBIfNode extends Node {
|
|
|
1468
1513
|
content: data.content ? Token.from(data.content) : null,
|
|
1469
1514
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1470
1515
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
1471
|
-
subsequent: data.subsequent ? fromSerializedNode((data.subsequent
|
|
1472
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
1516
|
+
subsequent: data.subsequent ? fromSerializedNode((data.subsequent)) : null,
|
|
1517
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
1473
1518
|
})
|
|
1474
1519
|
}
|
|
1475
1520
|
|
|
@@ -1533,8 +1578,6 @@ export class ERBIfNode extends Node {
|
|
|
1533
1578
|
output += `├── subsequent: ${this.inspectNode(this.subsequent, "│ ")}`;
|
|
1534
1579
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
1535
1580
|
|
|
1536
|
-
// output += "\n";
|
|
1537
|
-
|
|
1538
1581
|
return output
|
|
1539
1582
|
}
|
|
1540
1583
|
}
|
|
@@ -1545,7 +1588,7 @@ export interface SerializedERBBlockNode extends SerializedNode {
|
|
|
1545
1588
|
content: SerializedToken | null;
|
|
1546
1589
|
tag_closing: SerializedToken | null;
|
|
1547
1590
|
body: SerializedNode[];
|
|
1548
|
-
end_node:
|
|
1591
|
+
end_node: SerializedERBEndNode | null;
|
|
1549
1592
|
}
|
|
1550
1593
|
|
|
1551
1594
|
export interface ERBBlockNodeProps extends BaseNodeProps {
|
|
@@ -1553,7 +1596,7 @@ export interface ERBBlockNodeProps extends BaseNodeProps {
|
|
|
1553
1596
|
content: Token | null;
|
|
1554
1597
|
tag_closing: Token | null;
|
|
1555
1598
|
body: Node[];
|
|
1556
|
-
end_node:
|
|
1599
|
+
end_node: ERBEndNode | null;
|
|
1557
1600
|
}
|
|
1558
1601
|
|
|
1559
1602
|
export class ERBBlockNode extends Node {
|
|
@@ -1561,7 +1604,7 @@ export class ERBBlockNode extends Node {
|
|
|
1561
1604
|
readonly content: Token | null;
|
|
1562
1605
|
readonly tag_closing: Token | null;
|
|
1563
1606
|
readonly body: Node[];
|
|
1564
|
-
readonly end_node:
|
|
1607
|
+
readonly end_node: ERBEndNode | null;
|
|
1565
1608
|
|
|
1566
1609
|
static from(data: SerializedERBBlockNode): ERBBlockNode {
|
|
1567
1610
|
return new ERBBlockNode({
|
|
@@ -1572,7 +1615,7 @@ export class ERBBlockNode extends Node {
|
|
|
1572
1615
|
content: data.content ? Token.from(data.content) : null,
|
|
1573
1616
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1574
1617
|
body: (data.body || []).map(node => fromSerializedNode(node)),
|
|
1575
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
1618
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
1576
1619
|
})
|
|
1577
1620
|
}
|
|
1578
1621
|
|
|
@@ -1631,8 +1674,6 @@ export class ERBBlockNode extends Node {
|
|
|
1631
1674
|
output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
|
|
1632
1675
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
1633
1676
|
|
|
1634
|
-
// output += "\n";
|
|
1635
|
-
|
|
1636
1677
|
return output
|
|
1637
1678
|
}
|
|
1638
1679
|
}
|
|
@@ -1720,8 +1761,6 @@ export class ERBWhenNode extends Node {
|
|
|
1720
1761
|
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
1721
1762
|
output += `└── statements: ${this.inspectArray(this.statements, " ")}`;
|
|
1722
1763
|
|
|
1723
|
-
// output += "\n";
|
|
1724
|
-
|
|
1725
1764
|
return output
|
|
1726
1765
|
}
|
|
1727
1766
|
}
|
|
@@ -1733,8 +1772,8 @@ export interface SerializedERBCaseNode extends SerializedNode {
|
|
|
1733
1772
|
tag_closing: SerializedToken | null;
|
|
1734
1773
|
children: SerializedNode[];
|
|
1735
1774
|
conditions: SerializedNode[];
|
|
1736
|
-
else_clause:
|
|
1737
|
-
end_node:
|
|
1775
|
+
else_clause: SerializedERBElseNode | null;
|
|
1776
|
+
end_node: SerializedERBEndNode | null;
|
|
1738
1777
|
}
|
|
1739
1778
|
|
|
1740
1779
|
export interface ERBCaseNodeProps extends BaseNodeProps {
|
|
@@ -1743,8 +1782,8 @@ export interface ERBCaseNodeProps extends BaseNodeProps {
|
|
|
1743
1782
|
tag_closing: Token | null;
|
|
1744
1783
|
children: Node[];
|
|
1745
1784
|
conditions: any[];
|
|
1746
|
-
else_clause:
|
|
1747
|
-
end_node:
|
|
1785
|
+
else_clause: ERBElseNode | null;
|
|
1786
|
+
end_node: ERBEndNode | null;
|
|
1748
1787
|
}
|
|
1749
1788
|
|
|
1750
1789
|
export class ERBCaseNode extends Node {
|
|
@@ -1752,9 +1791,9 @@ export class ERBCaseNode extends Node {
|
|
|
1752
1791
|
readonly content: Token | null;
|
|
1753
1792
|
readonly tag_closing: Token | null;
|
|
1754
1793
|
readonly children: Node[];
|
|
1755
|
-
readonly conditions:
|
|
1756
|
-
readonly else_clause:
|
|
1757
|
-
readonly end_node:
|
|
1794
|
+
readonly conditions: Node[];
|
|
1795
|
+
readonly else_clause: ERBElseNode | null;
|
|
1796
|
+
readonly end_node: ERBEndNode | null;
|
|
1758
1797
|
|
|
1759
1798
|
static from(data: SerializedERBCaseNode): ERBCaseNode {
|
|
1760
1799
|
return new ERBCaseNode({
|
|
@@ -1766,8 +1805,8 @@ export class ERBCaseNode extends Node {
|
|
|
1766
1805
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1767
1806
|
children: (data.children || []).map(node => fromSerializedNode(node)),
|
|
1768
1807
|
conditions: (data.conditions || []).map(node => fromSerializedNode(node)),
|
|
1769
|
-
else_clause: data.else_clause ? fromSerializedNode((data.else_clause
|
|
1770
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
1808
|
+
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
1809
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
1771
1810
|
})
|
|
1772
1811
|
}
|
|
1773
1812
|
|
|
@@ -1836,8 +1875,6 @@ export class ERBCaseNode extends Node {
|
|
|
1836
1875
|
output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
|
|
1837
1876
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
1838
1877
|
|
|
1839
|
-
// output += "\n";
|
|
1840
|
-
|
|
1841
1878
|
return output
|
|
1842
1879
|
}
|
|
1843
1880
|
}
|
|
@@ -1849,8 +1886,8 @@ export interface SerializedERBCaseMatchNode extends SerializedNode {
|
|
|
1849
1886
|
tag_closing: SerializedToken | null;
|
|
1850
1887
|
children: SerializedNode[];
|
|
1851
1888
|
conditions: SerializedNode[];
|
|
1852
|
-
else_clause:
|
|
1853
|
-
end_node:
|
|
1889
|
+
else_clause: SerializedERBElseNode | null;
|
|
1890
|
+
end_node: SerializedERBEndNode | null;
|
|
1854
1891
|
}
|
|
1855
1892
|
|
|
1856
1893
|
export interface ERBCaseMatchNodeProps extends BaseNodeProps {
|
|
@@ -1859,8 +1896,8 @@ export interface ERBCaseMatchNodeProps extends BaseNodeProps {
|
|
|
1859
1896
|
tag_closing: Token | null;
|
|
1860
1897
|
children: Node[];
|
|
1861
1898
|
conditions: any[];
|
|
1862
|
-
else_clause:
|
|
1863
|
-
end_node:
|
|
1899
|
+
else_clause: ERBElseNode | null;
|
|
1900
|
+
end_node: ERBEndNode | null;
|
|
1864
1901
|
}
|
|
1865
1902
|
|
|
1866
1903
|
export class ERBCaseMatchNode extends Node {
|
|
@@ -1868,9 +1905,9 @@ export class ERBCaseMatchNode extends Node {
|
|
|
1868
1905
|
readonly content: Token | null;
|
|
1869
1906
|
readonly tag_closing: Token | null;
|
|
1870
1907
|
readonly children: Node[];
|
|
1871
|
-
readonly conditions:
|
|
1872
|
-
readonly else_clause:
|
|
1873
|
-
readonly end_node:
|
|
1908
|
+
readonly conditions: Node[];
|
|
1909
|
+
readonly else_clause: ERBElseNode | null;
|
|
1910
|
+
readonly end_node: ERBEndNode | null;
|
|
1874
1911
|
|
|
1875
1912
|
static from(data: SerializedERBCaseMatchNode): ERBCaseMatchNode {
|
|
1876
1913
|
return new ERBCaseMatchNode({
|
|
@@ -1882,8 +1919,8 @@ export class ERBCaseMatchNode extends Node {
|
|
|
1882
1919
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1883
1920
|
children: (data.children || []).map(node => fromSerializedNode(node)),
|
|
1884
1921
|
conditions: (data.conditions || []).map(node => fromSerializedNode(node)),
|
|
1885
|
-
else_clause: data.else_clause ? fromSerializedNode((data.else_clause
|
|
1886
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
1922
|
+
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
1923
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
1887
1924
|
})
|
|
1888
1925
|
}
|
|
1889
1926
|
|
|
@@ -1952,8 +1989,6 @@ export class ERBCaseMatchNode extends Node {
|
|
|
1952
1989
|
output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
|
|
1953
1990
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
1954
1991
|
|
|
1955
|
-
// output += "\n";
|
|
1956
|
-
|
|
1957
1992
|
return output
|
|
1958
1993
|
}
|
|
1959
1994
|
}
|
|
@@ -1964,7 +1999,7 @@ export interface SerializedERBWhileNode extends SerializedNode {
|
|
|
1964
1999
|
content: SerializedToken | null;
|
|
1965
2000
|
tag_closing: SerializedToken | null;
|
|
1966
2001
|
statements: SerializedNode[];
|
|
1967
|
-
end_node:
|
|
2002
|
+
end_node: SerializedERBEndNode | null;
|
|
1968
2003
|
}
|
|
1969
2004
|
|
|
1970
2005
|
export interface ERBWhileNodeProps extends BaseNodeProps {
|
|
@@ -1972,7 +2007,7 @@ export interface ERBWhileNodeProps extends BaseNodeProps {
|
|
|
1972
2007
|
content: Token | null;
|
|
1973
2008
|
tag_closing: Token | null;
|
|
1974
2009
|
statements: Node[];
|
|
1975
|
-
end_node:
|
|
2010
|
+
end_node: ERBEndNode | null;
|
|
1976
2011
|
}
|
|
1977
2012
|
|
|
1978
2013
|
export class ERBWhileNode extends Node {
|
|
@@ -1980,7 +2015,7 @@ export class ERBWhileNode extends Node {
|
|
|
1980
2015
|
readonly content: Token | null;
|
|
1981
2016
|
readonly tag_closing: Token | null;
|
|
1982
2017
|
readonly statements: Node[];
|
|
1983
|
-
readonly end_node:
|
|
2018
|
+
readonly end_node: ERBEndNode | null;
|
|
1984
2019
|
|
|
1985
2020
|
static from(data: SerializedERBWhileNode): ERBWhileNode {
|
|
1986
2021
|
return new ERBWhileNode({
|
|
@@ -1991,7 +2026,7 @@ export class ERBWhileNode extends Node {
|
|
|
1991
2026
|
content: data.content ? Token.from(data.content) : null,
|
|
1992
2027
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
1993
2028
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
1994
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
2029
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
1995
2030
|
})
|
|
1996
2031
|
}
|
|
1997
2032
|
|
|
@@ -2050,8 +2085,6 @@ export class ERBWhileNode extends Node {
|
|
|
2050
2085
|
output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`;
|
|
2051
2086
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
2052
2087
|
|
|
2053
|
-
// output += "\n";
|
|
2054
|
-
|
|
2055
2088
|
return output
|
|
2056
2089
|
}
|
|
2057
2090
|
}
|
|
@@ -2062,7 +2095,7 @@ export interface SerializedERBUntilNode extends SerializedNode {
|
|
|
2062
2095
|
content: SerializedToken | null;
|
|
2063
2096
|
tag_closing: SerializedToken | null;
|
|
2064
2097
|
statements: SerializedNode[];
|
|
2065
|
-
end_node:
|
|
2098
|
+
end_node: SerializedERBEndNode | null;
|
|
2066
2099
|
}
|
|
2067
2100
|
|
|
2068
2101
|
export interface ERBUntilNodeProps extends BaseNodeProps {
|
|
@@ -2070,7 +2103,7 @@ export interface ERBUntilNodeProps extends BaseNodeProps {
|
|
|
2070
2103
|
content: Token | null;
|
|
2071
2104
|
tag_closing: Token | null;
|
|
2072
2105
|
statements: Node[];
|
|
2073
|
-
end_node:
|
|
2106
|
+
end_node: ERBEndNode | null;
|
|
2074
2107
|
}
|
|
2075
2108
|
|
|
2076
2109
|
export class ERBUntilNode extends Node {
|
|
@@ -2078,7 +2111,7 @@ export class ERBUntilNode extends Node {
|
|
|
2078
2111
|
readonly content: Token | null;
|
|
2079
2112
|
readonly tag_closing: Token | null;
|
|
2080
2113
|
readonly statements: Node[];
|
|
2081
|
-
readonly end_node:
|
|
2114
|
+
readonly end_node: ERBEndNode | null;
|
|
2082
2115
|
|
|
2083
2116
|
static from(data: SerializedERBUntilNode): ERBUntilNode {
|
|
2084
2117
|
return new ERBUntilNode({
|
|
@@ -2089,7 +2122,7 @@ export class ERBUntilNode extends Node {
|
|
|
2089
2122
|
content: data.content ? Token.from(data.content) : null,
|
|
2090
2123
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
2091
2124
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
2092
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
2125
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
2093
2126
|
})
|
|
2094
2127
|
}
|
|
2095
2128
|
|
|
@@ -2148,8 +2181,6 @@ export class ERBUntilNode extends Node {
|
|
|
2148
2181
|
output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`;
|
|
2149
2182
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
2150
2183
|
|
|
2151
|
-
// output += "\n";
|
|
2152
|
-
|
|
2153
2184
|
return output
|
|
2154
2185
|
}
|
|
2155
2186
|
}
|
|
@@ -2160,7 +2191,7 @@ export interface SerializedERBForNode extends SerializedNode {
|
|
|
2160
2191
|
content: SerializedToken | null;
|
|
2161
2192
|
tag_closing: SerializedToken | null;
|
|
2162
2193
|
statements: SerializedNode[];
|
|
2163
|
-
end_node:
|
|
2194
|
+
end_node: SerializedERBEndNode | null;
|
|
2164
2195
|
}
|
|
2165
2196
|
|
|
2166
2197
|
export interface ERBForNodeProps extends BaseNodeProps {
|
|
@@ -2168,7 +2199,7 @@ export interface ERBForNodeProps extends BaseNodeProps {
|
|
|
2168
2199
|
content: Token | null;
|
|
2169
2200
|
tag_closing: Token | null;
|
|
2170
2201
|
statements: Node[];
|
|
2171
|
-
end_node:
|
|
2202
|
+
end_node: ERBEndNode | null;
|
|
2172
2203
|
}
|
|
2173
2204
|
|
|
2174
2205
|
export class ERBForNode extends Node {
|
|
@@ -2176,7 +2207,7 @@ export class ERBForNode extends Node {
|
|
|
2176
2207
|
readonly content: Token | null;
|
|
2177
2208
|
readonly tag_closing: Token | null;
|
|
2178
2209
|
readonly statements: Node[];
|
|
2179
|
-
readonly end_node:
|
|
2210
|
+
readonly end_node: ERBEndNode | null;
|
|
2180
2211
|
|
|
2181
2212
|
static from(data: SerializedERBForNode): ERBForNode {
|
|
2182
2213
|
return new ERBForNode({
|
|
@@ -2187,7 +2218,7 @@ export class ERBForNode extends Node {
|
|
|
2187
2218
|
content: data.content ? Token.from(data.content) : null,
|
|
2188
2219
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
2189
2220
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
2190
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
2221
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
2191
2222
|
})
|
|
2192
2223
|
}
|
|
2193
2224
|
|
|
@@ -2246,8 +2277,6 @@ export class ERBForNode extends Node {
|
|
|
2246
2277
|
output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`;
|
|
2247
2278
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
2248
2279
|
|
|
2249
|
-
// output += "\n";
|
|
2250
|
-
|
|
2251
2280
|
return output
|
|
2252
2281
|
}
|
|
2253
2282
|
}
|
|
@@ -2258,7 +2287,7 @@ export interface SerializedERBRescueNode extends SerializedNode {
|
|
|
2258
2287
|
content: SerializedToken | null;
|
|
2259
2288
|
tag_closing: SerializedToken | null;
|
|
2260
2289
|
statements: SerializedNode[];
|
|
2261
|
-
subsequent:
|
|
2290
|
+
subsequent: SerializedERBRescueNode | null;
|
|
2262
2291
|
}
|
|
2263
2292
|
|
|
2264
2293
|
export interface ERBRescueNodeProps extends BaseNodeProps {
|
|
@@ -2266,7 +2295,7 @@ export interface ERBRescueNodeProps extends BaseNodeProps {
|
|
|
2266
2295
|
content: Token | null;
|
|
2267
2296
|
tag_closing: Token | null;
|
|
2268
2297
|
statements: Node[];
|
|
2269
|
-
subsequent:
|
|
2298
|
+
subsequent: ERBRescueNode | null;
|
|
2270
2299
|
}
|
|
2271
2300
|
|
|
2272
2301
|
export class ERBRescueNode extends Node {
|
|
@@ -2274,7 +2303,7 @@ export class ERBRescueNode extends Node {
|
|
|
2274
2303
|
readonly content: Token | null;
|
|
2275
2304
|
readonly tag_closing: Token | null;
|
|
2276
2305
|
readonly statements: Node[];
|
|
2277
|
-
readonly subsequent:
|
|
2306
|
+
readonly subsequent: ERBRescueNode | null;
|
|
2278
2307
|
|
|
2279
2308
|
static from(data: SerializedERBRescueNode): ERBRescueNode {
|
|
2280
2309
|
return new ERBRescueNode({
|
|
@@ -2285,7 +2314,7 @@ export class ERBRescueNode extends Node {
|
|
|
2285
2314
|
content: data.content ? Token.from(data.content) : null,
|
|
2286
2315
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
2287
2316
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
2288
|
-
subsequent: data.subsequent ? fromSerializedNode((data.subsequent
|
|
2317
|
+
subsequent: data.subsequent ? fromSerializedNode((data.subsequent)) : null,
|
|
2289
2318
|
})
|
|
2290
2319
|
}
|
|
2291
2320
|
|
|
@@ -2344,8 +2373,6 @@ export class ERBRescueNode extends Node {
|
|
|
2344
2373
|
output += `├── statements: ${this.inspectArray(this.statements, "│ ")}`;
|
|
2345
2374
|
output += `└── subsequent: ${this.inspectNode(this.subsequent, " ")}`;
|
|
2346
2375
|
|
|
2347
|
-
// output += "\n";
|
|
2348
|
-
|
|
2349
2376
|
return output
|
|
2350
2377
|
}
|
|
2351
2378
|
}
|
|
@@ -2433,8 +2460,6 @@ export class ERBEnsureNode extends Node {
|
|
|
2433
2460
|
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
2434
2461
|
output += `└── statements: ${this.inspectArray(this.statements, " ")}`;
|
|
2435
2462
|
|
|
2436
|
-
// output += "\n";
|
|
2437
|
-
|
|
2438
2463
|
return output
|
|
2439
2464
|
}
|
|
2440
2465
|
}
|
|
@@ -2445,10 +2470,10 @@ export interface SerializedERBBeginNode extends SerializedNode {
|
|
|
2445
2470
|
content: SerializedToken | null;
|
|
2446
2471
|
tag_closing: SerializedToken | null;
|
|
2447
2472
|
statements: SerializedNode[];
|
|
2448
|
-
rescue_clause:
|
|
2449
|
-
else_clause:
|
|
2450
|
-
ensure_clause:
|
|
2451
|
-
end_node:
|
|
2473
|
+
rescue_clause: SerializedERBRescueNode | null;
|
|
2474
|
+
else_clause: SerializedERBElseNode | null;
|
|
2475
|
+
ensure_clause: SerializedERBEnsureNode | null;
|
|
2476
|
+
end_node: SerializedERBEndNode | null;
|
|
2452
2477
|
}
|
|
2453
2478
|
|
|
2454
2479
|
export interface ERBBeginNodeProps extends BaseNodeProps {
|
|
@@ -2456,10 +2481,10 @@ export interface ERBBeginNodeProps extends BaseNodeProps {
|
|
|
2456
2481
|
content: Token | null;
|
|
2457
2482
|
tag_closing: Token | null;
|
|
2458
2483
|
statements: Node[];
|
|
2459
|
-
rescue_clause:
|
|
2460
|
-
else_clause:
|
|
2461
|
-
ensure_clause:
|
|
2462
|
-
end_node:
|
|
2484
|
+
rescue_clause: ERBRescueNode | null;
|
|
2485
|
+
else_clause: ERBElseNode | null;
|
|
2486
|
+
ensure_clause: ERBEnsureNode | null;
|
|
2487
|
+
end_node: ERBEndNode | null;
|
|
2463
2488
|
}
|
|
2464
2489
|
|
|
2465
2490
|
export class ERBBeginNode extends Node {
|
|
@@ -2467,10 +2492,10 @@ export class ERBBeginNode extends Node {
|
|
|
2467
2492
|
readonly content: Token | null;
|
|
2468
2493
|
readonly tag_closing: Token | null;
|
|
2469
2494
|
readonly statements: Node[];
|
|
2470
|
-
readonly rescue_clause:
|
|
2471
|
-
readonly else_clause:
|
|
2472
|
-
readonly ensure_clause:
|
|
2473
|
-
readonly end_node:
|
|
2495
|
+
readonly rescue_clause: ERBRescueNode | null;
|
|
2496
|
+
readonly else_clause: ERBElseNode | null;
|
|
2497
|
+
readonly ensure_clause: ERBEnsureNode | null;
|
|
2498
|
+
readonly end_node: ERBEndNode | null;
|
|
2474
2499
|
|
|
2475
2500
|
static from(data: SerializedERBBeginNode): ERBBeginNode {
|
|
2476
2501
|
return new ERBBeginNode({
|
|
@@ -2481,10 +2506,10 @@ export class ERBBeginNode extends Node {
|
|
|
2481
2506
|
content: data.content ? Token.from(data.content) : null,
|
|
2482
2507
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
2483
2508
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
2484
|
-
rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause
|
|
2485
|
-
else_clause: data.else_clause ? fromSerializedNode((data.else_clause
|
|
2486
|
-
ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause
|
|
2487
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
2509
|
+
rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) : null,
|
|
2510
|
+
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
2511
|
+
ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) : null,
|
|
2512
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
2488
2513
|
})
|
|
2489
2514
|
}
|
|
2490
2515
|
|
|
@@ -2558,8 +2583,6 @@ export class ERBBeginNode extends Node {
|
|
|
2558
2583
|
output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`;
|
|
2559
2584
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
2560
2585
|
|
|
2561
|
-
// output += "\n";
|
|
2562
|
-
|
|
2563
2586
|
return output
|
|
2564
2587
|
}
|
|
2565
2588
|
}
|
|
@@ -2570,8 +2593,8 @@ export interface SerializedERBUnlessNode extends SerializedNode {
|
|
|
2570
2593
|
content: SerializedToken | null;
|
|
2571
2594
|
tag_closing: SerializedToken | null;
|
|
2572
2595
|
statements: SerializedNode[];
|
|
2573
|
-
else_clause:
|
|
2574
|
-
end_node:
|
|
2596
|
+
else_clause: SerializedERBElseNode | null;
|
|
2597
|
+
end_node: SerializedERBEndNode | null;
|
|
2575
2598
|
}
|
|
2576
2599
|
|
|
2577
2600
|
export interface ERBUnlessNodeProps extends BaseNodeProps {
|
|
@@ -2579,8 +2602,8 @@ export interface ERBUnlessNodeProps extends BaseNodeProps {
|
|
|
2579
2602
|
content: Token | null;
|
|
2580
2603
|
tag_closing: Token | null;
|
|
2581
2604
|
statements: Node[];
|
|
2582
|
-
else_clause:
|
|
2583
|
-
end_node:
|
|
2605
|
+
else_clause: ERBElseNode | null;
|
|
2606
|
+
end_node: ERBEndNode | null;
|
|
2584
2607
|
}
|
|
2585
2608
|
|
|
2586
2609
|
export class ERBUnlessNode extends Node {
|
|
@@ -2588,8 +2611,8 @@ export class ERBUnlessNode extends Node {
|
|
|
2588
2611
|
readonly content: Token | null;
|
|
2589
2612
|
readonly tag_closing: Token | null;
|
|
2590
2613
|
readonly statements: Node[];
|
|
2591
|
-
readonly else_clause:
|
|
2592
|
-
readonly end_node:
|
|
2614
|
+
readonly else_clause: ERBElseNode | null;
|
|
2615
|
+
readonly end_node: ERBEndNode | null;
|
|
2593
2616
|
|
|
2594
2617
|
static from(data: SerializedERBUnlessNode): ERBUnlessNode {
|
|
2595
2618
|
return new ERBUnlessNode({
|
|
@@ -2600,8 +2623,8 @@ export class ERBUnlessNode extends Node {
|
|
|
2600
2623
|
content: data.content ? Token.from(data.content) : null,
|
|
2601
2624
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
2602
2625
|
statements: (data.statements || []).map(node => fromSerializedNode(node)),
|
|
2603
|
-
else_clause: data.else_clause ? fromSerializedNode((data.else_clause
|
|
2604
|
-
end_node: data.end_node ? fromSerializedNode((data.end_node
|
|
2626
|
+
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
2627
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
2605
2628
|
})
|
|
2606
2629
|
}
|
|
2607
2630
|
|
|
@@ -2665,8 +2688,6 @@ export class ERBUnlessNode extends Node {
|
|
|
2665
2688
|
output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
|
|
2666
2689
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
2667
2690
|
|
|
2668
|
-
// output += "\n";
|
|
2669
|
-
|
|
2670
2691
|
return output
|
|
2671
2692
|
}
|
|
2672
2693
|
}
|
|
@@ -2745,8 +2766,6 @@ export class ERBYieldNode extends Node {
|
|
|
2745
2766
|
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
2746
2767
|
output += `└── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
2747
2768
|
|
|
2748
|
-
// output += "\n";
|
|
2749
|
-
|
|
2750
2769
|
return output
|
|
2751
2770
|
}
|
|
2752
2771
|
}
|
|
@@ -2834,20 +2853,52 @@ export class ERBInNode extends Node {
|
|
|
2834
2853
|
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
2835
2854
|
output += `└── statements: ${this.inspectArray(this.statements, " ")}`;
|
|
2836
2855
|
|
|
2837
|
-
// output += "\n";
|
|
2838
|
-
|
|
2839
2856
|
return output
|
|
2840
2857
|
}
|
|
2841
2858
|
}
|
|
2842
2859
|
|
|
2843
2860
|
|
|
2861
|
+
export type ConcreteNode =
|
|
2862
|
+
DocumentNode | LiteralNode | HTMLOpenTagNode | HTMLCloseTagNode | HTMLElementNode | HTMLAttributeValueNode | HTMLAttributeNameNode | HTMLAttributeNode | HTMLTextNode | HTMLCommentNode | HTMLDoctypeNode | XMLDeclarationNode | CDATANode | WhitespaceNode | ERBContentNode | ERBEndNode | ERBElseNode | ERBIfNode | ERBBlockNode | ERBWhenNode | ERBCaseNode | ERBCaseMatchNode | ERBWhileNode | ERBUntilNode | ERBForNode | ERBRescueNode | ERBEnsureNode | ERBBeginNode | ERBUnlessNode | ERBYieldNode | ERBInNode
|
|
2863
|
+
export function fromSerializedNode(node: SerializedDocumentNode): DocumentNode;
|
|
2864
|
+
export function fromSerializedNode(node: SerializedLiteralNode): LiteralNode;
|
|
2865
|
+
export function fromSerializedNode(node: SerializedHTMLOpenTagNode): HTMLOpenTagNode;
|
|
2866
|
+
export function fromSerializedNode(node: SerializedHTMLCloseTagNode): HTMLCloseTagNode;
|
|
2867
|
+
export function fromSerializedNode(node: SerializedHTMLElementNode): HTMLElementNode;
|
|
2868
|
+
export function fromSerializedNode(node: SerializedHTMLAttributeValueNode): HTMLAttributeValueNode;
|
|
2869
|
+
export function fromSerializedNode(node: SerializedHTMLAttributeNameNode): HTMLAttributeNameNode;
|
|
2870
|
+
export function fromSerializedNode(node: SerializedHTMLAttributeNode): HTMLAttributeNode;
|
|
2871
|
+
export function fromSerializedNode(node: SerializedHTMLTextNode): HTMLTextNode;
|
|
2872
|
+
export function fromSerializedNode(node: SerializedHTMLCommentNode): HTMLCommentNode;
|
|
2873
|
+
export function fromSerializedNode(node: SerializedHTMLDoctypeNode): HTMLDoctypeNode;
|
|
2874
|
+
export function fromSerializedNode(node: SerializedXMLDeclarationNode): XMLDeclarationNode;
|
|
2875
|
+
export function fromSerializedNode(node: SerializedCDATANode): CDATANode;
|
|
2876
|
+
export function fromSerializedNode(node: SerializedWhitespaceNode): WhitespaceNode;
|
|
2877
|
+
export function fromSerializedNode(node: SerializedERBContentNode): ERBContentNode;
|
|
2878
|
+
export function fromSerializedNode(node: SerializedERBEndNode): ERBEndNode;
|
|
2879
|
+
export function fromSerializedNode(node: SerializedERBElseNode): ERBElseNode;
|
|
2880
|
+
export function fromSerializedNode(node: SerializedERBIfNode): ERBIfNode;
|
|
2881
|
+
export function fromSerializedNode(node: SerializedERBBlockNode): ERBBlockNode;
|
|
2882
|
+
export function fromSerializedNode(node: SerializedERBWhenNode): ERBWhenNode;
|
|
2883
|
+
export function fromSerializedNode(node: SerializedERBCaseNode): ERBCaseNode;
|
|
2884
|
+
export function fromSerializedNode(node: SerializedERBCaseMatchNode): ERBCaseMatchNode;
|
|
2885
|
+
export function fromSerializedNode(node: SerializedERBWhileNode): ERBWhileNode;
|
|
2886
|
+
export function fromSerializedNode(node: SerializedERBUntilNode): ERBUntilNode;
|
|
2887
|
+
export function fromSerializedNode(node: SerializedERBForNode): ERBForNode;
|
|
2888
|
+
export function fromSerializedNode(node: SerializedERBRescueNode): ERBRescueNode;
|
|
2889
|
+
export function fromSerializedNode(node: SerializedERBEnsureNode): ERBEnsureNode;
|
|
2890
|
+
export function fromSerializedNode(node: SerializedERBBeginNode): ERBBeginNode;
|
|
2891
|
+
export function fromSerializedNode(node: SerializedERBUnlessNode): ERBUnlessNode;
|
|
2892
|
+
export function fromSerializedNode(node: SerializedERBYieldNode): ERBYieldNode;
|
|
2893
|
+
export function fromSerializedNode(node: SerializedERBInNode): ERBInNode;
|
|
2894
|
+
export function fromSerializedNode(node: SerializedNode): Node;
|
|
2895
|
+
|
|
2844
2896
|
export function fromSerializedNode(node: SerializedNode): Node {
|
|
2845
2897
|
switch (node.type) {
|
|
2846
2898
|
case "AST_DOCUMENT_NODE": return DocumentNode.from(node as SerializedDocumentNode);
|
|
2847
2899
|
case "AST_LITERAL_NODE": return LiteralNode.from(node as SerializedLiteralNode);
|
|
2848
2900
|
case "AST_HTML_OPEN_TAG_NODE": return HTMLOpenTagNode.from(node as SerializedHTMLOpenTagNode);
|
|
2849
2901
|
case "AST_HTML_CLOSE_TAG_NODE": return HTMLCloseTagNode.from(node as SerializedHTMLCloseTagNode);
|
|
2850
|
-
case "AST_HTML_SELF_CLOSE_TAG_NODE": return HTMLSelfCloseTagNode.from(node as SerializedHTMLSelfCloseTagNode);
|
|
2851
2902
|
case "AST_HTML_ELEMENT_NODE": return HTMLElementNode.from(node as SerializedHTMLElementNode);
|
|
2852
2903
|
case "AST_HTML_ATTRIBUTE_VALUE_NODE": return HTMLAttributeValueNode.from(node as SerializedHTMLAttributeValueNode);
|
|
2853
2904
|
case "AST_HTML_ATTRIBUTE_NAME_NODE": return HTMLAttributeNameNode.from(node as SerializedHTMLAttributeNameNode);
|
|
@@ -2855,6 +2906,8 @@ export function fromSerializedNode(node: SerializedNode): Node {
|
|
|
2855
2906
|
case "AST_HTML_TEXT_NODE": return HTMLTextNode.from(node as SerializedHTMLTextNode);
|
|
2856
2907
|
case "AST_HTML_COMMENT_NODE": return HTMLCommentNode.from(node as SerializedHTMLCommentNode);
|
|
2857
2908
|
case "AST_HTML_DOCTYPE_NODE": return HTMLDoctypeNode.from(node as SerializedHTMLDoctypeNode);
|
|
2909
|
+
case "AST_XML_DECLARATION_NODE": return XMLDeclarationNode.from(node as SerializedXMLDeclarationNode);
|
|
2910
|
+
case "AST_CDATA_NODE": return CDATANode.from(node as SerializedCDATANode);
|
|
2858
2911
|
case "AST_WHITESPACE_NODE": return WhitespaceNode.from(node as SerializedWhitespaceNode);
|
|
2859
2912
|
case "AST_ERB_CONTENT_NODE": return ERBContentNode.from(node as SerializedERBContentNode);
|
|
2860
2913
|
case "AST_ERB_END_NODE": return ERBEndNode.from(node as SerializedERBEndNode);
|
|
@@ -2884,7 +2937,6 @@ export type NodeType =
|
|
|
2884
2937
|
| "AST_LITERAL_NODE"
|
|
2885
2938
|
| "AST_HTML_OPEN_TAG_NODE"
|
|
2886
2939
|
| "AST_HTML_CLOSE_TAG_NODE"
|
|
2887
|
-
| "AST_HTML_SELF_CLOSE_TAG_NODE"
|
|
2888
2940
|
| "AST_HTML_ELEMENT_NODE"
|
|
2889
2941
|
| "AST_HTML_ATTRIBUTE_VALUE_NODE"
|
|
2890
2942
|
| "AST_HTML_ATTRIBUTE_NAME_NODE"
|
|
@@ -2892,6 +2944,8 @@ export type NodeType =
|
|
|
2892
2944
|
| "AST_HTML_TEXT_NODE"
|
|
2893
2945
|
| "AST_HTML_COMMENT_NODE"
|
|
2894
2946
|
| "AST_HTML_DOCTYPE_NODE"
|
|
2947
|
+
| "AST_XML_DECLARATION_NODE"
|
|
2948
|
+
| "AST_CDATA_NODE"
|
|
2895
2949
|
| "AST_WHITESPACE_NODE"
|
|
2896
2950
|
| "AST_ERB_CONTENT_NODE"
|
|
2897
2951
|
| "AST_ERB_END_NODE"
|
|
@@ -2951,8 +3005,3 @@ export const ERBNodeClasses = [
|
|
|
2951
3005
|
ERBYieldNode,
|
|
2952
3006
|
ERBInNode,
|
|
2953
3007
|
]
|
|
2954
|
-
|
|
2955
|
-
export function isERBNode(node: Node): node is ERBNode {
|
|
2956
|
-
|
|
2957
|
-
return node.constructor.name.startsWith("ERB")
|
|
2958
|
-
}
|