@herb-tools/formatter 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/herb-format.js +1068 -16
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +551 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +551 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/types/format-printer.d.ts +3 -1
- package/package.json +5 -5
- package/src/format-printer.ts +10 -0
package/dist/index.cjs
CHANGED
|
@@ -157,7 +157,7 @@ class Token {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
160
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
160
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/errors.ts.erb
|
|
161
161
|
class HerbError {
|
|
162
162
|
type;
|
|
163
163
|
message;
|
|
@@ -1158,6 +1158,279 @@ class NestedERBTagError extends HerbError {
|
|
|
1158
1158
|
return output;
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
|
+
class RenderAmbiguousLocalsError extends HerbError {
|
|
1162
|
+
partial;
|
|
1163
|
+
static from(data) {
|
|
1164
|
+
return new RenderAmbiguousLocalsError({
|
|
1165
|
+
type: data.type,
|
|
1166
|
+
message: data.message,
|
|
1167
|
+
location: Location.from(data.location),
|
|
1168
|
+
partial: data.partial,
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
constructor(props) {
|
|
1172
|
+
super(props.type, props.message, props.location);
|
|
1173
|
+
this.partial = props.partial;
|
|
1174
|
+
}
|
|
1175
|
+
toJSON() {
|
|
1176
|
+
return {
|
|
1177
|
+
...super.toJSON(),
|
|
1178
|
+
type: "RENDER_AMBIGUOUS_LOCALS_ERROR",
|
|
1179
|
+
partial: this.partial,
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
toMonacoDiagnostic() {
|
|
1183
|
+
return {
|
|
1184
|
+
line: this.location.start.line,
|
|
1185
|
+
column: this.location.start.column,
|
|
1186
|
+
endLine: this.location.end.line,
|
|
1187
|
+
endColumn: this.location.end.column,
|
|
1188
|
+
message: this.message,
|
|
1189
|
+
severity: 'error'
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
treeInspect() {
|
|
1193
|
+
let output = "";
|
|
1194
|
+
output += `@ RenderAmbiguousLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1195
|
+
output += `├── message: "${this.message}"\n`;
|
|
1196
|
+
output += `└── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1197
|
+
return output;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
class RenderMissingLocalsError extends HerbError {
|
|
1201
|
+
partial;
|
|
1202
|
+
keywords;
|
|
1203
|
+
static from(data) {
|
|
1204
|
+
return new RenderMissingLocalsError({
|
|
1205
|
+
type: data.type,
|
|
1206
|
+
message: data.message,
|
|
1207
|
+
location: Location.from(data.location),
|
|
1208
|
+
partial: data.partial,
|
|
1209
|
+
keywords: data.keywords,
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
constructor(props) {
|
|
1213
|
+
super(props.type, props.message, props.location);
|
|
1214
|
+
this.partial = props.partial;
|
|
1215
|
+
this.keywords = props.keywords;
|
|
1216
|
+
}
|
|
1217
|
+
toJSON() {
|
|
1218
|
+
return {
|
|
1219
|
+
...super.toJSON(),
|
|
1220
|
+
type: "RENDER_MISSING_LOCALS_ERROR",
|
|
1221
|
+
partial: this.partial,
|
|
1222
|
+
keywords: this.keywords,
|
|
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 += `@ RenderMissingLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1238
|
+
output += `├── message: "${this.message}"\n`;
|
|
1239
|
+
output += `├── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1240
|
+
output += `└── keywords: ${JSON.stringify(this.keywords)}\n`;
|
|
1241
|
+
return output;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
class RenderNoArgumentsError extends HerbError {
|
|
1245
|
+
static from(data) {
|
|
1246
|
+
return new RenderNoArgumentsError({
|
|
1247
|
+
type: data.type,
|
|
1248
|
+
message: data.message,
|
|
1249
|
+
location: Location.from(data.location),
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
constructor(props) {
|
|
1253
|
+
super(props.type, props.message, props.location);
|
|
1254
|
+
}
|
|
1255
|
+
toJSON() {
|
|
1256
|
+
return {
|
|
1257
|
+
...super.toJSON(),
|
|
1258
|
+
type: "RENDER_NO_ARGUMENTS_ERROR",
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
toMonacoDiagnostic() {
|
|
1262
|
+
return {
|
|
1263
|
+
line: this.location.start.line,
|
|
1264
|
+
column: this.location.start.column,
|
|
1265
|
+
endLine: this.location.end.line,
|
|
1266
|
+
endColumn: this.location.end.column,
|
|
1267
|
+
message: this.message,
|
|
1268
|
+
severity: 'error'
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
treeInspect() {
|
|
1272
|
+
let output = "";
|
|
1273
|
+
output += `@ RenderNoArgumentsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1274
|
+
output += `└── message: "${this.message}"\n`;
|
|
1275
|
+
return output;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
class RenderConflictingPartialError extends HerbError {
|
|
1279
|
+
positional_partial;
|
|
1280
|
+
keyword_partial;
|
|
1281
|
+
static from(data) {
|
|
1282
|
+
return new RenderConflictingPartialError({
|
|
1283
|
+
type: data.type,
|
|
1284
|
+
message: data.message,
|
|
1285
|
+
location: Location.from(data.location),
|
|
1286
|
+
positional_partial: data.positional_partial,
|
|
1287
|
+
keyword_partial: data.keyword_partial,
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
constructor(props) {
|
|
1291
|
+
super(props.type, props.message, props.location);
|
|
1292
|
+
this.positional_partial = props.positional_partial;
|
|
1293
|
+
this.keyword_partial = props.keyword_partial;
|
|
1294
|
+
}
|
|
1295
|
+
toJSON() {
|
|
1296
|
+
return {
|
|
1297
|
+
...super.toJSON(),
|
|
1298
|
+
type: "RENDER_CONFLICTING_PARTIAL_ERROR",
|
|
1299
|
+
positional_partial: this.positional_partial,
|
|
1300
|
+
keyword_partial: this.keyword_partial,
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
toMonacoDiagnostic() {
|
|
1304
|
+
return {
|
|
1305
|
+
line: this.location.start.line,
|
|
1306
|
+
column: this.location.start.column,
|
|
1307
|
+
endLine: this.location.end.line,
|
|
1308
|
+
endColumn: this.location.end.column,
|
|
1309
|
+
message: this.message,
|
|
1310
|
+
severity: 'error'
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
treeInspect() {
|
|
1314
|
+
let output = "";
|
|
1315
|
+
output += `@ RenderConflictingPartialError ${this.location.treeInspectWithLabel()}\n`;
|
|
1316
|
+
output += `├── message: "${this.message}"\n`;
|
|
1317
|
+
output += `├── positional_partial: ${JSON.stringify(this.positional_partial)}\n`;
|
|
1318
|
+
output += `└── keyword_partial: ${JSON.stringify(this.keyword_partial)}\n`;
|
|
1319
|
+
return output;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
class RenderInvalidAsOptionError extends HerbError {
|
|
1323
|
+
as_value;
|
|
1324
|
+
static from(data) {
|
|
1325
|
+
return new RenderInvalidAsOptionError({
|
|
1326
|
+
type: data.type,
|
|
1327
|
+
message: data.message,
|
|
1328
|
+
location: Location.from(data.location),
|
|
1329
|
+
as_value: data.as_value,
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
constructor(props) {
|
|
1333
|
+
super(props.type, props.message, props.location);
|
|
1334
|
+
this.as_value = props.as_value;
|
|
1335
|
+
}
|
|
1336
|
+
toJSON() {
|
|
1337
|
+
return {
|
|
1338
|
+
...super.toJSON(),
|
|
1339
|
+
type: "RENDER_INVALID_AS_OPTION_ERROR",
|
|
1340
|
+
as_value: this.as_value,
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
toMonacoDiagnostic() {
|
|
1344
|
+
return {
|
|
1345
|
+
line: this.location.start.line,
|
|
1346
|
+
column: this.location.start.column,
|
|
1347
|
+
endLine: this.location.end.line,
|
|
1348
|
+
endColumn: this.location.end.column,
|
|
1349
|
+
message: this.message,
|
|
1350
|
+
severity: 'error'
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
treeInspect() {
|
|
1354
|
+
let output = "";
|
|
1355
|
+
output += `@ RenderInvalidAsOptionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1356
|
+
output += `├── message: "${this.message}"\n`;
|
|
1357
|
+
output += `└── as_value: ${JSON.stringify(this.as_value)}\n`;
|
|
1358
|
+
return output;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
class RenderObjectAndCollectionError extends HerbError {
|
|
1362
|
+
static from(data) {
|
|
1363
|
+
return new RenderObjectAndCollectionError({
|
|
1364
|
+
type: data.type,
|
|
1365
|
+
message: data.message,
|
|
1366
|
+
location: Location.from(data.location),
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
constructor(props) {
|
|
1370
|
+
super(props.type, props.message, props.location);
|
|
1371
|
+
}
|
|
1372
|
+
toJSON() {
|
|
1373
|
+
return {
|
|
1374
|
+
...super.toJSON(),
|
|
1375
|
+
type: "RENDER_OBJECT_AND_COLLECTION_ERROR",
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
toMonacoDiagnostic() {
|
|
1379
|
+
return {
|
|
1380
|
+
line: this.location.start.line,
|
|
1381
|
+
column: this.location.start.column,
|
|
1382
|
+
endLine: this.location.end.line,
|
|
1383
|
+
endColumn: this.location.end.column,
|
|
1384
|
+
message: this.message,
|
|
1385
|
+
severity: 'error'
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
treeInspect() {
|
|
1389
|
+
let output = "";
|
|
1390
|
+
output += `@ RenderObjectAndCollectionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1391
|
+
output += `└── message: "${this.message}"\n`;
|
|
1392
|
+
return output;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
class RenderLayoutWithoutBlockError extends HerbError {
|
|
1396
|
+
layout;
|
|
1397
|
+
static from(data) {
|
|
1398
|
+
return new RenderLayoutWithoutBlockError({
|
|
1399
|
+
type: data.type,
|
|
1400
|
+
message: data.message,
|
|
1401
|
+
location: Location.from(data.location),
|
|
1402
|
+
layout: data.layout,
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
constructor(props) {
|
|
1406
|
+
super(props.type, props.message, props.location);
|
|
1407
|
+
this.layout = props.layout;
|
|
1408
|
+
}
|
|
1409
|
+
toJSON() {
|
|
1410
|
+
return {
|
|
1411
|
+
...super.toJSON(),
|
|
1412
|
+
type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR",
|
|
1413
|
+
layout: this.layout,
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
toMonacoDiagnostic() {
|
|
1417
|
+
return {
|
|
1418
|
+
line: this.location.start.line,
|
|
1419
|
+
column: this.location.start.column,
|
|
1420
|
+
endLine: this.location.end.line,
|
|
1421
|
+
endColumn: this.location.end.column,
|
|
1422
|
+
message: this.message,
|
|
1423
|
+
severity: 'error'
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
treeInspect() {
|
|
1427
|
+
let output = "";
|
|
1428
|
+
output += `@ RenderLayoutWithoutBlockError ${this.location.treeInspectWithLabel()}\n`;
|
|
1429
|
+
output += `├── message: "${this.message}"\n`;
|
|
1430
|
+
output += `└── layout: ${JSON.stringify(this.layout)}\n`;
|
|
1431
|
+
return output;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1161
1434
|
function fromSerializedError(error) {
|
|
1162
1435
|
switch (error.type) {
|
|
1163
1436
|
case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
|
|
@@ -1183,6 +1456,13 @@ function fromSerializedError(error) {
|
|
|
1183
1456
|
case "UNCLOSED_ERB_TAG_ERROR": return UnclosedERBTagError.from(error);
|
|
1184
1457
|
case "STRAY_ERB_CLOSING_TAG_ERROR": return StrayERBClosingTagError.from(error);
|
|
1185
1458
|
case "NESTED_ERB_TAG_ERROR": return NestedERBTagError.from(error);
|
|
1459
|
+
case "RENDER_AMBIGUOUS_LOCALS_ERROR": return RenderAmbiguousLocalsError.from(error);
|
|
1460
|
+
case "RENDER_MISSING_LOCALS_ERROR": return RenderMissingLocalsError.from(error);
|
|
1461
|
+
case "RENDER_NO_ARGUMENTS_ERROR": return RenderNoArgumentsError.from(error);
|
|
1462
|
+
case "RENDER_CONFLICTING_PARTIAL_ERROR": return RenderConflictingPartialError.from(error);
|
|
1463
|
+
case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
|
|
1464
|
+
case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
|
|
1465
|
+
case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
|
|
1186
1466
|
default:
|
|
1187
1467
|
throw new Error(`Unknown node type: ${error.type}`);
|
|
1188
1468
|
}
|
|
@@ -19771,7 +20051,7 @@ function deserializePrismNode(bytes, source) {
|
|
|
19771
20051
|
}
|
|
19772
20052
|
|
|
19773
20053
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
19774
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
20054
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/nodes.ts.erb
|
|
19775
20055
|
class Node {
|
|
19776
20056
|
type;
|
|
19777
20057
|
location;
|
|
@@ -22315,6 +22595,225 @@ class ERBUnlessNode extends Node {
|
|
|
22315
22595
|
return output;
|
|
22316
22596
|
}
|
|
22317
22597
|
}
|
|
22598
|
+
class RubyRenderLocalNode extends Node {
|
|
22599
|
+
name;
|
|
22600
|
+
value;
|
|
22601
|
+
static get type() {
|
|
22602
|
+
return "AST_RUBY_RENDER_LOCAL_NODE";
|
|
22603
|
+
}
|
|
22604
|
+
static from(data) {
|
|
22605
|
+
return new RubyRenderLocalNode({
|
|
22606
|
+
type: data.type,
|
|
22607
|
+
location: Location.from(data.location),
|
|
22608
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
22609
|
+
name: data.name ? Token.from(data.name) : null,
|
|
22610
|
+
value: data.value ? fromSerializedNode((data.value)) : null,
|
|
22611
|
+
});
|
|
22612
|
+
}
|
|
22613
|
+
constructor(props) {
|
|
22614
|
+
super(props.type, props.location, props.errors);
|
|
22615
|
+
this.name = props.name;
|
|
22616
|
+
this.value = props.value;
|
|
22617
|
+
}
|
|
22618
|
+
accept(visitor) {
|
|
22619
|
+
visitor.visitRubyRenderLocalNode(this);
|
|
22620
|
+
}
|
|
22621
|
+
childNodes() {
|
|
22622
|
+
return [
|
|
22623
|
+
this.value,
|
|
22624
|
+
];
|
|
22625
|
+
}
|
|
22626
|
+
compactChildNodes() {
|
|
22627
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
22628
|
+
}
|
|
22629
|
+
recursiveErrors() {
|
|
22630
|
+
return [
|
|
22631
|
+
...this.errors,
|
|
22632
|
+
this.value ? this.value.recursiveErrors() : [],
|
|
22633
|
+
].flat();
|
|
22634
|
+
}
|
|
22635
|
+
toJSON() {
|
|
22636
|
+
return {
|
|
22637
|
+
...super.toJSON(),
|
|
22638
|
+
type: "AST_RUBY_RENDER_LOCAL_NODE",
|
|
22639
|
+
name: this.name ? this.name.toJSON() : null,
|
|
22640
|
+
value: this.value ? this.value.toJSON() : null,
|
|
22641
|
+
};
|
|
22642
|
+
}
|
|
22643
|
+
treeInspect() {
|
|
22644
|
+
let output = "";
|
|
22645
|
+
output += `@ RubyRenderLocalNode ${this.location.treeInspectWithLabel()}\n`;
|
|
22646
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
22647
|
+
output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
|
|
22648
|
+
output += `└── value: ${this.inspectNode(this.value, " ")}`;
|
|
22649
|
+
return output;
|
|
22650
|
+
}
|
|
22651
|
+
}
|
|
22652
|
+
class ERBRenderNode extends Node {
|
|
22653
|
+
tag_opening;
|
|
22654
|
+
content;
|
|
22655
|
+
tag_closing;
|
|
22656
|
+
// no-op for analyzed_ruby
|
|
22657
|
+
prism_node;
|
|
22658
|
+
partial;
|
|
22659
|
+
template_path;
|
|
22660
|
+
layout;
|
|
22661
|
+
file;
|
|
22662
|
+
inline_template;
|
|
22663
|
+
body;
|
|
22664
|
+
plain;
|
|
22665
|
+
html;
|
|
22666
|
+
renderable;
|
|
22667
|
+
collection;
|
|
22668
|
+
object;
|
|
22669
|
+
as_name;
|
|
22670
|
+
spacer_template;
|
|
22671
|
+
formats;
|
|
22672
|
+
variants;
|
|
22673
|
+
handlers;
|
|
22674
|
+
content_type;
|
|
22675
|
+
locals;
|
|
22676
|
+
static get type() {
|
|
22677
|
+
return "AST_ERB_RENDER_NODE";
|
|
22678
|
+
}
|
|
22679
|
+
static from(data) {
|
|
22680
|
+
return new ERBRenderNode({
|
|
22681
|
+
type: data.type,
|
|
22682
|
+
location: Location.from(data.location),
|
|
22683
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
22684
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
22685
|
+
content: data.content ? Token.from(data.content) : null,
|
|
22686
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
22687
|
+
// no-op for analyzed_ruby
|
|
22688
|
+
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
22689
|
+
partial: data.partial ? Token.from(data.partial) : null,
|
|
22690
|
+
template_path: data.template_path ? Token.from(data.template_path) : null,
|
|
22691
|
+
layout: data.layout ? Token.from(data.layout) : null,
|
|
22692
|
+
file: data.file ? Token.from(data.file) : null,
|
|
22693
|
+
inline_template: data.inline_template ? Token.from(data.inline_template) : null,
|
|
22694
|
+
body: data.body ? Token.from(data.body) : null,
|
|
22695
|
+
plain: data.plain ? Token.from(data.plain) : null,
|
|
22696
|
+
html: data.html ? Token.from(data.html) : null,
|
|
22697
|
+
renderable: data.renderable ? Token.from(data.renderable) : null,
|
|
22698
|
+
collection: data.collection ? Token.from(data.collection) : null,
|
|
22699
|
+
object: data.object ? Token.from(data.object) : null,
|
|
22700
|
+
as_name: data.as_name ? Token.from(data.as_name) : null,
|
|
22701
|
+
spacer_template: data.spacer_template ? Token.from(data.spacer_template) : null,
|
|
22702
|
+
formats: data.formats ? Token.from(data.formats) : null,
|
|
22703
|
+
variants: data.variants ? Token.from(data.variants) : null,
|
|
22704
|
+
handlers: data.handlers ? Token.from(data.handlers) : null,
|
|
22705
|
+
content_type: data.content_type ? Token.from(data.content_type) : null,
|
|
22706
|
+
locals: (data.locals || []).map(node => fromSerializedNode(node)),
|
|
22707
|
+
});
|
|
22708
|
+
}
|
|
22709
|
+
constructor(props) {
|
|
22710
|
+
super(props.type, props.location, props.errors);
|
|
22711
|
+
this.tag_opening = props.tag_opening;
|
|
22712
|
+
this.content = props.content;
|
|
22713
|
+
this.tag_closing = props.tag_closing;
|
|
22714
|
+
// no-op for analyzed_ruby
|
|
22715
|
+
this.prism_node = props.prism_node;
|
|
22716
|
+
this.partial = props.partial;
|
|
22717
|
+
this.template_path = props.template_path;
|
|
22718
|
+
this.layout = props.layout;
|
|
22719
|
+
this.file = props.file;
|
|
22720
|
+
this.inline_template = props.inline_template;
|
|
22721
|
+
this.body = props.body;
|
|
22722
|
+
this.plain = props.plain;
|
|
22723
|
+
this.html = props.html;
|
|
22724
|
+
this.renderable = props.renderable;
|
|
22725
|
+
this.collection = props.collection;
|
|
22726
|
+
this.object = props.object;
|
|
22727
|
+
this.as_name = props.as_name;
|
|
22728
|
+
this.spacer_template = props.spacer_template;
|
|
22729
|
+
this.formats = props.formats;
|
|
22730
|
+
this.variants = props.variants;
|
|
22731
|
+
this.handlers = props.handlers;
|
|
22732
|
+
this.content_type = props.content_type;
|
|
22733
|
+
this.locals = props.locals;
|
|
22734
|
+
}
|
|
22735
|
+
accept(visitor) {
|
|
22736
|
+
visitor.visitERBRenderNode(this);
|
|
22737
|
+
}
|
|
22738
|
+
childNodes() {
|
|
22739
|
+
return [
|
|
22740
|
+
...this.locals,
|
|
22741
|
+
];
|
|
22742
|
+
}
|
|
22743
|
+
compactChildNodes() {
|
|
22744
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
22745
|
+
}
|
|
22746
|
+
get prismNode() {
|
|
22747
|
+
if (!this.prism_node || !this.source)
|
|
22748
|
+
return null;
|
|
22749
|
+
return deserializePrismNode(this.prism_node, this.source);
|
|
22750
|
+
}
|
|
22751
|
+
recursiveErrors() {
|
|
22752
|
+
return [
|
|
22753
|
+
...this.errors,
|
|
22754
|
+
...this.locals.map(node => node.recursiveErrors()),
|
|
22755
|
+
].flat();
|
|
22756
|
+
}
|
|
22757
|
+
toJSON() {
|
|
22758
|
+
return {
|
|
22759
|
+
...super.toJSON(),
|
|
22760
|
+
type: "AST_ERB_RENDER_NODE",
|
|
22761
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
22762
|
+
content: this.content ? this.content.toJSON() : null,
|
|
22763
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
22764
|
+
// no-op for analyzed_ruby
|
|
22765
|
+
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
22766
|
+
partial: this.partial ? this.partial.toJSON() : null,
|
|
22767
|
+
template_path: this.template_path ? this.template_path.toJSON() : null,
|
|
22768
|
+
layout: this.layout ? this.layout.toJSON() : null,
|
|
22769
|
+
file: this.file ? this.file.toJSON() : null,
|
|
22770
|
+
inline_template: this.inline_template ? this.inline_template.toJSON() : null,
|
|
22771
|
+
body: this.body ? this.body.toJSON() : null,
|
|
22772
|
+
plain: this.plain ? this.plain.toJSON() : null,
|
|
22773
|
+
html: this.html ? this.html.toJSON() : null,
|
|
22774
|
+
renderable: this.renderable ? this.renderable.toJSON() : null,
|
|
22775
|
+
collection: this.collection ? this.collection.toJSON() : null,
|
|
22776
|
+
object: this.object ? this.object.toJSON() : null,
|
|
22777
|
+
as_name: this.as_name ? this.as_name.toJSON() : null,
|
|
22778
|
+
spacer_template: this.spacer_template ? this.spacer_template.toJSON() : null,
|
|
22779
|
+
formats: this.formats ? this.formats.toJSON() : null,
|
|
22780
|
+
variants: this.variants ? this.variants.toJSON() : null,
|
|
22781
|
+
handlers: this.handlers ? this.handlers.toJSON() : null,
|
|
22782
|
+
content_type: this.content_type ? this.content_type.toJSON() : null,
|
|
22783
|
+
locals: this.locals.map(node => node.toJSON()),
|
|
22784
|
+
};
|
|
22785
|
+
}
|
|
22786
|
+
treeInspect() {
|
|
22787
|
+
let output = "";
|
|
22788
|
+
output += `@ ERBRenderNode ${this.location.treeInspectWithLabel()}\n`;
|
|
22789
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
22790
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
22791
|
+
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
22792
|
+
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
22793
|
+
if (this.prism_node) {
|
|
22794
|
+
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
22795
|
+
}
|
|
22796
|
+
output += `├── partial: ${this.partial ? this.partial.treeInspect() : "∅"}\n`;
|
|
22797
|
+
output += `├── template_path: ${this.template_path ? this.template_path.treeInspect() : "∅"}\n`;
|
|
22798
|
+
output += `├── layout: ${this.layout ? this.layout.treeInspect() : "∅"}\n`;
|
|
22799
|
+
output += `├── file: ${this.file ? this.file.treeInspect() : "∅"}\n`;
|
|
22800
|
+
output += `├── inline_template: ${this.inline_template ? this.inline_template.treeInspect() : "∅"}\n`;
|
|
22801
|
+
output += `├── body: ${this.body ? this.body.treeInspect() : "∅"}\n`;
|
|
22802
|
+
output += `├── plain: ${this.plain ? this.plain.treeInspect() : "∅"}\n`;
|
|
22803
|
+
output += `├── html: ${this.html ? this.html.treeInspect() : "∅"}\n`;
|
|
22804
|
+
output += `├── renderable: ${this.renderable ? this.renderable.treeInspect() : "∅"}\n`;
|
|
22805
|
+
output += `├── collection: ${this.collection ? this.collection.treeInspect() : "∅"}\n`;
|
|
22806
|
+
output += `├── object: ${this.object ? this.object.treeInspect() : "∅"}\n`;
|
|
22807
|
+
output += `├── as_name: ${this.as_name ? this.as_name.treeInspect() : "∅"}\n`;
|
|
22808
|
+
output += `├── spacer_template: ${this.spacer_template ? this.spacer_template.treeInspect() : "∅"}\n`;
|
|
22809
|
+
output += `├── formats: ${this.formats ? this.formats.treeInspect() : "∅"}\n`;
|
|
22810
|
+
output += `├── variants: ${this.variants ? this.variants.treeInspect() : "∅"}\n`;
|
|
22811
|
+
output += `├── handlers: ${this.handlers ? this.handlers.treeInspect() : "∅"}\n`;
|
|
22812
|
+
output += `├── content_type: ${this.content_type ? this.content_type.treeInspect() : "∅"}\n`;
|
|
22813
|
+
output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
|
|
22814
|
+
return output;
|
|
22815
|
+
}
|
|
22816
|
+
}
|
|
22318
22817
|
class ERBYieldNode extends Node {
|
|
22319
22818
|
tag_opening;
|
|
22320
22819
|
content;
|
|
@@ -22478,6 +22977,8 @@ function fromSerializedNode(node) {
|
|
|
22478
22977
|
case "AST_ERB_ENSURE_NODE": return ERBEnsureNode.from(node);
|
|
22479
22978
|
case "AST_ERB_BEGIN_NODE": return ERBBeginNode.from(node);
|
|
22480
22979
|
case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
|
|
22980
|
+
case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
|
|
22981
|
+
case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
|
|
22481
22982
|
case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
|
|
22482
22983
|
case "AST_ERB_IN_NODE": return ERBInNode.from(node);
|
|
22483
22984
|
default:
|
|
@@ -22527,6 +23028,7 @@ const DEFAULT_PARSER_OPTIONS = {
|
|
|
22527
23028
|
analyze: true,
|
|
22528
23029
|
strict: true,
|
|
22529
23030
|
action_view_helpers: false,
|
|
23031
|
+
render_nodes: false,
|
|
22530
23032
|
prism_nodes: false,
|
|
22531
23033
|
prism_nodes_deep: false,
|
|
22532
23034
|
prism_program: false,
|
|
@@ -22543,6 +23045,8 @@ class ParserOptions {
|
|
|
22543
23045
|
analyze;
|
|
22544
23046
|
/** Whether ActionView tag helper transformation was enabled during parsing. */
|
|
22545
23047
|
action_view_helpers;
|
|
23048
|
+
/** Whether ActionView render call detection was enabled during parsing. */
|
|
23049
|
+
render_nodes;
|
|
22546
23050
|
/** Whether Prism node serialization was enabled during parsing. */
|
|
22547
23051
|
prism_nodes;
|
|
22548
23052
|
/** Whether deep Prism node serialization was enabled during parsing. */
|
|
@@ -22557,6 +23061,7 @@ class ParserOptions {
|
|
|
22557
23061
|
this.track_whitespace = options.track_whitespace ?? DEFAULT_PARSER_OPTIONS.track_whitespace;
|
|
22558
23062
|
this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
|
|
22559
23063
|
this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
|
|
23064
|
+
this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
|
|
22560
23065
|
this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
|
|
22561
23066
|
this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
|
|
22562
23067
|
this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
|
|
@@ -22636,7 +23141,7 @@ class ParseResult extends Result {
|
|
|
22636
23141
|
}
|
|
22637
23142
|
|
|
22638
23143
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
22639
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23144
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
22640
23145
|
/**
|
|
22641
23146
|
* Type guard functions for AST nodes.
|
|
22642
23147
|
* These functions provide type checking by combining both instanceof
|
|
@@ -22931,6 +23436,22 @@ function isERBUnlessNode(node) {
|
|
|
22931
23436
|
return false;
|
|
22932
23437
|
return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
|
|
22933
23438
|
}
|
|
23439
|
+
/**
|
|
23440
|
+
* Checks if a node is a RubyRenderLocalNode
|
|
23441
|
+
*/
|
|
23442
|
+
function isRubyRenderLocalNode(node) {
|
|
23443
|
+
if (!node)
|
|
23444
|
+
return false;
|
|
23445
|
+
return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || node.constructor.type === "AST_RUBY_RENDER_LOCAL_NODE";
|
|
23446
|
+
}
|
|
23447
|
+
/**
|
|
23448
|
+
* Checks if a node is a ERBRenderNode
|
|
23449
|
+
*/
|
|
23450
|
+
function isERBRenderNode(node) {
|
|
23451
|
+
if (!node)
|
|
23452
|
+
return false;
|
|
23453
|
+
return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
|
|
23454
|
+
}
|
|
22934
23455
|
/**
|
|
22935
23456
|
* Checks if a node is a ERBYieldNode
|
|
22936
23457
|
*/
|
|
@@ -22967,6 +23488,7 @@ function isERBNode(node) {
|
|
|
22967
23488
|
isERBEnsureNode(node) ||
|
|
22968
23489
|
isERBBeginNode(node) ||
|
|
22969
23490
|
isERBUnlessNode(node) ||
|
|
23491
|
+
isERBRenderNode(node) ||
|
|
22970
23492
|
isERBYieldNode(node) ||
|
|
22971
23493
|
isERBInNode(node);
|
|
22972
23494
|
}
|
|
@@ -23017,6 +23539,8 @@ const NODE_TYPE_GUARDS = new Map([
|
|
|
23017
23539
|
[ERBEnsureNode, isERBEnsureNode],
|
|
23018
23540
|
[ERBBeginNode, isERBBeginNode],
|
|
23019
23541
|
[ERBUnlessNode, isERBUnlessNode],
|
|
23542
|
+
[RubyRenderLocalNode, isRubyRenderLocalNode],
|
|
23543
|
+
[ERBRenderNode, isERBRenderNode],
|
|
23020
23544
|
[ERBYieldNode, isERBYieldNode],
|
|
23021
23545
|
[ERBInNode, isERBInNode],
|
|
23022
23546
|
]);
|
|
@@ -23067,6 +23591,8 @@ const AST_TYPE_GUARDS = new Map([
|
|
|
23067
23591
|
["AST_ERB_ENSURE_NODE", isERBEnsureNode],
|
|
23068
23592
|
["AST_ERB_BEGIN_NODE", isERBBeginNode],
|
|
23069
23593
|
["AST_ERB_UNLESS_NODE", isERBUnlessNode],
|
|
23594
|
+
["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
|
|
23595
|
+
["AST_ERB_RENDER_NODE", isERBRenderNode],
|
|
23070
23596
|
["AST_ERB_YIELD_NODE", isERBYieldNode],
|
|
23071
23597
|
["AST_ERB_IN_NODE", isERBInNode],
|
|
23072
23598
|
]);
|
|
@@ -23398,7 +23924,7 @@ function getNodesAfterPosition(nodes, position, inclusive = true) {
|
|
|
23398
23924
|
}
|
|
23399
23925
|
|
|
23400
23926
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
23401
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23927
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/visitor.ts.erb
|
|
23402
23928
|
class Visitor {
|
|
23403
23929
|
visit(node) {
|
|
23404
23930
|
if (!node)
|
|
@@ -23577,6 +24103,15 @@ class Visitor {
|
|
|
23577
24103
|
this.visitERBNode(node);
|
|
23578
24104
|
this.visitChildNodes(node);
|
|
23579
24105
|
}
|
|
24106
|
+
visitRubyRenderLocalNode(node) {
|
|
24107
|
+
this.visitNode(node);
|
|
24108
|
+
this.visitChildNodes(node);
|
|
24109
|
+
}
|
|
24110
|
+
visitERBRenderNode(node) {
|
|
24111
|
+
this.visitNode(node);
|
|
24112
|
+
this.visitERBNode(node);
|
|
24113
|
+
this.visitChildNodes(node);
|
|
24114
|
+
}
|
|
23580
24115
|
visitERBYieldNode(node) {
|
|
23581
24116
|
this.visitNode(node);
|
|
23582
24117
|
this.visitERBNode(node);
|
|
@@ -24027,6 +24562,12 @@ class IdentityPrinter extends Printer {
|
|
|
24027
24562
|
this.visit(node.end_node);
|
|
24028
24563
|
}
|
|
24029
24564
|
}
|
|
24565
|
+
visitERBRenderNode(node) {
|
|
24566
|
+
this.printERBNode(node);
|
|
24567
|
+
}
|
|
24568
|
+
visitRubyRenderLocalNode(_node) {
|
|
24569
|
+
// extracted metadata, nothing to print
|
|
24570
|
+
}
|
|
24030
24571
|
visitERBYieldNode(node) {
|
|
24031
24572
|
this.printERBNode(node);
|
|
24032
24573
|
}
|
|
@@ -26496,6 +27037,12 @@ class FormatPrinter extends Printer {
|
|
|
26496
27037
|
visitERBEndNode(node) {
|
|
26497
27038
|
this.printERBNode(node);
|
|
26498
27039
|
}
|
|
27040
|
+
visitERBRenderNode(node) {
|
|
27041
|
+
this.printERBNode(node);
|
|
27042
|
+
}
|
|
27043
|
+
visitRubyRenderLocalNode(_node) {
|
|
27044
|
+
// extracted metadata, nothing to print
|
|
27045
|
+
}
|
|
26499
27046
|
visitERBYieldNode(node) {
|
|
26500
27047
|
this.trackBoundary(node, () => {
|
|
26501
27048
|
this.printERBNode(node);
|