@herb-tools/rewriter 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/index.cjs +544 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +544 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/loader.cjs +544 -4
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.esm.js +544 -4
- package/dist/loader.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/loader.esm.js
CHANGED
|
@@ -204,7 +204,7 @@ class Token {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
207
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
207
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/errors.ts.erb
|
|
208
208
|
class HerbError {
|
|
209
209
|
type;
|
|
210
210
|
message;
|
|
@@ -1205,6 +1205,279 @@ class NestedERBTagError extends HerbError {
|
|
|
1205
1205
|
return output;
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|
|
1208
|
+
class RenderAmbiguousLocalsError extends HerbError {
|
|
1209
|
+
partial;
|
|
1210
|
+
static from(data) {
|
|
1211
|
+
return new RenderAmbiguousLocalsError({
|
|
1212
|
+
type: data.type,
|
|
1213
|
+
message: data.message,
|
|
1214
|
+
location: Location.from(data.location),
|
|
1215
|
+
partial: data.partial,
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
constructor(props) {
|
|
1219
|
+
super(props.type, props.message, props.location);
|
|
1220
|
+
this.partial = props.partial;
|
|
1221
|
+
}
|
|
1222
|
+
toJSON() {
|
|
1223
|
+
return {
|
|
1224
|
+
...super.toJSON(),
|
|
1225
|
+
type: "RENDER_AMBIGUOUS_LOCALS_ERROR",
|
|
1226
|
+
partial: this.partial,
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
toMonacoDiagnostic() {
|
|
1230
|
+
return {
|
|
1231
|
+
line: this.location.start.line,
|
|
1232
|
+
column: this.location.start.column,
|
|
1233
|
+
endLine: this.location.end.line,
|
|
1234
|
+
endColumn: this.location.end.column,
|
|
1235
|
+
message: this.message,
|
|
1236
|
+
severity: 'error'
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
treeInspect() {
|
|
1240
|
+
let output = "";
|
|
1241
|
+
output += `@ RenderAmbiguousLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1242
|
+
output += `├── message: "${this.message}"\n`;
|
|
1243
|
+
output += `└── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1244
|
+
return output;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
class RenderMissingLocalsError extends HerbError {
|
|
1248
|
+
partial;
|
|
1249
|
+
keywords;
|
|
1250
|
+
static from(data) {
|
|
1251
|
+
return new RenderMissingLocalsError({
|
|
1252
|
+
type: data.type,
|
|
1253
|
+
message: data.message,
|
|
1254
|
+
location: Location.from(data.location),
|
|
1255
|
+
partial: data.partial,
|
|
1256
|
+
keywords: data.keywords,
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
constructor(props) {
|
|
1260
|
+
super(props.type, props.message, props.location);
|
|
1261
|
+
this.partial = props.partial;
|
|
1262
|
+
this.keywords = props.keywords;
|
|
1263
|
+
}
|
|
1264
|
+
toJSON() {
|
|
1265
|
+
return {
|
|
1266
|
+
...super.toJSON(),
|
|
1267
|
+
type: "RENDER_MISSING_LOCALS_ERROR",
|
|
1268
|
+
partial: this.partial,
|
|
1269
|
+
keywords: this.keywords,
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
toMonacoDiagnostic() {
|
|
1273
|
+
return {
|
|
1274
|
+
line: this.location.start.line,
|
|
1275
|
+
column: this.location.start.column,
|
|
1276
|
+
endLine: this.location.end.line,
|
|
1277
|
+
endColumn: this.location.end.column,
|
|
1278
|
+
message: this.message,
|
|
1279
|
+
severity: 'error'
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
treeInspect() {
|
|
1283
|
+
let output = "";
|
|
1284
|
+
output += `@ RenderMissingLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1285
|
+
output += `├── message: "${this.message}"\n`;
|
|
1286
|
+
output += `├── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1287
|
+
output += `└── keywords: ${JSON.stringify(this.keywords)}\n`;
|
|
1288
|
+
return output;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
class RenderNoArgumentsError extends HerbError {
|
|
1292
|
+
static from(data) {
|
|
1293
|
+
return new RenderNoArgumentsError({
|
|
1294
|
+
type: data.type,
|
|
1295
|
+
message: data.message,
|
|
1296
|
+
location: Location.from(data.location),
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
constructor(props) {
|
|
1300
|
+
super(props.type, props.message, props.location);
|
|
1301
|
+
}
|
|
1302
|
+
toJSON() {
|
|
1303
|
+
return {
|
|
1304
|
+
...super.toJSON(),
|
|
1305
|
+
type: "RENDER_NO_ARGUMENTS_ERROR",
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
toMonacoDiagnostic() {
|
|
1309
|
+
return {
|
|
1310
|
+
line: this.location.start.line,
|
|
1311
|
+
column: this.location.start.column,
|
|
1312
|
+
endLine: this.location.end.line,
|
|
1313
|
+
endColumn: this.location.end.column,
|
|
1314
|
+
message: this.message,
|
|
1315
|
+
severity: 'error'
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
treeInspect() {
|
|
1319
|
+
let output = "";
|
|
1320
|
+
output += `@ RenderNoArgumentsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1321
|
+
output += `└── message: "${this.message}"\n`;
|
|
1322
|
+
return output;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
class RenderConflictingPartialError extends HerbError {
|
|
1326
|
+
positional_partial;
|
|
1327
|
+
keyword_partial;
|
|
1328
|
+
static from(data) {
|
|
1329
|
+
return new RenderConflictingPartialError({
|
|
1330
|
+
type: data.type,
|
|
1331
|
+
message: data.message,
|
|
1332
|
+
location: Location.from(data.location),
|
|
1333
|
+
positional_partial: data.positional_partial,
|
|
1334
|
+
keyword_partial: data.keyword_partial,
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
constructor(props) {
|
|
1338
|
+
super(props.type, props.message, props.location);
|
|
1339
|
+
this.positional_partial = props.positional_partial;
|
|
1340
|
+
this.keyword_partial = props.keyword_partial;
|
|
1341
|
+
}
|
|
1342
|
+
toJSON() {
|
|
1343
|
+
return {
|
|
1344
|
+
...super.toJSON(),
|
|
1345
|
+
type: "RENDER_CONFLICTING_PARTIAL_ERROR",
|
|
1346
|
+
positional_partial: this.positional_partial,
|
|
1347
|
+
keyword_partial: this.keyword_partial,
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
toMonacoDiagnostic() {
|
|
1351
|
+
return {
|
|
1352
|
+
line: this.location.start.line,
|
|
1353
|
+
column: this.location.start.column,
|
|
1354
|
+
endLine: this.location.end.line,
|
|
1355
|
+
endColumn: this.location.end.column,
|
|
1356
|
+
message: this.message,
|
|
1357
|
+
severity: 'error'
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
treeInspect() {
|
|
1361
|
+
let output = "";
|
|
1362
|
+
output += `@ RenderConflictingPartialError ${this.location.treeInspectWithLabel()}\n`;
|
|
1363
|
+
output += `├── message: "${this.message}"\n`;
|
|
1364
|
+
output += `├── positional_partial: ${JSON.stringify(this.positional_partial)}\n`;
|
|
1365
|
+
output += `└── keyword_partial: ${JSON.stringify(this.keyword_partial)}\n`;
|
|
1366
|
+
return output;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
class RenderInvalidAsOptionError extends HerbError {
|
|
1370
|
+
as_value;
|
|
1371
|
+
static from(data) {
|
|
1372
|
+
return new RenderInvalidAsOptionError({
|
|
1373
|
+
type: data.type,
|
|
1374
|
+
message: data.message,
|
|
1375
|
+
location: Location.from(data.location),
|
|
1376
|
+
as_value: data.as_value,
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
constructor(props) {
|
|
1380
|
+
super(props.type, props.message, props.location);
|
|
1381
|
+
this.as_value = props.as_value;
|
|
1382
|
+
}
|
|
1383
|
+
toJSON() {
|
|
1384
|
+
return {
|
|
1385
|
+
...super.toJSON(),
|
|
1386
|
+
type: "RENDER_INVALID_AS_OPTION_ERROR",
|
|
1387
|
+
as_value: this.as_value,
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
toMonacoDiagnostic() {
|
|
1391
|
+
return {
|
|
1392
|
+
line: this.location.start.line,
|
|
1393
|
+
column: this.location.start.column,
|
|
1394
|
+
endLine: this.location.end.line,
|
|
1395
|
+
endColumn: this.location.end.column,
|
|
1396
|
+
message: this.message,
|
|
1397
|
+
severity: 'error'
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
treeInspect() {
|
|
1401
|
+
let output = "";
|
|
1402
|
+
output += `@ RenderInvalidAsOptionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1403
|
+
output += `├── message: "${this.message}"\n`;
|
|
1404
|
+
output += `└── as_value: ${JSON.stringify(this.as_value)}\n`;
|
|
1405
|
+
return output;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
class RenderObjectAndCollectionError extends HerbError {
|
|
1409
|
+
static from(data) {
|
|
1410
|
+
return new RenderObjectAndCollectionError({
|
|
1411
|
+
type: data.type,
|
|
1412
|
+
message: data.message,
|
|
1413
|
+
location: Location.from(data.location),
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
constructor(props) {
|
|
1417
|
+
super(props.type, props.message, props.location);
|
|
1418
|
+
}
|
|
1419
|
+
toJSON() {
|
|
1420
|
+
return {
|
|
1421
|
+
...super.toJSON(),
|
|
1422
|
+
type: "RENDER_OBJECT_AND_COLLECTION_ERROR",
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
toMonacoDiagnostic() {
|
|
1426
|
+
return {
|
|
1427
|
+
line: this.location.start.line,
|
|
1428
|
+
column: this.location.start.column,
|
|
1429
|
+
endLine: this.location.end.line,
|
|
1430
|
+
endColumn: this.location.end.column,
|
|
1431
|
+
message: this.message,
|
|
1432
|
+
severity: 'error'
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
treeInspect() {
|
|
1436
|
+
let output = "";
|
|
1437
|
+
output += `@ RenderObjectAndCollectionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1438
|
+
output += `└── message: "${this.message}"\n`;
|
|
1439
|
+
return output;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
class RenderLayoutWithoutBlockError extends HerbError {
|
|
1443
|
+
layout;
|
|
1444
|
+
static from(data) {
|
|
1445
|
+
return new RenderLayoutWithoutBlockError({
|
|
1446
|
+
type: data.type,
|
|
1447
|
+
message: data.message,
|
|
1448
|
+
location: Location.from(data.location),
|
|
1449
|
+
layout: data.layout,
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
constructor(props) {
|
|
1453
|
+
super(props.type, props.message, props.location);
|
|
1454
|
+
this.layout = props.layout;
|
|
1455
|
+
}
|
|
1456
|
+
toJSON() {
|
|
1457
|
+
return {
|
|
1458
|
+
...super.toJSON(),
|
|
1459
|
+
type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR",
|
|
1460
|
+
layout: this.layout,
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
toMonacoDiagnostic() {
|
|
1464
|
+
return {
|
|
1465
|
+
line: this.location.start.line,
|
|
1466
|
+
column: this.location.start.column,
|
|
1467
|
+
endLine: this.location.end.line,
|
|
1468
|
+
endColumn: this.location.end.column,
|
|
1469
|
+
message: this.message,
|
|
1470
|
+
severity: 'error'
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
treeInspect() {
|
|
1474
|
+
let output = "";
|
|
1475
|
+
output += `@ RenderLayoutWithoutBlockError ${this.location.treeInspectWithLabel()}\n`;
|
|
1476
|
+
output += `├── message: "${this.message}"\n`;
|
|
1477
|
+
output += `└── layout: ${JSON.stringify(this.layout)}\n`;
|
|
1478
|
+
return output;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1208
1481
|
function fromSerializedError(error) {
|
|
1209
1482
|
switch (error.type) {
|
|
1210
1483
|
case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
|
|
@@ -1230,6 +1503,13 @@ function fromSerializedError(error) {
|
|
|
1230
1503
|
case "UNCLOSED_ERB_TAG_ERROR": return UnclosedERBTagError.from(error);
|
|
1231
1504
|
case "STRAY_ERB_CLOSING_TAG_ERROR": return StrayERBClosingTagError.from(error);
|
|
1232
1505
|
case "NESTED_ERB_TAG_ERROR": return NestedERBTagError.from(error);
|
|
1506
|
+
case "RENDER_AMBIGUOUS_LOCALS_ERROR": return RenderAmbiguousLocalsError.from(error);
|
|
1507
|
+
case "RENDER_MISSING_LOCALS_ERROR": return RenderMissingLocalsError.from(error);
|
|
1508
|
+
case "RENDER_NO_ARGUMENTS_ERROR": return RenderNoArgumentsError.from(error);
|
|
1509
|
+
case "RENDER_CONFLICTING_PARTIAL_ERROR": return RenderConflictingPartialError.from(error);
|
|
1510
|
+
case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
|
|
1511
|
+
case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
|
|
1512
|
+
case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
|
|
1233
1513
|
default:
|
|
1234
1514
|
throw new Error(`Unknown node type: ${error.type}`);
|
|
1235
1515
|
}
|
|
@@ -19818,7 +20098,7 @@ function deserializePrismNode(bytes, source) {
|
|
|
19818
20098
|
}
|
|
19819
20099
|
|
|
19820
20100
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
19821
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
20101
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/nodes.ts.erb
|
|
19822
20102
|
class Node {
|
|
19823
20103
|
type;
|
|
19824
20104
|
location;
|
|
@@ -22362,6 +22642,225 @@ class ERBUnlessNode extends Node {
|
|
|
22362
22642
|
return output;
|
|
22363
22643
|
}
|
|
22364
22644
|
}
|
|
22645
|
+
class RubyRenderLocalNode extends Node {
|
|
22646
|
+
name;
|
|
22647
|
+
value;
|
|
22648
|
+
static get type() {
|
|
22649
|
+
return "AST_RUBY_RENDER_LOCAL_NODE";
|
|
22650
|
+
}
|
|
22651
|
+
static from(data) {
|
|
22652
|
+
return new RubyRenderLocalNode({
|
|
22653
|
+
type: data.type,
|
|
22654
|
+
location: Location.from(data.location),
|
|
22655
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
22656
|
+
name: data.name ? Token.from(data.name) : null,
|
|
22657
|
+
value: data.value ? fromSerializedNode((data.value)) : null,
|
|
22658
|
+
});
|
|
22659
|
+
}
|
|
22660
|
+
constructor(props) {
|
|
22661
|
+
super(props.type, props.location, props.errors);
|
|
22662
|
+
this.name = props.name;
|
|
22663
|
+
this.value = props.value;
|
|
22664
|
+
}
|
|
22665
|
+
accept(visitor) {
|
|
22666
|
+
visitor.visitRubyRenderLocalNode(this);
|
|
22667
|
+
}
|
|
22668
|
+
childNodes() {
|
|
22669
|
+
return [
|
|
22670
|
+
this.value,
|
|
22671
|
+
];
|
|
22672
|
+
}
|
|
22673
|
+
compactChildNodes() {
|
|
22674
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
22675
|
+
}
|
|
22676
|
+
recursiveErrors() {
|
|
22677
|
+
return [
|
|
22678
|
+
...this.errors,
|
|
22679
|
+
this.value ? this.value.recursiveErrors() : [],
|
|
22680
|
+
].flat();
|
|
22681
|
+
}
|
|
22682
|
+
toJSON() {
|
|
22683
|
+
return {
|
|
22684
|
+
...super.toJSON(),
|
|
22685
|
+
type: "AST_RUBY_RENDER_LOCAL_NODE",
|
|
22686
|
+
name: this.name ? this.name.toJSON() : null,
|
|
22687
|
+
value: this.value ? this.value.toJSON() : null,
|
|
22688
|
+
};
|
|
22689
|
+
}
|
|
22690
|
+
treeInspect() {
|
|
22691
|
+
let output = "";
|
|
22692
|
+
output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`;
|
|
22693
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
22694
|
+
output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
|
|
22695
|
+
output += `└── value: ${this.inspectNode(this.value, " ")}`;
|
|
22696
|
+
return output;
|
|
22697
|
+
}
|
|
22698
|
+
}
|
|
22699
|
+
class ERBRenderNode extends Node {
|
|
22700
|
+
tag_opening;
|
|
22701
|
+
content;
|
|
22702
|
+
tag_closing;
|
|
22703
|
+
// no-op for analyzed_ruby
|
|
22704
|
+
prism_node;
|
|
22705
|
+
partial;
|
|
22706
|
+
template_path;
|
|
22707
|
+
layout;
|
|
22708
|
+
file;
|
|
22709
|
+
inline_template;
|
|
22710
|
+
body;
|
|
22711
|
+
plain;
|
|
22712
|
+
html;
|
|
22713
|
+
renderable;
|
|
22714
|
+
collection;
|
|
22715
|
+
object;
|
|
22716
|
+
as_name;
|
|
22717
|
+
spacer_template;
|
|
22718
|
+
formats;
|
|
22719
|
+
variants;
|
|
22720
|
+
handlers;
|
|
22721
|
+
content_type;
|
|
22722
|
+
locals;
|
|
22723
|
+
static get type() {
|
|
22724
|
+
return "AST_ERB_RENDER_NODE";
|
|
22725
|
+
}
|
|
22726
|
+
static from(data) {
|
|
22727
|
+
return new ERBRenderNode({
|
|
22728
|
+
type: data.type,
|
|
22729
|
+
location: Location.from(data.location),
|
|
22730
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
22731
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
22732
|
+
content: data.content ? Token.from(data.content) : null,
|
|
22733
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
22734
|
+
// no-op for analyzed_ruby
|
|
22735
|
+
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
22736
|
+
partial: data.partial ? Token.from(data.partial) : null,
|
|
22737
|
+
template_path: data.template_path ? Token.from(data.template_path) : null,
|
|
22738
|
+
layout: data.layout ? Token.from(data.layout) : null,
|
|
22739
|
+
file: data.file ? Token.from(data.file) : null,
|
|
22740
|
+
inline_template: data.inline_template ? Token.from(data.inline_template) : null,
|
|
22741
|
+
body: data.body ? Token.from(data.body) : null,
|
|
22742
|
+
plain: data.plain ? Token.from(data.plain) : null,
|
|
22743
|
+
html: data.html ? Token.from(data.html) : null,
|
|
22744
|
+
renderable: data.renderable ? Token.from(data.renderable) : null,
|
|
22745
|
+
collection: data.collection ? Token.from(data.collection) : null,
|
|
22746
|
+
object: data.object ? Token.from(data.object) : null,
|
|
22747
|
+
as_name: data.as_name ? Token.from(data.as_name) : null,
|
|
22748
|
+
spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null,
|
|
22749
|
+
formats: data.formats ? Token.from(data.formats) : null,
|
|
22750
|
+
variants: data.variants ? Token.from(data.variants) : null,
|
|
22751
|
+
handlers: data.handlers ? Token.from(data.handlers) : null,
|
|
22752
|
+
content_type: data.content_type ? Token.from(data.content_type) : null,
|
|
22753
|
+
locals: (data.locals || []).map(node => fromSerializedNode(node)),
|
|
22754
|
+
});
|
|
22755
|
+
}
|
|
22756
|
+
constructor(props) {
|
|
22757
|
+
super(props.type, props.location, props.errors);
|
|
22758
|
+
this.tag_opening = props.tag_opening;
|
|
22759
|
+
this.content = props.content;
|
|
22760
|
+
this.tag_closing = props.tag_closing;
|
|
22761
|
+
// no-op for analyzed_ruby
|
|
22762
|
+
this.prism_node = props.prism_node;
|
|
22763
|
+
this.partial = props.partial;
|
|
22764
|
+
this.template_path = props.template_path;
|
|
22765
|
+
this.layout = props.layout;
|
|
22766
|
+
this.file = props.file;
|
|
22767
|
+
this.inline_template = props.inline_template;
|
|
22768
|
+
this.body = props.body;
|
|
22769
|
+
this.plain = props.plain;
|
|
22770
|
+
this.html = props.html;
|
|
22771
|
+
this.renderable = props.renderable;
|
|
22772
|
+
this.collection = props.collection;
|
|
22773
|
+
this.object = props.object;
|
|
22774
|
+
this.as_name = props.as_name;
|
|
22775
|
+
this.spacer_template = props.spacer_template;
|
|
22776
|
+
this.formats = props.formats;
|
|
22777
|
+
this.variants = props.variants;
|
|
22778
|
+
this.handlers = props.handlers;
|
|
22779
|
+
this.content_type = props.content_type;
|
|
22780
|
+
this.locals = props.locals;
|
|
22781
|
+
}
|
|
22782
|
+
accept(visitor) {
|
|
22783
|
+
visitor.visitERBRenderNode(this);
|
|
22784
|
+
}
|
|
22785
|
+
childNodes() {
|
|
22786
|
+
return [
|
|
22787
|
+
...this.locals,
|
|
22788
|
+
];
|
|
22789
|
+
}
|
|
22790
|
+
compactChildNodes() {
|
|
22791
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
22792
|
+
}
|
|
22793
|
+
get prismNode() {
|
|
22794
|
+
if (!this.prism_node || !this.source)
|
|
22795
|
+
return null;
|
|
22796
|
+
return deserializePrismNode(this.prism_node, this.source);
|
|
22797
|
+
}
|
|
22798
|
+
recursiveErrors() {
|
|
22799
|
+
return [
|
|
22800
|
+
...this.errors,
|
|
22801
|
+
...this.locals.map(node => node.recursiveErrors()),
|
|
22802
|
+
].flat();
|
|
22803
|
+
}
|
|
22804
|
+
toJSON() {
|
|
22805
|
+
return {
|
|
22806
|
+
...super.toJSON(),
|
|
22807
|
+
type: "AST_ERB_RENDER_NODE",
|
|
22808
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
22809
|
+
content: this.content ? this.content.toJSON() : null,
|
|
22810
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
22811
|
+
// no-op for analyzed_ruby
|
|
22812
|
+
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
22813
|
+
partial: this.partial ? this.partial.toJSON() : null,
|
|
22814
|
+
template_path: this.template_path ? this.template_path.toJSON() : null,
|
|
22815
|
+
layout: this.layout ? this.layout.toJSON() : null,
|
|
22816
|
+
file: this.file ? this.file.toJSON() : null,
|
|
22817
|
+
inline_template: this.inline_template ? this.inline_template.toJSON() : null,
|
|
22818
|
+
body: this.body ? this.body.toJSON() : null,
|
|
22819
|
+
plain: this.plain ? this.plain.toJSON() : null,
|
|
22820
|
+
html: this.html ? this.html.toJSON() : null,
|
|
22821
|
+
renderable: this.renderable ? this.renderable.toJSON() : null,
|
|
22822
|
+
collection: this.collection ? this.collection.toJSON() : null,
|
|
22823
|
+
object: this.object ? this.object.toJSON() : null,
|
|
22824
|
+
as_name: this.as_name ? this.as_name.toJSON() : null,
|
|
22825
|
+
spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null,
|
|
22826
|
+
formats: this.formats ? this.formats.toJSON() : null,
|
|
22827
|
+
variants: this.variants ? this.variants.toJSON() : null,
|
|
22828
|
+
handlers: this.handlers ? this.handlers.toJSON() : null,
|
|
22829
|
+
content_type: this.content_type ? this.content_type.toJSON() : null,
|
|
22830
|
+
locals: this.locals.map(node => node.toJSON()),
|
|
22831
|
+
};
|
|
22832
|
+
}
|
|
22833
|
+
treeInspect() {
|
|
22834
|
+
let output = "";
|
|
22835
|
+
output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
|
|
22836
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
22837
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
22838
|
+
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
22839
|
+
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
22840
|
+
if (this.prism_node) {
|
|
22841
|
+
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
22842
|
+
}
|
|
22843
|
+
output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
|
|
22844
|
+
output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
|
|
22845
|
+
output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
|
|
22846
|
+
output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`;
|
|
22847
|
+
output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`;
|
|
22848
|
+
output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`;
|
|
22849
|
+
output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`;
|
|
22850
|
+
output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`;
|
|
22851
|
+
output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`;
|
|
22852
|
+
output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`;
|
|
22853
|
+
output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`;
|
|
22854
|
+
output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`;
|
|
22855
|
+
output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`;
|
|
22856
|
+
output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`;
|
|
22857
|
+
output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`;
|
|
22858
|
+
output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`;
|
|
22859
|
+
output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`;
|
|
22860
|
+
output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
|
|
22861
|
+
return output;
|
|
22862
|
+
}
|
|
22863
|
+
}
|
|
22365
22864
|
class ERBYieldNode extends Node {
|
|
22366
22865
|
tag_opening;
|
|
22367
22866
|
content;
|
|
@@ -22525,6 +23024,8 @@ function fromSerializedNode(node) {
|
|
|
22525
23024
|
case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node);
|
|
22526
23025
|
case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node);
|
|
22527
23026
|
case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
|
|
23027
|
+
case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
|
|
23028
|
+
case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
|
|
22528
23029
|
case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
|
|
22529
23030
|
case "AST_ERB_IN_NODE": return ERBInNode.from(node);
|
|
22530
23031
|
default:
|
|
@@ -22574,6 +23075,7 @@ const DEFAULT_PARSER_OPTIONS = {
|
|
|
22574
23075
|
analyze: true,
|
|
22575
23076
|
strict: true,
|
|
22576
23077
|
action_view_helpers: false,
|
|
23078
|
+
render_nodes: false,
|
|
22577
23079
|
prism_nodes: false,
|
|
22578
23080
|
prism_nodes_deep: false,
|
|
22579
23081
|
prism_program: false,
|
|
@@ -22590,6 +23092,8 @@ class ParserOptions {
|
|
|
22590
23092
|
analyze;
|
|
22591
23093
|
/** Whether ActionView tag helper transformation was enabled during parsing. */
|
|
22592
23094
|
action_view_helpers;
|
|
23095
|
+
/** Whether ActionView render call detection was enabled during parsing. */
|
|
23096
|
+
render_nodes;
|
|
22593
23097
|
/** Whether Prism node serialization was enabled during parsing. */
|
|
22594
23098
|
prism_nodes;
|
|
22595
23099
|
/** Whether deep Prism node serialization was enabled during parsing. */
|
|
@@ -22604,6 +23108,7 @@ class ParserOptions {
|
|
|
22604
23108
|
this.track_whitespace = options.track_whitespace ?? DEFAULT_PARSER_OPTIONS.track_whitespace;
|
|
22605
23109
|
this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
|
|
22606
23110
|
this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
|
|
23111
|
+
this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
|
|
22607
23112
|
this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
|
|
22608
23113
|
this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
|
|
22609
23114
|
this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
|
|
@@ -22683,7 +23188,7 @@ class ParseResult extends Result {
|
|
|
22683
23188
|
}
|
|
22684
23189
|
|
|
22685
23190
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
22686
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23191
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
22687
23192
|
/**
|
|
22688
23193
|
* Type guard functions for AST nodes.
|
|
22689
23194
|
* These functions provide type checking by combining both instanceof
|
|
@@ -22978,6 +23483,22 @@ function isERBUnlessNode(node) {
|
|
|
22978
23483
|
return false;
|
|
22979
23484
|
return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
|
|
22980
23485
|
}
|
|
23486
|
+
/**
|
|
23487
|
+
* Checks if a node is a RubyRenderLocalNode
|
|
23488
|
+
*/
|
|
23489
|
+
function isRubyRenderLocalNode(node) {
|
|
23490
|
+
if (!node)
|
|
23491
|
+
return false;
|
|
23492
|
+
return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || node.constructor.type === "AST_RUBY_RENDER_LOCAL_NODE";
|
|
23493
|
+
}
|
|
23494
|
+
/**
|
|
23495
|
+
* Checks if a node is a ERBRenderNode
|
|
23496
|
+
*/
|
|
23497
|
+
function isERBRenderNode(node) {
|
|
23498
|
+
if (!node)
|
|
23499
|
+
return false;
|
|
23500
|
+
return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
|
|
23501
|
+
}
|
|
22981
23502
|
/**
|
|
22982
23503
|
* Checks if a node is a ERBYieldNode
|
|
22983
23504
|
*/
|
|
@@ -23041,6 +23562,8 @@ const NODE_TYPE_GUARDS = new Map([
|
|
|
23041
23562
|
[ERBEnsureNode, isERBEnsureNode],
|
|
23042
23563
|
[ERBBeginNode, isERBBeginNode],
|
|
23043
23564
|
[ERBUnlessNode, isERBUnlessNode],
|
|
23565
|
+
[RubyRenderLocalNode, isRubyRenderLocalNode],
|
|
23566
|
+
[ERBRenderNode, isERBRenderNode],
|
|
23044
23567
|
[ERBYieldNode, isERBYieldNode],
|
|
23045
23568
|
[ERBInNode, isERBInNode],
|
|
23046
23569
|
]);
|
|
@@ -23091,6 +23614,8 @@ const AST_TYPE_GUARDS = new Map([
|
|
|
23091
23614
|
["AST_ERB_ENSURE_NODE", isERBEnsureNode],
|
|
23092
23615
|
["AST_ERB_BEGIN_NODE", isERBBeginNode],
|
|
23093
23616
|
["AST_ERB_UNLESS_NODE", isERBUnlessNode],
|
|
23617
|
+
["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
|
|
23618
|
+
["AST_ERB_RENDER_NODE", isERBRenderNode],
|
|
23094
23619
|
["AST_ERB_YIELD_NODE", isERBYieldNode],
|
|
23095
23620
|
["AST_ERB_IN_NODE", isERBInNode],
|
|
23096
23621
|
]);
|
|
@@ -23317,7 +23842,7 @@ function createSyntheticToken(value, type = "TOKEN_SYNTHETIC") {
|
|
|
23317
23842
|
}
|
|
23318
23843
|
|
|
23319
23844
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
23320
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23845
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/visitor.ts.erb
|
|
23321
23846
|
class Visitor {
|
|
23322
23847
|
visit(node) {
|
|
23323
23848
|
if (!node)
|
|
@@ -23496,6 +24021,15 @@ class Visitor {
|
|
|
23496
24021
|
this.visitERBNode(node);
|
|
23497
24022
|
this.visitChildNodes(node);
|
|
23498
24023
|
}
|
|
24024
|
+
visitRubyRenderLocalNode(node) {
|
|
24025
|
+
this.visitNode(node);
|
|
24026
|
+
this.visitChildNodes(node);
|
|
24027
|
+
}
|
|
24028
|
+
visitERBRenderNode(node) {
|
|
24029
|
+
this.visitNode(node);
|
|
24030
|
+
this.visitERBNode(node);
|
|
24031
|
+
this.visitChildNodes(node);
|
|
24032
|
+
}
|
|
23499
24033
|
visitERBYieldNode(node) {
|
|
23500
24034
|
this.visitNode(node);
|
|
23501
24035
|
this.visitERBNode(node);
|
|
@@ -24379,6 +24913,12 @@ class IdentityPrinter extends Printer {
|
|
|
24379
24913
|
this.visit(node.end_node);
|
|
24380
24914
|
}
|
|
24381
24915
|
}
|
|
24916
|
+
visitERBRenderNode(node) {
|
|
24917
|
+
this.printERBNode(node);
|
|
24918
|
+
}
|
|
24919
|
+
visitRubyRenderLocalNode(_node) {
|
|
24920
|
+
// extracted metadata, nothing to print
|
|
24921
|
+
}
|
|
24382
24922
|
visitERBYieldNode(node) {
|
|
24383
24923
|
this.printERBNode(node);
|
|
24384
24924
|
}
|