@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/index.esm.js
CHANGED
|
@@ -200,7 +200,7 @@ class Token {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
203
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
203
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/errors.ts.erb
|
|
204
204
|
class HerbError {
|
|
205
205
|
type;
|
|
206
206
|
message;
|
|
@@ -1201,6 +1201,279 @@ class NestedERBTagError extends HerbError {
|
|
|
1201
1201
|
return output;
|
|
1202
1202
|
}
|
|
1203
1203
|
}
|
|
1204
|
+
class RenderAmbiguousLocalsError extends HerbError {
|
|
1205
|
+
partial;
|
|
1206
|
+
static from(data) {
|
|
1207
|
+
return new RenderAmbiguousLocalsError({
|
|
1208
|
+
type: data.type,
|
|
1209
|
+
message: data.message,
|
|
1210
|
+
location: Location.from(data.location),
|
|
1211
|
+
partial: data.partial,
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
constructor(props) {
|
|
1215
|
+
super(props.type, props.message, props.location);
|
|
1216
|
+
this.partial = props.partial;
|
|
1217
|
+
}
|
|
1218
|
+
toJSON() {
|
|
1219
|
+
return {
|
|
1220
|
+
...super.toJSON(),
|
|
1221
|
+
type: "RENDER_AMBIGUOUS_LOCALS_ERROR",
|
|
1222
|
+
partial: this.partial,
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
toMonacoDiagnostic() {
|
|
1226
|
+
return {
|
|
1227
|
+
line: this.location.start.line,
|
|
1228
|
+
column: this.location.start.column,
|
|
1229
|
+
endLine: this.location.end.line,
|
|
1230
|
+
endColumn: this.location.end.column,
|
|
1231
|
+
message: this.message,
|
|
1232
|
+
severity: 'error'
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
treeInspect() {
|
|
1236
|
+
let output = "";
|
|
1237
|
+
output += `@ RenderAmbiguousLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1238
|
+
output += `├── message: "${this.message}"\n`;
|
|
1239
|
+
output += `└── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1240
|
+
return output;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
class RenderMissingLocalsError extends HerbError {
|
|
1244
|
+
partial;
|
|
1245
|
+
keywords;
|
|
1246
|
+
static from(data) {
|
|
1247
|
+
return new RenderMissingLocalsError({
|
|
1248
|
+
type: data.type,
|
|
1249
|
+
message: data.message,
|
|
1250
|
+
location: Location.from(data.location),
|
|
1251
|
+
partial: data.partial,
|
|
1252
|
+
keywords: data.keywords,
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
constructor(props) {
|
|
1256
|
+
super(props.type, props.message, props.location);
|
|
1257
|
+
this.partial = props.partial;
|
|
1258
|
+
this.keywords = props.keywords;
|
|
1259
|
+
}
|
|
1260
|
+
toJSON() {
|
|
1261
|
+
return {
|
|
1262
|
+
...super.toJSON(),
|
|
1263
|
+
type: "RENDER_MISSING_LOCALS_ERROR",
|
|
1264
|
+
partial: this.partial,
|
|
1265
|
+
keywords: this.keywords,
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
toMonacoDiagnostic() {
|
|
1269
|
+
return {
|
|
1270
|
+
line: this.location.start.line,
|
|
1271
|
+
column: this.location.start.column,
|
|
1272
|
+
endLine: this.location.end.line,
|
|
1273
|
+
endColumn: this.location.end.column,
|
|
1274
|
+
message: this.message,
|
|
1275
|
+
severity: 'error'
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
treeInspect() {
|
|
1279
|
+
let output = "";
|
|
1280
|
+
output += `@ RenderMissingLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1281
|
+
output += `├── message: "${this.message}"\n`;
|
|
1282
|
+
output += `├── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1283
|
+
output += `└── keywords: ${JSON.stringify(this.keywords)}\n`;
|
|
1284
|
+
return output;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
class RenderNoArgumentsError extends HerbError {
|
|
1288
|
+
static from(data) {
|
|
1289
|
+
return new RenderNoArgumentsError({
|
|
1290
|
+
type: data.type,
|
|
1291
|
+
message: data.message,
|
|
1292
|
+
location: Location.from(data.location),
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
constructor(props) {
|
|
1296
|
+
super(props.type, props.message, props.location);
|
|
1297
|
+
}
|
|
1298
|
+
toJSON() {
|
|
1299
|
+
return {
|
|
1300
|
+
...super.toJSON(),
|
|
1301
|
+
type: "RENDER_NO_ARGUMENTS_ERROR",
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
toMonacoDiagnostic() {
|
|
1305
|
+
return {
|
|
1306
|
+
line: this.location.start.line,
|
|
1307
|
+
column: this.location.start.column,
|
|
1308
|
+
endLine: this.location.end.line,
|
|
1309
|
+
endColumn: this.location.end.column,
|
|
1310
|
+
message: this.message,
|
|
1311
|
+
severity: 'error'
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
treeInspect() {
|
|
1315
|
+
let output = "";
|
|
1316
|
+
output += `@ RenderNoArgumentsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1317
|
+
output += `└── message: "${this.message}"\n`;
|
|
1318
|
+
return output;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
class RenderConflictingPartialError extends HerbError {
|
|
1322
|
+
positional_partial;
|
|
1323
|
+
keyword_partial;
|
|
1324
|
+
static from(data) {
|
|
1325
|
+
return new RenderConflictingPartialError({
|
|
1326
|
+
type: data.type,
|
|
1327
|
+
message: data.message,
|
|
1328
|
+
location: Location.from(data.location),
|
|
1329
|
+
positional_partial: data.positional_partial,
|
|
1330
|
+
keyword_partial: data.keyword_partial,
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
constructor(props) {
|
|
1334
|
+
super(props.type, props.message, props.location);
|
|
1335
|
+
this.positional_partial = props.positional_partial;
|
|
1336
|
+
this.keyword_partial = props.keyword_partial;
|
|
1337
|
+
}
|
|
1338
|
+
toJSON() {
|
|
1339
|
+
return {
|
|
1340
|
+
...super.toJSON(),
|
|
1341
|
+
type: "RENDER_CONFLICTING_PARTIAL_ERROR",
|
|
1342
|
+
positional_partial: this.positional_partial,
|
|
1343
|
+
keyword_partial: this.keyword_partial,
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
toMonacoDiagnostic() {
|
|
1347
|
+
return {
|
|
1348
|
+
line: this.location.start.line,
|
|
1349
|
+
column: this.location.start.column,
|
|
1350
|
+
endLine: this.location.end.line,
|
|
1351
|
+
endColumn: this.location.end.column,
|
|
1352
|
+
message: this.message,
|
|
1353
|
+
severity: 'error'
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
treeInspect() {
|
|
1357
|
+
let output = "";
|
|
1358
|
+
output += `@ RenderConflictingPartialError ${this.location.treeInspectWithLabel()}\n`;
|
|
1359
|
+
output += `├── message: "${this.message}"\n`;
|
|
1360
|
+
output += `├── positional_partial: ${JSON.stringify(this.positional_partial)}\n`;
|
|
1361
|
+
output += `└── keyword_partial: ${JSON.stringify(this.keyword_partial)}\n`;
|
|
1362
|
+
return output;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
class RenderInvalidAsOptionError extends HerbError {
|
|
1366
|
+
as_value;
|
|
1367
|
+
static from(data) {
|
|
1368
|
+
return new RenderInvalidAsOptionError({
|
|
1369
|
+
type: data.type,
|
|
1370
|
+
message: data.message,
|
|
1371
|
+
location: Location.from(data.location),
|
|
1372
|
+
as_value: data.as_value,
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
constructor(props) {
|
|
1376
|
+
super(props.type, props.message, props.location);
|
|
1377
|
+
this.as_value = props.as_value;
|
|
1378
|
+
}
|
|
1379
|
+
toJSON() {
|
|
1380
|
+
return {
|
|
1381
|
+
...super.toJSON(),
|
|
1382
|
+
type: "RENDER_INVALID_AS_OPTION_ERROR",
|
|
1383
|
+
as_value: this.as_value,
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
toMonacoDiagnostic() {
|
|
1387
|
+
return {
|
|
1388
|
+
line: this.location.start.line,
|
|
1389
|
+
column: this.location.start.column,
|
|
1390
|
+
endLine: this.location.end.line,
|
|
1391
|
+
endColumn: this.location.end.column,
|
|
1392
|
+
message: this.message,
|
|
1393
|
+
severity: 'error'
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
treeInspect() {
|
|
1397
|
+
let output = "";
|
|
1398
|
+
output += `@ RenderInvalidAsOptionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1399
|
+
output += `├── message: "${this.message}"\n`;
|
|
1400
|
+
output += `└── as_value: ${JSON.stringify(this.as_value)}\n`;
|
|
1401
|
+
return output;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
class RenderObjectAndCollectionError extends HerbError {
|
|
1405
|
+
static from(data) {
|
|
1406
|
+
return new RenderObjectAndCollectionError({
|
|
1407
|
+
type: data.type,
|
|
1408
|
+
message: data.message,
|
|
1409
|
+
location: Location.from(data.location),
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
constructor(props) {
|
|
1413
|
+
super(props.type, props.message, props.location);
|
|
1414
|
+
}
|
|
1415
|
+
toJSON() {
|
|
1416
|
+
return {
|
|
1417
|
+
...super.toJSON(),
|
|
1418
|
+
type: "RENDER_OBJECT_AND_COLLECTION_ERROR",
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
toMonacoDiagnostic() {
|
|
1422
|
+
return {
|
|
1423
|
+
line: this.location.start.line,
|
|
1424
|
+
column: this.location.start.column,
|
|
1425
|
+
endLine: this.location.end.line,
|
|
1426
|
+
endColumn: this.location.end.column,
|
|
1427
|
+
message: this.message,
|
|
1428
|
+
severity: 'error'
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
treeInspect() {
|
|
1432
|
+
let output = "";
|
|
1433
|
+
output += `@ RenderObjectAndCollectionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1434
|
+
output += `└── message: "${this.message}"\n`;
|
|
1435
|
+
return output;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
class RenderLayoutWithoutBlockError extends HerbError {
|
|
1439
|
+
layout;
|
|
1440
|
+
static from(data) {
|
|
1441
|
+
return new RenderLayoutWithoutBlockError({
|
|
1442
|
+
type: data.type,
|
|
1443
|
+
message: data.message,
|
|
1444
|
+
location: Location.from(data.location),
|
|
1445
|
+
layout: data.layout,
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
constructor(props) {
|
|
1449
|
+
super(props.type, props.message, props.location);
|
|
1450
|
+
this.layout = props.layout;
|
|
1451
|
+
}
|
|
1452
|
+
toJSON() {
|
|
1453
|
+
return {
|
|
1454
|
+
...super.toJSON(),
|
|
1455
|
+
type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR",
|
|
1456
|
+
layout: this.layout,
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
toMonacoDiagnostic() {
|
|
1460
|
+
return {
|
|
1461
|
+
line: this.location.start.line,
|
|
1462
|
+
column: this.location.start.column,
|
|
1463
|
+
endLine: this.location.end.line,
|
|
1464
|
+
endColumn: this.location.end.column,
|
|
1465
|
+
message: this.message,
|
|
1466
|
+
severity: 'error'
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
treeInspect() {
|
|
1470
|
+
let output = "";
|
|
1471
|
+
output += `@ RenderLayoutWithoutBlockError ${this.location.treeInspectWithLabel()}\n`;
|
|
1472
|
+
output += `├── message: "${this.message}"\n`;
|
|
1473
|
+
output += `└── layout: ${JSON.stringify(this.layout)}\n`;
|
|
1474
|
+
return output;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1204
1477
|
function fromSerializedError(error) {
|
|
1205
1478
|
switch (error.type) {
|
|
1206
1479
|
case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
|
|
@@ -1226,6 +1499,13 @@ function fromSerializedError(error) {
|
|
|
1226
1499
|
case "UNCLOSED_ERB_TAG_ERROR": return UnclosedERBTagError.from(error);
|
|
1227
1500
|
case "STRAY_ERB_CLOSING_TAG_ERROR": return StrayERBClosingTagError.from(error);
|
|
1228
1501
|
case "NESTED_ERB_TAG_ERROR": return NestedERBTagError.from(error);
|
|
1502
|
+
case "RENDER_AMBIGUOUS_LOCALS_ERROR": return RenderAmbiguousLocalsError.from(error);
|
|
1503
|
+
case "RENDER_MISSING_LOCALS_ERROR": return RenderMissingLocalsError.from(error);
|
|
1504
|
+
case "RENDER_NO_ARGUMENTS_ERROR": return RenderNoArgumentsError.from(error);
|
|
1505
|
+
case "RENDER_CONFLICTING_PARTIAL_ERROR": return RenderConflictingPartialError.from(error);
|
|
1506
|
+
case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
|
|
1507
|
+
case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
|
|
1508
|
+
case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
|
|
1229
1509
|
default:
|
|
1230
1510
|
throw new Error(`Unknown node type: ${error.type}`);
|
|
1231
1511
|
}
|
|
@@ -19814,7 +20094,7 @@ function deserializePrismNode(bytes, source) {
|
|
|
19814
20094
|
}
|
|
19815
20095
|
|
|
19816
20096
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
19817
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
20097
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/nodes.ts.erb
|
|
19818
20098
|
class Node {
|
|
19819
20099
|
type;
|
|
19820
20100
|
location;
|
|
@@ -22358,6 +22638,225 @@ class ERBUnlessNode extends Node {
|
|
|
22358
22638
|
return output;
|
|
22359
22639
|
}
|
|
22360
22640
|
}
|
|
22641
|
+
class RubyRenderLocalNode extends Node {
|
|
22642
|
+
name;
|
|
22643
|
+
value;
|
|
22644
|
+
static get type() {
|
|
22645
|
+
return "AST_RUBY_RENDER_LOCAL_NODE";
|
|
22646
|
+
}
|
|
22647
|
+
static from(data) {
|
|
22648
|
+
return new RubyRenderLocalNode({
|
|
22649
|
+
type: data.type,
|
|
22650
|
+
location: Location.from(data.location),
|
|
22651
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
22652
|
+
name: data.name ? Token.from(data.name) : null,
|
|
22653
|
+
value: data.value ? fromSerializedNode((data.value)) : null,
|
|
22654
|
+
});
|
|
22655
|
+
}
|
|
22656
|
+
constructor(props) {
|
|
22657
|
+
super(props.type, props.location, props.errors);
|
|
22658
|
+
this.name = props.name;
|
|
22659
|
+
this.value = props.value;
|
|
22660
|
+
}
|
|
22661
|
+
accept(visitor) {
|
|
22662
|
+
visitor.visitRubyRenderLocalNode(this);
|
|
22663
|
+
}
|
|
22664
|
+
childNodes() {
|
|
22665
|
+
return [
|
|
22666
|
+
this.value,
|
|
22667
|
+
];
|
|
22668
|
+
}
|
|
22669
|
+
compactChildNodes() {
|
|
22670
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
22671
|
+
}
|
|
22672
|
+
recursiveErrors() {
|
|
22673
|
+
return [
|
|
22674
|
+
...this.errors,
|
|
22675
|
+
this.value ? this.value.recursiveErrors() : [],
|
|
22676
|
+
].flat();
|
|
22677
|
+
}
|
|
22678
|
+
toJSON() {
|
|
22679
|
+
return {
|
|
22680
|
+
...super.toJSON(),
|
|
22681
|
+
type: "AST_RUBY_RENDER_LOCAL_NODE",
|
|
22682
|
+
name: this.name ? this.name.toJSON() : null,
|
|
22683
|
+
value: this.value ? this.value.toJSON() : null,
|
|
22684
|
+
};
|
|
22685
|
+
}
|
|
22686
|
+
treeInspect() {
|
|
22687
|
+
let output = "";
|
|
22688
|
+
output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`;
|
|
22689
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
22690
|
+
output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
|
|
22691
|
+
output += `└── value: ${this.inspectNode(this.value, " ")}`;
|
|
22692
|
+
return output;
|
|
22693
|
+
}
|
|
22694
|
+
}
|
|
22695
|
+
class ERBRenderNode extends Node {
|
|
22696
|
+
tag_opening;
|
|
22697
|
+
content;
|
|
22698
|
+
tag_closing;
|
|
22699
|
+
// no-op for analyzed_ruby
|
|
22700
|
+
prism_node;
|
|
22701
|
+
partial;
|
|
22702
|
+
template_path;
|
|
22703
|
+
layout;
|
|
22704
|
+
file;
|
|
22705
|
+
inline_template;
|
|
22706
|
+
body;
|
|
22707
|
+
plain;
|
|
22708
|
+
html;
|
|
22709
|
+
renderable;
|
|
22710
|
+
collection;
|
|
22711
|
+
object;
|
|
22712
|
+
as_name;
|
|
22713
|
+
spacer_template;
|
|
22714
|
+
formats;
|
|
22715
|
+
variants;
|
|
22716
|
+
handlers;
|
|
22717
|
+
content_type;
|
|
22718
|
+
locals;
|
|
22719
|
+
static get type() {
|
|
22720
|
+
return "AST_ERB_RENDER_NODE";
|
|
22721
|
+
}
|
|
22722
|
+
static from(data) {
|
|
22723
|
+
return new ERBRenderNode({
|
|
22724
|
+
type: data.type,
|
|
22725
|
+
location: Location.from(data.location),
|
|
22726
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
22727
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
22728
|
+
content: data.content ? Token.from(data.content) : null,
|
|
22729
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
22730
|
+
// no-op for analyzed_ruby
|
|
22731
|
+
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
22732
|
+
partial: data.partial ? Token.from(data.partial) : null,
|
|
22733
|
+
template_path: data.template_path ? Token.from(data.template_path) : null,
|
|
22734
|
+
layout: data.layout ? Token.from(data.layout) : null,
|
|
22735
|
+
file: data.file ? Token.from(data.file) : null,
|
|
22736
|
+
inline_template: data.inline_template ? Token.from(data.inline_template) : null,
|
|
22737
|
+
body: data.body ? Token.from(data.body) : null,
|
|
22738
|
+
plain: data.plain ? Token.from(data.plain) : null,
|
|
22739
|
+
html: data.html ? Token.from(data.html) : null,
|
|
22740
|
+
renderable: data.renderable ? Token.from(data.renderable) : null,
|
|
22741
|
+
collection: data.collection ? Token.from(data.collection) : null,
|
|
22742
|
+
object: data.object ? Token.from(data.object) : null,
|
|
22743
|
+
as_name: data.as_name ? Token.from(data.as_name) : null,
|
|
22744
|
+
spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null,
|
|
22745
|
+
formats: data.formats ? Token.from(data.formats) : null,
|
|
22746
|
+
variants: data.variants ? Token.from(data.variants) : null,
|
|
22747
|
+
handlers: data.handlers ? Token.from(data.handlers) : null,
|
|
22748
|
+
content_type: data.content_type ? Token.from(data.content_type) : null,
|
|
22749
|
+
locals: (data.locals || []).map(node => fromSerializedNode(node)),
|
|
22750
|
+
});
|
|
22751
|
+
}
|
|
22752
|
+
constructor(props) {
|
|
22753
|
+
super(props.type, props.location, props.errors);
|
|
22754
|
+
this.tag_opening = props.tag_opening;
|
|
22755
|
+
this.content = props.content;
|
|
22756
|
+
this.tag_closing = props.tag_closing;
|
|
22757
|
+
// no-op for analyzed_ruby
|
|
22758
|
+
this.prism_node = props.prism_node;
|
|
22759
|
+
this.partial = props.partial;
|
|
22760
|
+
this.template_path = props.template_path;
|
|
22761
|
+
this.layout = props.layout;
|
|
22762
|
+
this.file = props.file;
|
|
22763
|
+
this.inline_template = props.inline_template;
|
|
22764
|
+
this.body = props.body;
|
|
22765
|
+
this.plain = props.plain;
|
|
22766
|
+
this.html = props.html;
|
|
22767
|
+
this.renderable = props.renderable;
|
|
22768
|
+
this.collection = props.collection;
|
|
22769
|
+
this.object = props.object;
|
|
22770
|
+
this.as_name = props.as_name;
|
|
22771
|
+
this.spacer_template = props.spacer_template;
|
|
22772
|
+
this.formats = props.formats;
|
|
22773
|
+
this.variants = props.variants;
|
|
22774
|
+
this.handlers = props.handlers;
|
|
22775
|
+
this.content_type = props.content_type;
|
|
22776
|
+
this.locals = props.locals;
|
|
22777
|
+
}
|
|
22778
|
+
accept(visitor) {
|
|
22779
|
+
visitor.visitERBRenderNode(this);
|
|
22780
|
+
}
|
|
22781
|
+
childNodes() {
|
|
22782
|
+
return [
|
|
22783
|
+
...this.locals,
|
|
22784
|
+
];
|
|
22785
|
+
}
|
|
22786
|
+
compactChildNodes() {
|
|
22787
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
22788
|
+
}
|
|
22789
|
+
get prismNode() {
|
|
22790
|
+
if (!this.prism_node || !this.source)
|
|
22791
|
+
return null;
|
|
22792
|
+
return deserializePrismNode(this.prism_node, this.source);
|
|
22793
|
+
}
|
|
22794
|
+
recursiveErrors() {
|
|
22795
|
+
return [
|
|
22796
|
+
...this.errors,
|
|
22797
|
+
...this.locals.map(node => node.recursiveErrors()),
|
|
22798
|
+
].flat();
|
|
22799
|
+
}
|
|
22800
|
+
toJSON() {
|
|
22801
|
+
return {
|
|
22802
|
+
...super.toJSON(),
|
|
22803
|
+
type: "AST_ERB_RENDER_NODE",
|
|
22804
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
22805
|
+
content: this.content ? this.content.toJSON() : null,
|
|
22806
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
22807
|
+
// no-op for analyzed_ruby
|
|
22808
|
+
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
22809
|
+
partial: this.partial ? this.partial.toJSON() : null,
|
|
22810
|
+
template_path: this.template_path ? this.template_path.toJSON() : null,
|
|
22811
|
+
layout: this.layout ? this.layout.toJSON() : null,
|
|
22812
|
+
file: this.file ? this.file.toJSON() : null,
|
|
22813
|
+
inline_template: this.inline_template ? this.inline_template.toJSON() : null,
|
|
22814
|
+
body: this.body ? this.body.toJSON() : null,
|
|
22815
|
+
plain: this.plain ? this.plain.toJSON() : null,
|
|
22816
|
+
html: this.html ? this.html.toJSON() : null,
|
|
22817
|
+
renderable: this.renderable ? this.renderable.toJSON() : null,
|
|
22818
|
+
collection: this.collection ? this.collection.toJSON() : null,
|
|
22819
|
+
object: this.object ? this.object.toJSON() : null,
|
|
22820
|
+
as_name: this.as_name ? this.as_name.toJSON() : null,
|
|
22821
|
+
spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null,
|
|
22822
|
+
formats: this.formats ? this.formats.toJSON() : null,
|
|
22823
|
+
variants: this.variants ? this.variants.toJSON() : null,
|
|
22824
|
+
handlers: this.handlers ? this.handlers.toJSON() : null,
|
|
22825
|
+
content_type: this.content_type ? this.content_type.toJSON() : null,
|
|
22826
|
+
locals: this.locals.map(node => node.toJSON()),
|
|
22827
|
+
};
|
|
22828
|
+
}
|
|
22829
|
+
treeInspect() {
|
|
22830
|
+
let output = "";
|
|
22831
|
+
output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
|
|
22832
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
22833
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
22834
|
+
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
22835
|
+
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
22836
|
+
if (this.prism_node) {
|
|
22837
|
+
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
22838
|
+
}
|
|
22839
|
+
output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
|
|
22840
|
+
output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
|
|
22841
|
+
output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
|
|
22842
|
+
output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`;
|
|
22843
|
+
output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`;
|
|
22844
|
+
output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`;
|
|
22845
|
+
output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`;
|
|
22846
|
+
output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`;
|
|
22847
|
+
output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`;
|
|
22848
|
+
output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`;
|
|
22849
|
+
output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`;
|
|
22850
|
+
output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`;
|
|
22851
|
+
output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`;
|
|
22852
|
+
output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`;
|
|
22853
|
+
output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`;
|
|
22854
|
+
output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`;
|
|
22855
|
+
output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`;
|
|
22856
|
+
output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
|
|
22857
|
+
return output;
|
|
22858
|
+
}
|
|
22859
|
+
}
|
|
22361
22860
|
class ERBYieldNode extends Node {
|
|
22362
22861
|
tag_opening;
|
|
22363
22862
|
content;
|
|
@@ -22521,6 +23020,8 @@ function fromSerializedNode(node) {
|
|
|
22521
23020
|
case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node);
|
|
22522
23021
|
case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node);
|
|
22523
23022
|
case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
|
|
23023
|
+
case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
|
|
23024
|
+
case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
|
|
22524
23025
|
case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
|
|
22525
23026
|
case "AST_ERB_IN_NODE": return ERBInNode.from(node);
|
|
22526
23027
|
default:
|
|
@@ -22570,6 +23071,7 @@ const DEFAULT_PARSER_OPTIONS = {
|
|
|
22570
23071
|
analyze: true,
|
|
22571
23072
|
strict: true,
|
|
22572
23073
|
action_view_helpers: false,
|
|
23074
|
+
render_nodes: false,
|
|
22573
23075
|
prism_nodes: false,
|
|
22574
23076
|
prism_nodes_deep: false,
|
|
22575
23077
|
prism_program: false,
|
|
@@ -22586,6 +23088,8 @@ class ParserOptions {
|
|
|
22586
23088
|
analyze;
|
|
22587
23089
|
/** Whether ActionView tag helper transformation was enabled during parsing. */
|
|
22588
23090
|
action_view_helpers;
|
|
23091
|
+
/** Whether ActionView render call detection was enabled during parsing. */
|
|
23092
|
+
render_nodes;
|
|
22589
23093
|
/** Whether Prism node serialization was enabled during parsing. */
|
|
22590
23094
|
prism_nodes;
|
|
22591
23095
|
/** Whether deep Prism node serialization was enabled during parsing. */
|
|
@@ -22600,6 +23104,7 @@ class ParserOptions {
|
|
|
22600
23104
|
this.track_whitespace = options.track_whitespace ?? DEFAULT_PARSER_OPTIONS.track_whitespace;
|
|
22601
23105
|
this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
|
|
22602
23106
|
this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
|
|
23107
|
+
this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
|
|
22603
23108
|
this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
|
|
22604
23109
|
this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
|
|
22605
23110
|
this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
|
|
@@ -22679,7 +23184,7 @@ class ParseResult extends Result {
|
|
|
22679
23184
|
}
|
|
22680
23185
|
|
|
22681
23186
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
22682
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23187
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
22683
23188
|
/**
|
|
22684
23189
|
* Type guard functions for AST nodes.
|
|
22685
23190
|
* These functions provide type checking by combining both instanceof
|
|
@@ -22974,6 +23479,22 @@ function isERBUnlessNode(node) {
|
|
|
22974
23479
|
return false;
|
|
22975
23480
|
return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
|
|
22976
23481
|
}
|
|
23482
|
+
/**
|
|
23483
|
+
* Checks if a node is a RubyRenderLocalNode
|
|
23484
|
+
*/
|
|
23485
|
+
function isRubyRenderLocalNode(node) {
|
|
23486
|
+
if (!node)
|
|
23487
|
+
return false;
|
|
23488
|
+
return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || node.constructor.type === "AST_RUBY_RENDER_LOCAL_NODE";
|
|
23489
|
+
}
|
|
23490
|
+
/**
|
|
23491
|
+
* Checks if a node is a ERBRenderNode
|
|
23492
|
+
*/
|
|
23493
|
+
function isERBRenderNode(node) {
|
|
23494
|
+
if (!node)
|
|
23495
|
+
return false;
|
|
23496
|
+
return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
|
|
23497
|
+
}
|
|
22977
23498
|
/**
|
|
22978
23499
|
* Checks if a node is a ERBYieldNode
|
|
22979
23500
|
*/
|
|
@@ -23037,6 +23558,8 @@ const NODE_TYPE_GUARDS = new Map([
|
|
|
23037
23558
|
[ERBEnsureNode, isERBEnsureNode],
|
|
23038
23559
|
[ERBBeginNode, isERBBeginNode],
|
|
23039
23560
|
[ERBUnlessNode, isERBUnlessNode],
|
|
23561
|
+
[RubyRenderLocalNode, isRubyRenderLocalNode],
|
|
23562
|
+
[ERBRenderNode, isERBRenderNode],
|
|
23040
23563
|
[ERBYieldNode, isERBYieldNode],
|
|
23041
23564
|
[ERBInNode, isERBInNode],
|
|
23042
23565
|
]);
|
|
@@ -23087,6 +23610,8 @@ const AST_TYPE_GUARDS = new Map([
|
|
|
23087
23610
|
["AST_ERB_ENSURE_NODE", isERBEnsureNode],
|
|
23088
23611
|
["AST_ERB_BEGIN_NODE", isERBBeginNode],
|
|
23089
23612
|
["AST_ERB_UNLESS_NODE", isERBUnlessNode],
|
|
23613
|
+
["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
|
|
23614
|
+
["AST_ERB_RENDER_NODE", isERBRenderNode],
|
|
23090
23615
|
["AST_ERB_YIELD_NODE", isERBYieldNode],
|
|
23091
23616
|
["AST_ERB_IN_NODE", isERBInNode],
|
|
23092
23617
|
]);
|
|
@@ -23208,7 +23733,7 @@ function createSyntheticToken(value, type = "TOKEN_SYNTHETIC") {
|
|
|
23208
23733
|
}
|
|
23209
23734
|
|
|
23210
23735
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
23211
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23736
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/visitor.ts.erb
|
|
23212
23737
|
class Visitor {
|
|
23213
23738
|
visit(node) {
|
|
23214
23739
|
if (!node)
|
|
@@ -23387,6 +23912,15 @@ class Visitor {
|
|
|
23387
23912
|
this.visitERBNode(node);
|
|
23388
23913
|
this.visitChildNodes(node);
|
|
23389
23914
|
}
|
|
23915
|
+
visitRubyRenderLocalNode(node) {
|
|
23916
|
+
this.visitNode(node);
|
|
23917
|
+
this.visitChildNodes(node);
|
|
23918
|
+
}
|
|
23919
|
+
visitERBRenderNode(node) {
|
|
23920
|
+
this.visitNode(node);
|
|
23921
|
+
this.visitERBNode(node);
|
|
23922
|
+
this.visitChildNodes(node);
|
|
23923
|
+
}
|
|
23390
23924
|
visitERBYieldNode(node) {
|
|
23391
23925
|
this.visitNode(node);
|
|
23392
23926
|
this.visitERBNode(node);
|
|
@@ -24270,6 +24804,12 @@ class IdentityPrinter extends Printer {
|
|
|
24270
24804
|
this.visit(node.end_node);
|
|
24271
24805
|
}
|
|
24272
24806
|
}
|
|
24807
|
+
visitERBRenderNode(node) {
|
|
24808
|
+
this.printERBNode(node);
|
|
24809
|
+
}
|
|
24810
|
+
visitRubyRenderLocalNode(_node) {
|
|
24811
|
+
// extracted metadata, nothing to print
|
|
24812
|
+
}
|
|
24273
24813
|
visitERBYieldNode(node) {
|
|
24274
24814
|
this.printERBNode(node);
|
|
24275
24815
|
}
|