@herb-tools/rewriter 0.9.4 → 0.9.5
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/index.cjs +212 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +212 -73
- package/dist/index.esm.js.map +1 -1
- package/dist/loader.cjs +212 -73
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.esm.js +212 -73
- package/dist/loader.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/built-ins/erb-string-to-direct-output.ts +6 -12
package/dist/loader.esm.js
CHANGED
|
@@ -207,7 +207,7 @@ class Token {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
210
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
210
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.5/templates/javascript/packages/core/src/errors.ts.erb
|
|
211
211
|
class HerbError {
|
|
212
212
|
type;
|
|
213
213
|
message;
|
|
@@ -20355,6 +20355,17 @@ function inspectPrismSerialized(bytes, source, prefix = "") {
|
|
|
20355
20355
|
}
|
|
20356
20356
|
}
|
|
20357
20357
|
|
|
20358
|
+
/**
|
|
20359
|
+
* Checks if a Prism node is of a specific type by comparing constructor names.
|
|
20360
|
+
*
|
|
20361
|
+
* This is preferred over `instanceof` because `@ruby/prism` classes may be
|
|
20362
|
+
* duplicated across bundled packages, causing `instanceof` checks to fail.
|
|
20363
|
+
*/
|
|
20364
|
+
function isPrismNodeType(node, type) {
|
|
20365
|
+
if (!node)
|
|
20366
|
+
return false;
|
|
20367
|
+
return node.constructor?.name === type;
|
|
20368
|
+
}
|
|
20358
20369
|
/**
|
|
20359
20370
|
* Deserialize a Prism parse result from the raw bytes produced by pm_serialize().
|
|
20360
20371
|
*
|
|
@@ -20386,7 +20397,7 @@ function deserializePrismNode(bytes, source) {
|
|
|
20386
20397
|
}
|
|
20387
20398
|
|
|
20388
20399
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
20389
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
20400
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.5/templates/javascript/packages/core/src/nodes.ts.erb
|
|
20390
20401
|
class Node {
|
|
20391
20402
|
type;
|
|
20392
20403
|
location;
|
|
@@ -22007,6 +22018,7 @@ class ERBBlockNode extends Node {
|
|
|
22007
22018
|
tag_closing;
|
|
22008
22019
|
prism_node;
|
|
22009
22020
|
body;
|
|
22021
|
+
block_arguments;
|
|
22010
22022
|
rescue_clause;
|
|
22011
22023
|
else_clause;
|
|
22012
22024
|
ensure_clause;
|
|
@@ -22024,6 +22036,7 @@ class ERBBlockNode extends Node {
|
|
|
22024
22036
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
22025
22037
|
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
22026
22038
|
body: (data.body || []).map(node => fromSerializedNode(node)),
|
|
22039
|
+
block_arguments: (data.block_arguments || []).map(node => fromSerializedNode(node)),
|
|
22027
22040
|
rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) : null,
|
|
22028
22041
|
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
22029
22042
|
ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) : null,
|
|
@@ -22037,6 +22050,7 @@ class ERBBlockNode extends Node {
|
|
|
22037
22050
|
this.tag_closing = props.tag_closing;
|
|
22038
22051
|
this.prism_node = props.prism_node;
|
|
22039
22052
|
this.body = props.body;
|
|
22053
|
+
this.block_arguments = props.block_arguments;
|
|
22040
22054
|
this.rescue_clause = props.rescue_clause;
|
|
22041
22055
|
this.else_clause = props.else_clause;
|
|
22042
22056
|
this.ensure_clause = props.ensure_clause;
|
|
@@ -22048,6 +22062,7 @@ class ERBBlockNode extends Node {
|
|
|
22048
22062
|
childNodes() {
|
|
22049
22063
|
return [
|
|
22050
22064
|
...this.body,
|
|
22065
|
+
...this.block_arguments,
|
|
22051
22066
|
this.rescue_clause,
|
|
22052
22067
|
this.else_clause,
|
|
22053
22068
|
this.ensure_clause,
|
|
@@ -22066,6 +22081,7 @@ class ERBBlockNode extends Node {
|
|
|
22066
22081
|
return [
|
|
22067
22082
|
...this.errors,
|
|
22068
22083
|
...this.body.map(node => node.recursiveErrors()),
|
|
22084
|
+
...this.block_arguments.map(node => node.recursiveErrors()),
|
|
22069
22085
|
this.rescue_clause ? this.rescue_clause.recursiveErrors() : [],
|
|
22070
22086
|
this.else_clause ? this.else_clause.recursiveErrors() : [],
|
|
22071
22087
|
this.ensure_clause ? this.ensure_clause.recursiveErrors() : [],
|
|
@@ -22081,6 +22097,7 @@ class ERBBlockNode extends Node {
|
|
|
22081
22097
|
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
22082
22098
|
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
22083
22099
|
body: this.body.map(node => node.toJSON()),
|
|
22100
|
+
block_arguments: this.block_arguments.map(node => node.toJSON()),
|
|
22084
22101
|
rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null,
|
|
22085
22102
|
else_clause: this.else_clause ? this.else_clause.toJSON() : null,
|
|
22086
22103
|
ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null,
|
|
@@ -22098,6 +22115,7 @@ class ERBBlockNode extends Node {
|
|
|
22098
22115
|
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
22099
22116
|
}
|
|
22100
22117
|
output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
|
|
22118
|
+
output += `├── block_arguments: ${this.inspectArray(this.block_arguments, "│ ")}`;
|
|
22101
22119
|
output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`;
|
|
22102
22120
|
output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
|
|
22103
22121
|
output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`;
|
|
@@ -23005,12 +23023,7 @@ class RubyRenderLocalNode extends Node {
|
|
|
23005
23023
|
return output;
|
|
23006
23024
|
}
|
|
23007
23025
|
}
|
|
23008
|
-
class
|
|
23009
|
-
tag_opening;
|
|
23010
|
-
content;
|
|
23011
|
-
tag_closing;
|
|
23012
|
-
// no-op for analyzed_ruby
|
|
23013
|
-
prism_node;
|
|
23026
|
+
class RubyRenderKeywordsNode extends Node {
|
|
23014
23027
|
partial;
|
|
23015
23028
|
template_path;
|
|
23016
23029
|
layout;
|
|
@@ -23030,18 +23043,13 @@ class ERBRenderNode extends Node {
|
|
|
23030
23043
|
content_type;
|
|
23031
23044
|
locals;
|
|
23032
23045
|
static get type() {
|
|
23033
|
-
return "
|
|
23046
|
+
return "AST_RUBY_RENDER_KEYWORDS_NODE";
|
|
23034
23047
|
}
|
|
23035
23048
|
static from(data) {
|
|
23036
|
-
return new
|
|
23049
|
+
return new RubyRenderKeywordsNode({
|
|
23037
23050
|
type: data.type,
|
|
23038
23051
|
location: Location.from(data.location),
|
|
23039
23052
|
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
23040
|
-
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
23041
|
-
content: data.content ? Token.from(data.content) : null,
|
|
23042
|
-
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
23043
|
-
// no-op for analyzed_ruby
|
|
23044
|
-
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
23045
23053
|
partial: data.partial ? Token.from(data.partial) : null,
|
|
23046
23054
|
template_path: data.template_path ? Token.from(data.template_path) : null,
|
|
23047
23055
|
layout: data.layout ? Token.from(data.layout) : null,
|
|
@@ -23064,11 +23072,6 @@ class ERBRenderNode extends Node {
|
|
|
23064
23072
|
}
|
|
23065
23073
|
constructor(props) {
|
|
23066
23074
|
super(props.type, props.location, props.errors);
|
|
23067
|
-
this.tag_opening = props.tag_opening;
|
|
23068
|
-
this.content = props.content;
|
|
23069
|
-
this.tag_closing = props.tag_closing;
|
|
23070
|
-
// no-op for analyzed_ruby
|
|
23071
|
-
this.prism_node = props.prism_node;
|
|
23072
23075
|
this.partial = props.partial;
|
|
23073
23076
|
this.template_path = props.template_path;
|
|
23074
23077
|
this.layout = props.layout;
|
|
@@ -23089,7 +23092,7 @@ class ERBRenderNode extends Node {
|
|
|
23089
23092
|
this.locals = props.locals;
|
|
23090
23093
|
}
|
|
23091
23094
|
accept(visitor) {
|
|
23092
|
-
visitor.
|
|
23095
|
+
visitor.visitRubyRenderKeywordsNode(this);
|
|
23093
23096
|
}
|
|
23094
23097
|
childNodes() {
|
|
23095
23098
|
return [
|
|
@@ -23099,11 +23102,6 @@ class ERBRenderNode extends Node {
|
|
|
23099
23102
|
compactChildNodes() {
|
|
23100
23103
|
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
23101
23104
|
}
|
|
23102
|
-
get prismNode() {
|
|
23103
|
-
if (!this.prism_node || !this.source)
|
|
23104
|
-
return null;
|
|
23105
|
-
return deserializePrismNode(this.prism_node, this.source);
|
|
23106
|
-
}
|
|
23107
23105
|
recursiveErrors() {
|
|
23108
23106
|
return [
|
|
23109
23107
|
...this.errors,
|
|
@@ -23113,12 +23111,7 @@ class ERBRenderNode extends Node {
|
|
|
23113
23111
|
toJSON() {
|
|
23114
23112
|
return {
|
|
23115
23113
|
...super.toJSON(),
|
|
23116
|
-
type: "
|
|
23117
|
-
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
23118
|
-
content: this.content ? this.content.toJSON() : null,
|
|
23119
|
-
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
23120
|
-
// no-op for analyzed_ruby
|
|
23121
|
-
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
23114
|
+
type: "AST_RUBY_RENDER_KEYWORDS_NODE",
|
|
23122
23115
|
partial: this.partial ? this.partial.toJSON() : null,
|
|
23123
23116
|
template_path: this.template_path ? this.template_path.toJSON() : null,
|
|
23124
23117
|
layout: this.layout ? this.layout.toJSON() : null,
|
|
@@ -23141,14 +23134,8 @@ class ERBRenderNode extends Node {
|
|
|
23141
23134
|
}
|
|
23142
23135
|
treeInspect() {
|
|
23143
23136
|
let output = "";
|
|
23144
|
-
output += `@
|
|
23137
|
+
output += `@ RubyRenderKeywordsNode ${this.location.treeInspectWithLabel()}\n`;
|
|
23145
23138
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
23146
|
-
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
23147
|
-
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
23148
|
-
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
23149
|
-
if (this.prism_node) {
|
|
23150
|
-
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
23151
|
-
}
|
|
23152
23139
|
output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
|
|
23153
23140
|
output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
|
|
23154
23141
|
output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
|
|
@@ -23170,34 +23157,156 @@ class ERBRenderNode extends Node {
|
|
|
23170
23157
|
return output;
|
|
23171
23158
|
}
|
|
23172
23159
|
}
|
|
23173
|
-
class
|
|
23160
|
+
class ERBRenderNode extends Node {
|
|
23161
|
+
tag_opening;
|
|
23162
|
+
content;
|
|
23163
|
+
tag_closing;
|
|
23164
|
+
// no-op for analyzed_ruby
|
|
23165
|
+
prism_node;
|
|
23166
|
+
keywords;
|
|
23167
|
+
body;
|
|
23168
|
+
block_arguments;
|
|
23169
|
+
rescue_clause;
|
|
23170
|
+
else_clause;
|
|
23171
|
+
ensure_clause;
|
|
23172
|
+
end_node;
|
|
23173
|
+
static get type() {
|
|
23174
|
+
return "AST_ERB_RENDER_NODE";
|
|
23175
|
+
}
|
|
23176
|
+
static from(data) {
|
|
23177
|
+
return new ERBRenderNode({
|
|
23178
|
+
type: data.type,
|
|
23179
|
+
location: Location.from(data.location),
|
|
23180
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
23181
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
23182
|
+
content: data.content ? Token.from(data.content) : null,
|
|
23183
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
23184
|
+
// no-op for analyzed_ruby
|
|
23185
|
+
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
23186
|
+
keywords: data.keywords ? fromSerializedNode((data.keywords)) : null,
|
|
23187
|
+
body: (data.body || []).map(node => fromSerializedNode(node)),
|
|
23188
|
+
block_arguments: (data.block_arguments || []).map(node => fromSerializedNode(node)),
|
|
23189
|
+
rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) : null,
|
|
23190
|
+
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
23191
|
+
ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) : null,
|
|
23192
|
+
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
23193
|
+
});
|
|
23194
|
+
}
|
|
23195
|
+
constructor(props) {
|
|
23196
|
+
super(props.type, props.location, props.errors);
|
|
23197
|
+
this.tag_opening = props.tag_opening;
|
|
23198
|
+
this.content = props.content;
|
|
23199
|
+
this.tag_closing = props.tag_closing;
|
|
23200
|
+
// no-op for analyzed_ruby
|
|
23201
|
+
this.prism_node = props.prism_node;
|
|
23202
|
+
this.keywords = props.keywords;
|
|
23203
|
+
this.body = props.body;
|
|
23204
|
+
this.block_arguments = props.block_arguments;
|
|
23205
|
+
this.rescue_clause = props.rescue_clause;
|
|
23206
|
+
this.else_clause = props.else_clause;
|
|
23207
|
+
this.ensure_clause = props.ensure_clause;
|
|
23208
|
+
this.end_node = props.end_node;
|
|
23209
|
+
}
|
|
23210
|
+
accept(visitor) {
|
|
23211
|
+
visitor.visitERBRenderNode(this);
|
|
23212
|
+
}
|
|
23213
|
+
childNodes() {
|
|
23214
|
+
return [
|
|
23215
|
+
this.keywords,
|
|
23216
|
+
...this.body,
|
|
23217
|
+
...this.block_arguments,
|
|
23218
|
+
this.rescue_clause,
|
|
23219
|
+
this.else_clause,
|
|
23220
|
+
this.ensure_clause,
|
|
23221
|
+
this.end_node,
|
|
23222
|
+
];
|
|
23223
|
+
}
|
|
23224
|
+
compactChildNodes() {
|
|
23225
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
23226
|
+
}
|
|
23227
|
+
get prismNode() {
|
|
23228
|
+
if (!this.prism_node || !this.source)
|
|
23229
|
+
return null;
|
|
23230
|
+
return deserializePrismNode(this.prism_node, this.source);
|
|
23231
|
+
}
|
|
23232
|
+
recursiveErrors() {
|
|
23233
|
+
return [
|
|
23234
|
+
...this.errors,
|
|
23235
|
+
this.keywords ? this.keywords.recursiveErrors() : [],
|
|
23236
|
+
...this.body.map(node => node.recursiveErrors()),
|
|
23237
|
+
...this.block_arguments.map(node => node.recursiveErrors()),
|
|
23238
|
+
this.rescue_clause ? this.rescue_clause.recursiveErrors() : [],
|
|
23239
|
+
this.else_clause ? this.else_clause.recursiveErrors() : [],
|
|
23240
|
+
this.ensure_clause ? this.ensure_clause.recursiveErrors() : [],
|
|
23241
|
+
this.end_node ? this.end_node.recursiveErrors() : [],
|
|
23242
|
+
].flat();
|
|
23243
|
+
}
|
|
23244
|
+
toJSON() {
|
|
23245
|
+
return {
|
|
23246
|
+
...super.toJSON(),
|
|
23247
|
+
type: "AST_ERB_RENDER_NODE",
|
|
23248
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
23249
|
+
content: this.content ? this.content.toJSON() : null,
|
|
23250
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
23251
|
+
// no-op for analyzed_ruby
|
|
23252
|
+
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
23253
|
+
keywords: this.keywords ? this.keywords.toJSON() : null,
|
|
23254
|
+
body: this.body.map(node => node.toJSON()),
|
|
23255
|
+
block_arguments: this.block_arguments.map(node => node.toJSON()),
|
|
23256
|
+
rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null,
|
|
23257
|
+
else_clause: this.else_clause ? this.else_clause.toJSON() : null,
|
|
23258
|
+
ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null,
|
|
23259
|
+
end_node: this.end_node ? this.end_node.toJSON() : null,
|
|
23260
|
+
};
|
|
23261
|
+
}
|
|
23262
|
+
treeInspect() {
|
|
23263
|
+
let output = "";
|
|
23264
|
+
output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
|
|
23265
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
23266
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
23267
|
+
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
23268
|
+
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
23269
|
+
if (this.prism_node) {
|
|
23270
|
+
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
23271
|
+
}
|
|
23272
|
+
output += `├── keywords: ${this.inspectNode(this.keywords, "│ ")}`;
|
|
23273
|
+
output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
|
|
23274
|
+
output += `├── block_arguments: ${this.inspectArray(this.block_arguments, "│ ")}`;
|
|
23275
|
+
output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`;
|
|
23276
|
+
output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
|
|
23277
|
+
output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`;
|
|
23278
|
+
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
23279
|
+
return output;
|
|
23280
|
+
}
|
|
23281
|
+
}
|
|
23282
|
+
class RubyParameterNode extends Node {
|
|
23174
23283
|
name;
|
|
23175
23284
|
default_value;
|
|
23285
|
+
kind;
|
|
23176
23286
|
required;
|
|
23177
|
-
double_splat;
|
|
23178
23287
|
static get type() {
|
|
23179
|
-
return "
|
|
23288
|
+
return "AST_RUBY_PARAMETER_NODE";
|
|
23180
23289
|
}
|
|
23181
23290
|
static from(data) {
|
|
23182
|
-
return new
|
|
23291
|
+
return new RubyParameterNode({
|
|
23183
23292
|
type: data.type,
|
|
23184
23293
|
location: Location.from(data.location),
|
|
23185
23294
|
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
23186
23295
|
name: data.name ? Token.from(data.name) : null,
|
|
23187
23296
|
default_value: data.default_value ? fromSerializedNode((data.default_value)) : null,
|
|
23297
|
+
kind: data.kind,
|
|
23188
23298
|
required: data.required,
|
|
23189
|
-
double_splat: data.double_splat,
|
|
23190
23299
|
});
|
|
23191
23300
|
}
|
|
23192
23301
|
constructor(props) {
|
|
23193
23302
|
super(props.type, props.location, props.errors);
|
|
23194
23303
|
this.name = props.name;
|
|
23195
23304
|
this.default_value = props.default_value;
|
|
23305
|
+
this.kind = props.kind;
|
|
23196
23306
|
this.required = props.required;
|
|
23197
|
-
this.double_splat = props.double_splat;
|
|
23198
23307
|
}
|
|
23199
23308
|
accept(visitor) {
|
|
23200
|
-
visitor.
|
|
23309
|
+
visitor.visitRubyParameterNode(this);
|
|
23201
23310
|
}
|
|
23202
23311
|
childNodes() {
|
|
23203
23312
|
return [
|
|
@@ -23216,21 +23325,21 @@ class RubyStrictLocalNode extends Node {
|
|
|
23216
23325
|
toJSON() {
|
|
23217
23326
|
return {
|
|
23218
23327
|
...super.toJSON(),
|
|
23219
|
-
type: "
|
|
23328
|
+
type: "AST_RUBY_PARAMETER_NODE",
|
|
23220
23329
|
name: this.name ? this.name.toJSON() : null,
|
|
23221
23330
|
default_value: this.default_value ? this.default_value.toJSON() : null,
|
|
23331
|
+
kind: this.kind,
|
|
23222
23332
|
required: this.required,
|
|
23223
|
-
double_splat: this.double_splat,
|
|
23224
23333
|
};
|
|
23225
23334
|
}
|
|
23226
23335
|
treeInspect() {
|
|
23227
23336
|
let output = "";
|
|
23228
|
-
output += `@
|
|
23337
|
+
output += `@ RubyParameterNode ${this.location.treeInspectWithLabel()}\n`;
|
|
23229
23338
|
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
23230
23339
|
output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
|
|
23231
23340
|
output += `├── default_value: ${this.inspectNode(this.default_value, "│ ")}`;
|
|
23232
|
-
output += `├──
|
|
23233
|
-
output += `└──
|
|
23341
|
+
output += `├── kind: ${this.kind ? JSON.stringify(this.kind) : "∅"}\n`;
|
|
23342
|
+
output += `└── required: ${typeof this.required === 'boolean' ? String(this.required) : "∅"}\n`;
|
|
23234
23343
|
return output;
|
|
23235
23344
|
}
|
|
23236
23345
|
}
|
|
@@ -23478,8 +23587,9 @@ function fromSerializedNode(node) {
|
|
|
23478
23587
|
case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node);
|
|
23479
23588
|
case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
|
|
23480
23589
|
case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
|
|
23590
|
+
case "AST_RUBY_RENDER_KEYWORDS_NODE": return RubyRenderKeywordsNode.from(node);
|
|
23481
23591
|
case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
|
|
23482
|
-
case "
|
|
23592
|
+
case "AST_RUBY_PARAMETER_NODE": return RubyParameterNode.from(node);
|
|
23483
23593
|
case "AST_ERB_STRICT_LOCALS_NODE": return ERBStrictLocalsNode.from(node);
|
|
23484
23594
|
case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
|
|
23485
23595
|
case "AST_ERB_IN_NODE": return ERBInNode.from(node);
|
|
@@ -23655,7 +23765,7 @@ class ParseResult extends Result {
|
|
|
23655
23765
|
}
|
|
23656
23766
|
|
|
23657
23767
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
23658
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23768
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.5/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
23659
23769
|
/**
|
|
23660
23770
|
* Type guard functions for AST nodes.
|
|
23661
23771
|
* These functions provide type checking by combining both instanceof
|
|
@@ -23958,6 +24068,14 @@ function isRubyRenderLocalNode(node) {
|
|
|
23958
24068
|
return false;
|
|
23959
24069
|
return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || node.constructor.type === "AST_RUBY_RENDER_LOCAL_NODE";
|
|
23960
24070
|
}
|
|
24071
|
+
/**
|
|
24072
|
+
* Checks if a node is a RubyRenderKeywordsNode
|
|
24073
|
+
*/
|
|
24074
|
+
function isRubyRenderKeywordsNode(node) {
|
|
24075
|
+
if (!node)
|
|
24076
|
+
return false;
|
|
24077
|
+
return node instanceof RubyRenderKeywordsNode || node.type === "AST_RUBY_RENDER_KEYWORDS_NODE" || node.constructor.type === "AST_RUBY_RENDER_KEYWORDS_NODE";
|
|
24078
|
+
}
|
|
23961
24079
|
/**
|
|
23962
24080
|
* Checks if a node is a ERBRenderNode
|
|
23963
24081
|
*/
|
|
@@ -23967,12 +24085,12 @@ function isERBRenderNode(node) {
|
|
|
23967
24085
|
return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
|
|
23968
24086
|
}
|
|
23969
24087
|
/**
|
|
23970
|
-
* Checks if a node is a
|
|
24088
|
+
* Checks if a node is a RubyParameterNode
|
|
23971
24089
|
*/
|
|
23972
|
-
function
|
|
24090
|
+
function isRubyParameterNode(node) {
|
|
23973
24091
|
if (!node)
|
|
23974
24092
|
return false;
|
|
23975
|
-
return node instanceof
|
|
24093
|
+
return node instanceof RubyParameterNode || node.type === "AST_RUBY_PARAMETER_NODE" || node.constructor.type === "AST_RUBY_PARAMETER_NODE";
|
|
23976
24094
|
}
|
|
23977
24095
|
/**
|
|
23978
24096
|
* Checks if a node is a ERBStrictLocalsNode
|
|
@@ -24071,8 +24189,9 @@ const NODE_TYPE_GUARDS = new Map([
|
|
|
24071
24189
|
[ERBBeginNode, isERBBeginNode],
|
|
24072
24190
|
[ERBUnlessNode, isERBUnlessNode],
|
|
24073
24191
|
[RubyRenderLocalNode, isRubyRenderLocalNode],
|
|
24192
|
+
[RubyRenderKeywordsNode, isRubyRenderKeywordsNode],
|
|
24074
24193
|
[ERBRenderNode, isERBRenderNode],
|
|
24075
|
-
[
|
|
24194
|
+
[RubyParameterNode, isRubyParameterNode],
|
|
24076
24195
|
[ERBStrictLocalsNode, isERBStrictLocalsNode],
|
|
24077
24196
|
[ERBYieldNode, isERBYieldNode],
|
|
24078
24197
|
[ERBInNode, isERBInNode],
|
|
@@ -24125,8 +24244,9 @@ const AST_TYPE_GUARDS = new Map([
|
|
|
24125
24244
|
["AST_ERB_BEGIN_NODE", isERBBeginNode],
|
|
24126
24245
|
["AST_ERB_UNLESS_NODE", isERBUnlessNode],
|
|
24127
24246
|
["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
|
|
24247
|
+
["AST_RUBY_RENDER_KEYWORDS_NODE", isRubyRenderKeywordsNode],
|
|
24128
24248
|
["AST_ERB_RENDER_NODE", isERBRenderNode],
|
|
24129
|
-
["
|
|
24249
|
+
["AST_RUBY_PARAMETER_NODE", isRubyParameterNode],
|
|
24130
24250
|
["AST_ERB_STRICT_LOCALS_NODE", isERBStrictLocalsNode],
|
|
24131
24251
|
["AST_ERB_YIELD_NODE", isERBYieldNode],
|
|
24132
24252
|
["AST_ERB_IN_NODE", isERBInNode],
|
|
@@ -24441,7 +24561,7 @@ function createERBOutputNode(expression, tagOpening = "<%=", tagClosing = "%>")
|
|
|
24441
24561
|
}
|
|
24442
24562
|
|
|
24443
24563
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
24444
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
24564
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.5/templates/javascript/packages/core/src/visitor.ts.erb
|
|
24445
24565
|
class Visitor {
|
|
24446
24566
|
visit(node) {
|
|
24447
24567
|
if (!node)
|
|
@@ -24624,12 +24744,16 @@ class Visitor {
|
|
|
24624
24744
|
this.visitNode(node);
|
|
24625
24745
|
this.visitChildNodes(node);
|
|
24626
24746
|
}
|
|
24747
|
+
visitRubyRenderKeywordsNode(node) {
|
|
24748
|
+
this.visitNode(node);
|
|
24749
|
+
this.visitChildNodes(node);
|
|
24750
|
+
}
|
|
24627
24751
|
visitERBRenderNode(node) {
|
|
24628
24752
|
this.visitNode(node);
|
|
24629
24753
|
this.visitERBNode(node);
|
|
24630
24754
|
this.visitChildNodes(node);
|
|
24631
24755
|
}
|
|
24632
|
-
|
|
24756
|
+
visitRubyParameterNode(node) {
|
|
24633
24757
|
this.visitNode(node);
|
|
24634
24758
|
this.visitChildNodes(node);
|
|
24635
24759
|
}
|
|
@@ -24902,8 +25026,7 @@ class ERBStringToDirectOutputRewriter extends ASTRewriter {
|
|
|
24902
25026
|
return node;
|
|
24903
25027
|
}
|
|
24904
25028
|
static isStringOutputNode(prismNode) {
|
|
24905
|
-
|
|
24906
|
-
return nodeType === STRING_NODE_TYPE || nodeType === INTERPOLATED_STRING_NODE_TYPE;
|
|
25029
|
+
return isPrismNodeType(prismNode, STRING_NODE_TYPE) || isPrismNodeType(prismNode, INTERPOLATED_STRING_NODE_TYPE);
|
|
24907
25030
|
}
|
|
24908
25031
|
static extractStringContent(stringNode, source) {
|
|
24909
25032
|
const unescapedValue = stringNode.unescaped?.value;
|
|
@@ -24926,25 +25049,23 @@ class ERBStringToDirectOutputRewriter extends ASTRewriter {
|
|
|
24926
25049
|
return source.substring(expressionStart, expressionEnd);
|
|
24927
25050
|
}
|
|
24928
25051
|
static extractReplacementParts(prismNode, source) {
|
|
24929
|
-
|
|
24930
|
-
if (nodeType === STRING_NODE_TYPE) {
|
|
25052
|
+
if (isPrismNodeType(prismNode, STRING_NODE_TYPE)) {
|
|
24931
25053
|
const textContent = this.extractStringContent(prismNode, source);
|
|
24932
25054
|
return [{ type: "text", content: textContent }];
|
|
24933
25055
|
}
|
|
24934
|
-
if (
|
|
25056
|
+
if (isPrismNodeType(prismNode, INTERPOLATED_STRING_NODE_TYPE)) {
|
|
24935
25057
|
const parts = prismNode.parts;
|
|
24936
25058
|
if (!parts || parts.length === 0)
|
|
24937
25059
|
return null;
|
|
24938
25060
|
const replacementParts = [];
|
|
24939
25061
|
for (const part of parts) {
|
|
24940
|
-
|
|
24941
|
-
if (partType === STRING_NODE_TYPE) {
|
|
25062
|
+
if (isPrismNodeType(part, STRING_NODE_TYPE)) {
|
|
24942
25063
|
const textContent = this.extractStringContent(part, source);
|
|
24943
25064
|
if (textContent) {
|
|
24944
25065
|
replacementParts.push({ type: "text", content: textContent });
|
|
24945
25066
|
}
|
|
24946
25067
|
}
|
|
24947
|
-
else if (
|
|
25068
|
+
else if (isPrismNodeType(part, EMBEDDED_STATEMENTS_NODE_TYPE)) {
|
|
24948
25069
|
const expression = this.extractExpressionSource(part, source);
|
|
24949
25070
|
if (expression) {
|
|
24950
25071
|
replacementParts.push({ type: "expression", expression });
|
|
@@ -25550,12 +25671,12 @@ class IdentityPrinter extends Printer {
|
|
|
25550
25671
|
this.visitChildNodes(node);
|
|
25551
25672
|
}
|
|
25552
25673
|
visitHTMLAttributeValueNode(node) {
|
|
25553
|
-
if (node.quoted
|
|
25554
|
-
this.write(node.open_quote
|
|
25674
|
+
if (node.quoted) {
|
|
25675
|
+
this.write(node.open_quote?.value ?? '"');
|
|
25555
25676
|
}
|
|
25556
25677
|
this.visitChildNodes(node);
|
|
25557
|
-
if (node.quoted
|
|
25558
|
-
this.write(node.close_quote
|
|
25678
|
+
if (node.quoted) {
|
|
25679
|
+
this.write(node.close_quote?.value ?? '"');
|
|
25559
25680
|
}
|
|
25560
25681
|
}
|
|
25561
25682
|
visitRubyLiteralNode(node) {
|
|
@@ -25740,6 +25861,24 @@ class IdentityPrinter extends Printer {
|
|
|
25740
25861
|
}
|
|
25741
25862
|
visitERBRenderNode(node) {
|
|
25742
25863
|
this.printERBNode(node);
|
|
25864
|
+
if (node.end_node) {
|
|
25865
|
+
if (node.body) {
|
|
25866
|
+
node.body.forEach(child => this.visit(child));
|
|
25867
|
+
}
|
|
25868
|
+
if (node.rescue_clause) {
|
|
25869
|
+
this.visit(node.rescue_clause);
|
|
25870
|
+
}
|
|
25871
|
+
if (node.else_clause) {
|
|
25872
|
+
this.visit(node.else_clause);
|
|
25873
|
+
}
|
|
25874
|
+
if (node.ensure_clause) {
|
|
25875
|
+
this.visit(node.ensure_clause);
|
|
25876
|
+
}
|
|
25877
|
+
this.visit(node.end_node);
|
|
25878
|
+
}
|
|
25879
|
+
}
|
|
25880
|
+
visitRubyRenderKeywordsNode(_node) {
|
|
25881
|
+
// no-op: extracted metadata, nothing to print
|
|
25743
25882
|
}
|
|
25744
25883
|
visitRubyRenderLocalNode(_node) {
|
|
25745
25884
|
// extracted metadata, nothing to print
|
|
@@ -25747,7 +25886,7 @@ class IdentityPrinter extends Printer {
|
|
|
25747
25886
|
visitERBStrictLocalsNode(node) {
|
|
25748
25887
|
this.printERBNode(node);
|
|
25749
25888
|
}
|
|
25750
|
-
|
|
25889
|
+
visitRubyParameterNode(_node) {
|
|
25751
25890
|
// extracted metadata, nothing to print
|
|
25752
25891
|
}
|
|
25753
25892
|
visitERBYieldNode(node) {
|