@herb-tools/core 0.9.0 → 0.9.1
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 +557 -10
- package/dist/herb-core.browser.js.map +1 -1
- package/dist/herb-core.cjs +570 -10
- package/dist/herb-core.cjs.map +1 -1
- package/dist/herb-core.esm.js +557 -10
- package/dist/herb-core.esm.js.map +1 -1
- package/dist/herb-core.umd.js +570 -10
- package/dist/herb-core.umd.js.map +1 -1
- package/dist/types/ast-utils.d.ts +2 -3
- package/dist/types/diagnostic.d.ts +6 -0
- package/dist/types/errors.d.ts +141 -1
- package/dist/types/node-type-guards.d.ts +19 -1
- package/dist/types/nodes.d.ts +115 -4
- package/dist/types/parser-options.d.ts +3 -0
- package/dist/types/visitor.d.ts +5 -1
- package/package.json +1 -1
- package/src/ast-utils.ts +3 -4
- package/src/diagnostic.ts +7 -0
- package/src/errors.ts +465 -17
- package/src/node-type-guards.ts +42 -1
- package/src/nodes.ts +322 -2
- package/src/parser-options.ts +6 -0
- package/src/visitor.ts +16 -1
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-0.9.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/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"
|
|
@@ -3708,6 +3708,318 @@ export class ERBUnlessNode extends Node {
|
|
|
3708
3708
|
}
|
|
3709
3709
|
}
|
|
3710
3710
|
|
|
3711
|
+
export interface SerializedRubyRenderLocalNode extends SerializedNode {
|
|
3712
|
+
type: "AST_RUBY_RENDER_LOCAL_NODE";
|
|
3713
|
+
name: SerializedToken | null;
|
|
3714
|
+
value: SerializedRubyLiteralNode | null;
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
export interface RubyRenderLocalNodeProps extends Omit<BaseNodeProps, 'type'> {
|
|
3718
|
+
type: "AST_RUBY_RENDER_LOCAL_NODE";
|
|
3719
|
+
name: Token | null;
|
|
3720
|
+
value: RubyLiteralNode | null;
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
export class RubyRenderLocalNode extends Node {
|
|
3724
|
+
declare readonly type: "AST_RUBY_RENDER_LOCAL_NODE";
|
|
3725
|
+
readonly name: Token | null;
|
|
3726
|
+
readonly value: RubyLiteralNode | null;
|
|
3727
|
+
|
|
3728
|
+
static get type(): NodeType {
|
|
3729
|
+
return "AST_RUBY_RENDER_LOCAL_NODE"
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
static from(data: SerializedRubyRenderLocalNode): RubyRenderLocalNode {
|
|
3733
|
+
return new RubyRenderLocalNode({
|
|
3734
|
+
type: data.type,
|
|
3735
|
+
location: Location.from(data.location),
|
|
3736
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
3737
|
+
name: data.name ? Token.from(data.name) : null,
|
|
3738
|
+
value: data.value ? fromSerializedNode((data.value)) as RubyLiteralNode : null,
|
|
3739
|
+
})
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
constructor(props: RubyRenderLocalNodeProps) {
|
|
3743
|
+
super(props.type, props.location, props.errors);
|
|
3744
|
+
this.name = props.name;
|
|
3745
|
+
this.value = props.value;
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
accept(visitor: Visitor): void {
|
|
3749
|
+
visitor.visitRubyRenderLocalNode(this)
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
childNodes(): (Node | null | undefined)[] {
|
|
3753
|
+
return [
|
|
3754
|
+
this.value,
|
|
3755
|
+
];
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
compactChildNodes(): Node[] {
|
|
3759
|
+
return this.childNodes().filter(node => node !== null && node !== undefined)
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
|
|
3763
|
+
recursiveErrors(): HerbError[] {
|
|
3764
|
+
return [
|
|
3765
|
+
...this.errors,
|
|
3766
|
+
this.value ? this.value.recursiveErrors() : [],
|
|
3767
|
+
].flat();
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
toJSON(): SerializedRubyRenderLocalNode {
|
|
3771
|
+
return {
|
|
3772
|
+
...super.toJSON(),
|
|
3773
|
+
type: "AST_RUBY_RENDER_LOCAL_NODE",
|
|
3774
|
+
name: this.name ? this.name.toJSON() : null,
|
|
3775
|
+
value: this.value ? this.value.toJSON() : null,
|
|
3776
|
+
};
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3779
|
+
treeInspect(): string {
|
|
3780
|
+
let output = "";
|
|
3781
|
+
|
|
3782
|
+
output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`;
|
|
3783
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
3784
|
+
output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
|
|
3785
|
+
output += `└── value: ${this.inspectNode(this.value, " ")}`;
|
|
3786
|
+
|
|
3787
|
+
return output
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
export interface SerializedERBRenderNode extends SerializedNode {
|
|
3792
|
+
type: "AST_ERB_RENDER_NODE";
|
|
3793
|
+
tag_opening: SerializedToken | null;
|
|
3794
|
+
content: SerializedToken | null;
|
|
3795
|
+
tag_closing: SerializedToken | null;
|
|
3796
|
+
// no-op for analyzed_ruby
|
|
3797
|
+
prism_node: number[] | null;
|
|
3798
|
+
partial: SerializedToken | null;
|
|
3799
|
+
template_path: SerializedToken | null;
|
|
3800
|
+
layout: SerializedToken | null;
|
|
3801
|
+
file: SerializedToken | null;
|
|
3802
|
+
inline_template: SerializedToken | null;
|
|
3803
|
+
body: SerializedToken | null;
|
|
3804
|
+
plain: SerializedToken | null;
|
|
3805
|
+
html: SerializedToken | null;
|
|
3806
|
+
renderable: SerializedToken | null;
|
|
3807
|
+
collection: SerializedToken | null;
|
|
3808
|
+
object: SerializedToken | null;
|
|
3809
|
+
as_name: SerializedToken | null;
|
|
3810
|
+
spacer_template: SerializedToken | null;
|
|
3811
|
+
formats: SerializedToken | null;
|
|
3812
|
+
variants: SerializedToken | null;
|
|
3813
|
+
handlers: SerializedToken | null;
|
|
3814
|
+
content_type: SerializedToken | null;
|
|
3815
|
+
locals: SerializedNode[];
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
export interface ERBRenderNodeProps extends Omit<BaseNodeProps, 'type'> {
|
|
3819
|
+
type: "AST_ERB_RENDER_NODE";
|
|
3820
|
+
tag_opening: Token | null;
|
|
3821
|
+
content: Token | null;
|
|
3822
|
+
tag_closing: Token | null;
|
|
3823
|
+
// no-op for analyzed_ruby
|
|
3824
|
+
prism_node: Uint8Array | null;
|
|
3825
|
+
partial: Token | null;
|
|
3826
|
+
template_path: Token | null;
|
|
3827
|
+
layout: Token | null;
|
|
3828
|
+
file: Token | null;
|
|
3829
|
+
inline_template: Token | null;
|
|
3830
|
+
body: Token | null;
|
|
3831
|
+
plain: Token | null;
|
|
3832
|
+
html: Token | null;
|
|
3833
|
+
renderable: Token | null;
|
|
3834
|
+
collection: Token | null;
|
|
3835
|
+
object: Token | null;
|
|
3836
|
+
as_name: Token | null;
|
|
3837
|
+
spacer_template: Token | null;
|
|
3838
|
+
formats: Token | null;
|
|
3839
|
+
variants: Token | null;
|
|
3840
|
+
handlers: Token | null;
|
|
3841
|
+
content_type: Token | null;
|
|
3842
|
+
locals: any[];
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
export class ERBRenderNode extends Node {
|
|
3846
|
+
declare readonly type: "AST_ERB_RENDER_NODE";
|
|
3847
|
+
readonly tag_opening: Token | null;
|
|
3848
|
+
readonly content: Token | null;
|
|
3849
|
+
readonly tag_closing: Token | null;
|
|
3850
|
+
// no-op for analyzed_ruby
|
|
3851
|
+
readonly prism_node: Uint8Array | null;
|
|
3852
|
+
readonly partial: Token | null;
|
|
3853
|
+
readonly template_path: Token | null;
|
|
3854
|
+
readonly layout: Token | null;
|
|
3855
|
+
readonly file: Token | null;
|
|
3856
|
+
readonly inline_template: Token | null;
|
|
3857
|
+
readonly body: Token | null;
|
|
3858
|
+
readonly plain: Token | null;
|
|
3859
|
+
readonly html: Token | null;
|
|
3860
|
+
readonly renderable: Token | null;
|
|
3861
|
+
readonly collection: Token | null;
|
|
3862
|
+
readonly object: Token | null;
|
|
3863
|
+
readonly as_name: Token | null;
|
|
3864
|
+
readonly spacer_template: Token | null;
|
|
3865
|
+
readonly formats: Token | null;
|
|
3866
|
+
readonly variants: Token | null;
|
|
3867
|
+
readonly handlers: Token | null;
|
|
3868
|
+
readonly content_type: Token | null;
|
|
3869
|
+
readonly locals: Node[];
|
|
3870
|
+
|
|
3871
|
+
static get type(): NodeType {
|
|
3872
|
+
return "AST_ERB_RENDER_NODE"
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
static from(data: SerializedERBRenderNode): ERBRenderNode {
|
|
3876
|
+
return new ERBRenderNode({
|
|
3877
|
+
type: data.type,
|
|
3878
|
+
location: Location.from(data.location),
|
|
3879
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
3880
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
3881
|
+
content: data.content ? Token.from(data.content) : null,
|
|
3882
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
3883
|
+
// no-op for analyzed_ruby
|
|
3884
|
+
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
3885
|
+
partial: data.partial ? Token.from(data.partial) : null,
|
|
3886
|
+
template_path: data.template_path ? Token.from(data.template_path) : null,
|
|
3887
|
+
layout: data.layout ? Token.from(data.layout) : null,
|
|
3888
|
+
file: data.file ? Token.from(data.file) : null,
|
|
3889
|
+
inline_template: data.inline_template ? Token.from(data.inline_template) : null,
|
|
3890
|
+
body: data.body ? Token.from(data.body) : null,
|
|
3891
|
+
plain: data.plain ? Token.from(data.plain) : null,
|
|
3892
|
+
html: data.html ? Token.from(data.html) : null,
|
|
3893
|
+
renderable: data.renderable ? Token.from(data.renderable) : null,
|
|
3894
|
+
collection: data.collection ? Token.from(data.collection) : null,
|
|
3895
|
+
object: data.object ? Token.from(data.object) : null,
|
|
3896
|
+
as_name: data.as_name ? Token.from(data.as_name) : null,
|
|
3897
|
+
spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null,
|
|
3898
|
+
formats: data.formats ? Token.from(data.formats) : null,
|
|
3899
|
+
variants: data.variants ? Token.from(data.variants) : null,
|
|
3900
|
+
handlers: data.handlers ? Token.from(data.handlers) : null,
|
|
3901
|
+
content_type: data.content_type ? Token.from(data.content_type) : null,
|
|
3902
|
+
locals: (data.locals || []).map(node => fromSerializedNode(node)),
|
|
3903
|
+
})
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3906
|
+
constructor(props: ERBRenderNodeProps) {
|
|
3907
|
+
super(props.type, props.location, props.errors);
|
|
3908
|
+
this.tag_opening = props.tag_opening;
|
|
3909
|
+
this.content = props.content;
|
|
3910
|
+
this.tag_closing = props.tag_closing;
|
|
3911
|
+
// no-op for analyzed_ruby
|
|
3912
|
+
this.prism_node = props.prism_node;
|
|
3913
|
+
this.partial = props.partial;
|
|
3914
|
+
this.template_path = props.template_path;
|
|
3915
|
+
this.layout = props.layout;
|
|
3916
|
+
this.file = props.file;
|
|
3917
|
+
this.inline_template = props.inline_template;
|
|
3918
|
+
this.body = props.body;
|
|
3919
|
+
this.plain = props.plain;
|
|
3920
|
+
this.html = props.html;
|
|
3921
|
+
this.renderable = props.renderable;
|
|
3922
|
+
this.collection = props.collection;
|
|
3923
|
+
this.object = props.object;
|
|
3924
|
+
this.as_name = props.as_name;
|
|
3925
|
+
this.spacer_template = props.spacer_template;
|
|
3926
|
+
this.formats = props.formats;
|
|
3927
|
+
this.variants = props.variants;
|
|
3928
|
+
this.handlers = props.handlers;
|
|
3929
|
+
this.content_type = props.content_type;
|
|
3930
|
+
this.locals = props.locals;
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
accept(visitor: Visitor): void {
|
|
3934
|
+
visitor.visitERBRenderNode(this)
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
childNodes(): (Node | null | undefined)[] {
|
|
3938
|
+
return [
|
|
3939
|
+
...this.locals,
|
|
3940
|
+
];
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
compactChildNodes(): Node[] {
|
|
3944
|
+
return this.childNodes().filter(node => node !== null && node !== undefined)
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
get prismNode(): PrismNode | null {
|
|
3948
|
+
if (!this.prism_node || !this.source) return null;
|
|
3949
|
+
return deserializePrismNode(this.prism_node, this.source);
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
recursiveErrors(): HerbError[] {
|
|
3953
|
+
return [
|
|
3954
|
+
...this.errors,
|
|
3955
|
+
...this.locals.map(node => node.recursiveErrors()),
|
|
3956
|
+
].flat();
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
toJSON(): SerializedERBRenderNode {
|
|
3960
|
+
return {
|
|
3961
|
+
...super.toJSON(),
|
|
3962
|
+
type: "AST_ERB_RENDER_NODE",
|
|
3963
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
3964
|
+
content: this.content ? this.content.toJSON() : null,
|
|
3965
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
3966
|
+
// no-op for analyzed_ruby
|
|
3967
|
+
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
3968
|
+
partial: this.partial ? this.partial.toJSON() : null,
|
|
3969
|
+
template_path: this.template_path ? this.template_path.toJSON() : null,
|
|
3970
|
+
layout: this.layout ? this.layout.toJSON() : null,
|
|
3971
|
+
file: this.file ? this.file.toJSON() : null,
|
|
3972
|
+
inline_template: this.inline_template ? this.inline_template.toJSON() : null,
|
|
3973
|
+
body: this.body ? this.body.toJSON() : null,
|
|
3974
|
+
plain: this.plain ? this.plain.toJSON() : null,
|
|
3975
|
+
html: this.html ? this.html.toJSON() : null,
|
|
3976
|
+
renderable: this.renderable ? this.renderable.toJSON() : null,
|
|
3977
|
+
collection: this.collection ? this.collection.toJSON() : null,
|
|
3978
|
+
object: this.object ? this.object.toJSON() : null,
|
|
3979
|
+
as_name: this.as_name ? this.as_name.toJSON() : null,
|
|
3980
|
+
spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null,
|
|
3981
|
+
formats: this.formats ? this.formats.toJSON() : null,
|
|
3982
|
+
variants: this.variants ? this.variants.toJSON() : null,
|
|
3983
|
+
handlers: this.handlers ? this.handlers.toJSON() : null,
|
|
3984
|
+
content_type: this.content_type ? this.content_type.toJSON() : null,
|
|
3985
|
+
locals: this.locals.map(node => node.toJSON()),
|
|
3986
|
+
};
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
treeInspect(): string {
|
|
3990
|
+
let output = "";
|
|
3991
|
+
|
|
3992
|
+
output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
|
|
3993
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
3994
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
3995
|
+
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
3996
|
+
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
3997
|
+
if (this.prism_node) {
|
|
3998
|
+
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
3999
|
+
}
|
|
4000
|
+
output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
|
|
4001
|
+
output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
|
|
4002
|
+
output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
|
|
4003
|
+
output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`;
|
|
4004
|
+
output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`;
|
|
4005
|
+
output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`;
|
|
4006
|
+
output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`;
|
|
4007
|
+
output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`;
|
|
4008
|
+
output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`;
|
|
4009
|
+
output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`;
|
|
4010
|
+
output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`;
|
|
4011
|
+
output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`;
|
|
4012
|
+
output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`;
|
|
4013
|
+
output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`;
|
|
4014
|
+
output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`;
|
|
4015
|
+
output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`;
|
|
4016
|
+
output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`;
|
|
4017
|
+
output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
|
|
4018
|
+
|
|
4019
|
+
return output
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
|
|
3711
4023
|
export interface SerializedERBYieldNode extends SerializedNode {
|
|
3712
4024
|
type: "AST_ERB_YIELD_NODE";
|
|
3713
4025
|
tag_opening: SerializedToken | null;
|
|
@@ -3896,7 +4208,7 @@ export class ERBInNode extends Node {
|
|
|
3896
4208
|
|
|
3897
4209
|
|
|
3898
4210
|
export type ConcreteNode =
|
|
3899
|
-
DocumentNode | LiteralNode | HTMLOpenTagNode | HTMLConditionalOpenTagNode | HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode | HTMLElementNode | HTMLConditionalElementNode | HTMLAttributeValueNode | HTMLAttributeNameNode | HTMLAttributeNode | RubyLiteralNode | RubyHTMLAttributesSplatNode | ERBOpenTagNode | HTMLTextNode | HTMLCommentNode | HTMLDoctypeNode | XMLDeclarationNode | CDATANode | WhitespaceNode | ERBContentNode | ERBEndNode | ERBElseNode | ERBIfNode | ERBBlockNode | ERBWhenNode | ERBCaseNode | ERBCaseMatchNode | ERBWhileNode | ERBUntilNode | ERBForNode | ERBRescueNode | ERBEnsureNode | ERBBeginNode | ERBUnlessNode | ERBYieldNode | ERBInNode
|
|
4211
|
+
DocumentNode | LiteralNode | HTMLOpenTagNode | HTMLConditionalOpenTagNode | HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode | HTMLElementNode | HTMLConditionalElementNode | HTMLAttributeValueNode | HTMLAttributeNameNode | HTMLAttributeNode | RubyLiteralNode | RubyHTMLAttributesSplatNode | ERBOpenTagNode | HTMLTextNode | HTMLCommentNode | HTMLDoctypeNode | XMLDeclarationNode | CDATANode | WhitespaceNode | ERBContentNode | ERBEndNode | ERBElseNode | ERBIfNode | ERBBlockNode | ERBWhenNode | ERBCaseNode | ERBCaseMatchNode | ERBWhileNode | ERBUntilNode | ERBForNode | ERBRescueNode | ERBEnsureNode | ERBBeginNode | ERBUnlessNode | RubyRenderLocalNode | ERBRenderNode | ERBYieldNode | ERBInNode
|
|
3900
4212
|
export function fromSerializedNode(node: SerializedDocumentNode): DocumentNode;
|
|
3901
4213
|
export function fromSerializedNode(node: SerializedLiteralNode): LiteralNode;
|
|
3902
4214
|
export function fromSerializedNode(node: SerializedHTMLOpenTagNode): HTMLOpenTagNode;
|
|
@@ -3933,6 +4245,8 @@ export function fromSerializedNode(node: SerializedERBRescueNode): ERBRescueNode
|
|
|
3933
4245
|
export function fromSerializedNode(node: SerializedERBEnsureNode): ERBEnsureNode;
|
|
3934
4246
|
export function fromSerializedNode(node: SerializedERBBeginNode): ERBBeginNode;
|
|
3935
4247
|
export function fromSerializedNode(node: SerializedERBUnlessNode): ERBUnlessNode;
|
|
4248
|
+
export function fromSerializedNode(node: SerializedRubyRenderLocalNode): RubyRenderLocalNode;
|
|
4249
|
+
export function fromSerializedNode(node: SerializedERBRenderNode): ERBRenderNode;
|
|
3936
4250
|
export function fromSerializedNode(node: SerializedERBYieldNode): ERBYieldNode;
|
|
3937
4251
|
export function fromSerializedNode(node: SerializedERBInNode): ERBInNode;
|
|
3938
4252
|
export function fromSerializedNode(node: SerializedNode): Node;
|
|
@@ -3975,6 +4289,8 @@ export function fromSerializedNode(node: SerializedNode): Node {
|
|
|
3975
4289
|
case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node as SerializedERBEnsureNode);
|
|
3976
4290
|
case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node as SerializedERBBeginNode);
|
|
3977
4291
|
case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node as SerializedERBUnlessNode);
|
|
4292
|
+
case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node as SerializedRubyRenderLocalNode);
|
|
4293
|
+
case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node as SerializedERBRenderNode);
|
|
3978
4294
|
case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node as SerializedERBYieldNode);
|
|
3979
4295
|
case "AST_ERB_IN_NODE": return ERBInNode.from(node as SerializedERBInNode);
|
|
3980
4296
|
|
|
@@ -4020,6 +4336,8 @@ export type NodeType =
|
|
|
4020
4336
|
| "AST_ERB_ENSURE_NODE"
|
|
4021
4337
|
| "AST_ERB_BEGIN_NODE"
|
|
4022
4338
|
| "AST_ERB_UNLESS_NODE"
|
|
4339
|
+
| "AST_RUBY_RENDER_LOCAL_NODE"
|
|
4340
|
+
| "AST_ERB_RENDER_NODE"
|
|
4023
4341
|
| "AST_ERB_YIELD_NODE"
|
|
4024
4342
|
| "AST_ERB_IN_NODE"
|
|
4025
4343
|
|
|
@@ -4042,6 +4360,7 @@ export type ERBNode =
|
|
|
4042
4360
|
| ERBEnsureNode
|
|
4043
4361
|
| ERBBeginNode
|
|
4044
4362
|
| ERBUnlessNode
|
|
4363
|
+
| ERBRenderNode
|
|
4045
4364
|
| ERBYieldNode
|
|
4046
4365
|
| ERBInNode
|
|
4047
4366
|
|
|
@@ -4062,6 +4381,7 @@ export const ERBNodeClasses = [
|
|
|
4062
4381
|
ERBEnsureNode,
|
|
4063
4382
|
ERBBeginNode,
|
|
4064
4383
|
ERBUnlessNode,
|
|
4384
|
+
ERBRenderNode,
|
|
4065
4385
|
ERBYieldNode,
|
|
4066
4386
|
ERBInNode,
|
|
4067
4387
|
]
|
package/src/parser-options.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface ParseOptions {
|
|
|
3
3
|
analyze?: boolean
|
|
4
4
|
strict?: boolean
|
|
5
5
|
action_view_helpers?: boolean
|
|
6
|
+
render_nodes?: boolean
|
|
6
7
|
prism_nodes?: boolean
|
|
7
8
|
prism_nodes_deep?: boolean
|
|
8
9
|
prism_program?: boolean
|
|
@@ -15,6 +16,7 @@ export const DEFAULT_PARSER_OPTIONS: SerializedParserOptions = {
|
|
|
15
16
|
analyze: true,
|
|
16
17
|
strict: true,
|
|
17
18
|
action_view_helpers: false,
|
|
19
|
+
render_nodes: false,
|
|
18
20
|
prism_nodes: false,
|
|
19
21
|
prism_nodes_deep: false,
|
|
20
22
|
prism_program: false,
|
|
@@ -36,6 +38,9 @@ export class ParserOptions {
|
|
|
36
38
|
/** Whether ActionView tag helper transformation was enabled during parsing. */
|
|
37
39
|
readonly action_view_helpers: boolean
|
|
38
40
|
|
|
41
|
+
/** Whether ActionView render call detection was enabled during parsing. */
|
|
42
|
+
readonly render_nodes: boolean
|
|
43
|
+
|
|
39
44
|
/** Whether Prism node serialization was enabled during parsing. */
|
|
40
45
|
readonly prism_nodes: boolean
|
|
41
46
|
|
|
@@ -54,6 +59,7 @@ export class ParserOptions {
|
|
|
54
59
|
this.track_whitespace = options.track_whitespace ?? DEFAULT_PARSER_OPTIONS.track_whitespace
|
|
55
60
|
this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze
|
|
56
61
|
this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers
|
|
62
|
+
this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes
|
|
57
63
|
this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes
|
|
58
64
|
this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep
|
|
59
65
|
this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program
|
package/src/visitor.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-0.9.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/visitor.ts.erb
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
Node,
|
|
@@ -40,6 +40,8 @@ import {
|
|
|
40
40
|
ERBEnsureNode,
|
|
41
41
|
ERBBeginNode,
|
|
42
42
|
ERBUnlessNode,
|
|
43
|
+
RubyRenderLocalNode,
|
|
44
|
+
ERBRenderNode,
|
|
43
45
|
ERBYieldNode,
|
|
44
46
|
ERBInNode,
|
|
45
47
|
} from "./nodes.js"
|
|
@@ -88,6 +90,8 @@ export interface IVisitor {
|
|
|
88
90
|
visitERBEnsureNode(node: ERBEnsureNode): void
|
|
89
91
|
visitERBBeginNode(node: ERBBeginNode): void
|
|
90
92
|
visitERBUnlessNode(node: ERBUnlessNode): void
|
|
93
|
+
visitRubyRenderLocalNode(node: RubyRenderLocalNode): void
|
|
94
|
+
visitERBRenderNode(node: ERBRenderNode): void
|
|
91
95
|
visitERBYieldNode(node: ERBYieldNode): void
|
|
92
96
|
visitERBInNode(node: ERBInNode): void
|
|
93
97
|
visitNode(node: Node): void
|
|
@@ -313,6 +317,17 @@ export class Visitor implements IVisitor {
|
|
|
313
317
|
this.visitChildNodes(node)
|
|
314
318
|
}
|
|
315
319
|
|
|
320
|
+
visitRubyRenderLocalNode(node: RubyRenderLocalNode): void {
|
|
321
|
+
this.visitNode(node)
|
|
322
|
+
this.visitChildNodes(node)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
visitERBRenderNode(node: ERBRenderNode): void {
|
|
326
|
+
this.visitNode(node)
|
|
327
|
+
this.visitERBNode(node)
|
|
328
|
+
this.visitChildNodes(node)
|
|
329
|
+
}
|
|
330
|
+
|
|
316
331
|
visitERBYieldNode(node: ERBYieldNode): void {
|
|
317
332
|
this.visitNode(node)
|
|
318
333
|
this.visitERBNode(node)
|