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