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