@herb-tools/rewriter 0.9.2 → 0.9.3
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 +575 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +575 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/loader.cjs +575 -17
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.esm.js +575 -17
- package/dist/loader.esm.js.map +1 -1
- package/dist/types/built-ins/action-view-tag-helper-to-html.d.ts +1 -1
- package/package.json +4 -4
- package/src/built-ins/action-view-tag-helper-to-html.ts +54 -10
- package/src/built-ins/html-to-action-view-tag-helper.ts +19 -4
package/dist/loader.esm.js
CHANGED
|
@@ -170,6 +170,9 @@ class Token {
|
|
|
170
170
|
static from(token) {
|
|
171
171
|
return new Token(token.value, Range.from(token.range), Location.from(token.location), token.type);
|
|
172
172
|
}
|
|
173
|
+
static synthetic(value, type = "SYNTETHIC") {
|
|
174
|
+
return new Token(value, Range.zero, Location.zero, type);
|
|
175
|
+
}
|
|
173
176
|
constructor(value, range, location, type) {
|
|
174
177
|
this.value = value;
|
|
175
178
|
this.range = range;
|
|
@@ -204,7 +207,7 @@ class Token {
|
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
207
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
210
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/errors.ts.erb
|
|
208
211
|
class HerbError {
|
|
209
212
|
type;
|
|
210
213
|
message;
|
|
@@ -1478,6 +1481,284 @@ class RenderLayoutWithoutBlockError extends HerbError {
|
|
|
1478
1481
|
return output;
|
|
1479
1482
|
}
|
|
1480
1483
|
}
|
|
1484
|
+
class StrictLocalsPositionalArgumentError extends HerbError {
|
|
1485
|
+
name;
|
|
1486
|
+
static from(data) {
|
|
1487
|
+
return new StrictLocalsPositionalArgumentError({
|
|
1488
|
+
type: data.type,
|
|
1489
|
+
message: data.message,
|
|
1490
|
+
location: Location.from(data.location),
|
|
1491
|
+
name: data.name,
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
constructor(props) {
|
|
1495
|
+
super(props.type, props.message, props.location);
|
|
1496
|
+
this.name = props.name;
|
|
1497
|
+
}
|
|
1498
|
+
toJSON() {
|
|
1499
|
+
return {
|
|
1500
|
+
...super.toJSON(),
|
|
1501
|
+
type: "STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR",
|
|
1502
|
+
name: this.name,
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
toMonacoDiagnostic() {
|
|
1506
|
+
return {
|
|
1507
|
+
line: this.location.start.line,
|
|
1508
|
+
column: this.location.start.column,
|
|
1509
|
+
endLine: this.location.end.line,
|
|
1510
|
+
endColumn: this.location.end.column,
|
|
1511
|
+
message: this.message,
|
|
1512
|
+
severity: 'error'
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
treeInspect() {
|
|
1516
|
+
let output = "";
|
|
1517
|
+
output += `@ StrictLocalsPositionalArgumentError ${this.location.treeInspectWithLabel()}\n`;
|
|
1518
|
+
output += `├── message: "${this.message}"\n`;
|
|
1519
|
+
output += `└── name: ${JSON.stringify(this.name)}\n`;
|
|
1520
|
+
return output;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
class StrictLocalsBlockArgumentError extends HerbError {
|
|
1524
|
+
name;
|
|
1525
|
+
static from(data) {
|
|
1526
|
+
return new StrictLocalsBlockArgumentError({
|
|
1527
|
+
type: data.type,
|
|
1528
|
+
message: data.message,
|
|
1529
|
+
location: Location.from(data.location),
|
|
1530
|
+
name: data.name,
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
constructor(props) {
|
|
1534
|
+
super(props.type, props.message, props.location);
|
|
1535
|
+
this.name = props.name;
|
|
1536
|
+
}
|
|
1537
|
+
toJSON() {
|
|
1538
|
+
return {
|
|
1539
|
+
...super.toJSON(),
|
|
1540
|
+
type: "STRICT_LOCALS_BLOCK_ARGUMENT_ERROR",
|
|
1541
|
+
name: this.name,
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
toMonacoDiagnostic() {
|
|
1545
|
+
return {
|
|
1546
|
+
line: this.location.start.line,
|
|
1547
|
+
column: this.location.start.column,
|
|
1548
|
+
endLine: this.location.end.line,
|
|
1549
|
+
endColumn: this.location.end.column,
|
|
1550
|
+
message: this.message,
|
|
1551
|
+
severity: 'error'
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
treeInspect() {
|
|
1555
|
+
let output = "";
|
|
1556
|
+
output += `@ StrictLocalsBlockArgumentError ${this.location.treeInspectWithLabel()}\n`;
|
|
1557
|
+
output += `├── message: "${this.message}"\n`;
|
|
1558
|
+
output += `└── name: ${JSON.stringify(this.name)}\n`;
|
|
1559
|
+
return output;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
class StrictLocalsSplatArgumentError extends HerbError {
|
|
1563
|
+
name;
|
|
1564
|
+
static from(data) {
|
|
1565
|
+
return new StrictLocalsSplatArgumentError({
|
|
1566
|
+
type: data.type,
|
|
1567
|
+
message: data.message,
|
|
1568
|
+
location: Location.from(data.location),
|
|
1569
|
+
name: data.name,
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
constructor(props) {
|
|
1573
|
+
super(props.type, props.message, props.location);
|
|
1574
|
+
this.name = props.name;
|
|
1575
|
+
}
|
|
1576
|
+
toJSON() {
|
|
1577
|
+
return {
|
|
1578
|
+
...super.toJSON(),
|
|
1579
|
+
type: "STRICT_LOCALS_SPLAT_ARGUMENT_ERROR",
|
|
1580
|
+
name: this.name,
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
toMonacoDiagnostic() {
|
|
1584
|
+
return {
|
|
1585
|
+
line: this.location.start.line,
|
|
1586
|
+
column: this.location.start.column,
|
|
1587
|
+
endLine: this.location.end.line,
|
|
1588
|
+
endColumn: this.location.end.column,
|
|
1589
|
+
message: this.message,
|
|
1590
|
+
severity: 'error'
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
treeInspect() {
|
|
1594
|
+
let output = "";
|
|
1595
|
+
output += `@ StrictLocalsSplatArgumentError ${this.location.treeInspectWithLabel()}\n`;
|
|
1596
|
+
output += `├── message: "${this.message}"\n`;
|
|
1597
|
+
output += `└── name: ${JSON.stringify(this.name)}\n`;
|
|
1598
|
+
return output;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
class StrictLocalsMissingParenthesisError extends HerbError {
|
|
1602
|
+
rest;
|
|
1603
|
+
static from(data) {
|
|
1604
|
+
return new StrictLocalsMissingParenthesisError({
|
|
1605
|
+
type: data.type,
|
|
1606
|
+
message: data.message,
|
|
1607
|
+
location: Location.from(data.location),
|
|
1608
|
+
rest: data.rest,
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
constructor(props) {
|
|
1612
|
+
super(props.type, props.message, props.location);
|
|
1613
|
+
this.rest = props.rest;
|
|
1614
|
+
}
|
|
1615
|
+
toJSON() {
|
|
1616
|
+
return {
|
|
1617
|
+
...super.toJSON(),
|
|
1618
|
+
type: "STRICT_LOCALS_MISSING_PARENTHESIS_ERROR",
|
|
1619
|
+
rest: this.rest,
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
toMonacoDiagnostic() {
|
|
1623
|
+
return {
|
|
1624
|
+
line: this.location.start.line,
|
|
1625
|
+
column: this.location.start.column,
|
|
1626
|
+
endLine: this.location.end.line,
|
|
1627
|
+
endColumn: this.location.end.column,
|
|
1628
|
+
message: this.message,
|
|
1629
|
+
severity: 'error'
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
treeInspect() {
|
|
1633
|
+
let output = "";
|
|
1634
|
+
output += `@ StrictLocalsMissingParenthesisError ${this.location.treeInspectWithLabel()}\n`;
|
|
1635
|
+
output += `├── message: "${this.message}"\n`;
|
|
1636
|
+
output += `└── rest: ${JSON.stringify(this.rest)}\n`;
|
|
1637
|
+
return output;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
class StrictLocalsDuplicateDeclarationError extends HerbError {
|
|
1641
|
+
static from(data) {
|
|
1642
|
+
return new StrictLocalsDuplicateDeclarationError({
|
|
1643
|
+
type: data.type,
|
|
1644
|
+
message: data.message,
|
|
1645
|
+
location: Location.from(data.location),
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
constructor(props) {
|
|
1649
|
+
super(props.type, props.message, props.location);
|
|
1650
|
+
}
|
|
1651
|
+
toJSON() {
|
|
1652
|
+
return {
|
|
1653
|
+
...super.toJSON(),
|
|
1654
|
+
type: "STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR",
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
toMonacoDiagnostic() {
|
|
1658
|
+
return {
|
|
1659
|
+
line: this.location.start.line,
|
|
1660
|
+
column: this.location.start.column,
|
|
1661
|
+
endLine: this.location.end.line,
|
|
1662
|
+
endColumn: this.location.end.column,
|
|
1663
|
+
message: this.message,
|
|
1664
|
+
severity: 'error'
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
treeInspect() {
|
|
1668
|
+
let output = "";
|
|
1669
|
+
output += `@ StrictLocalsDuplicateDeclarationError ${this.location.treeInspectWithLabel()}\n`;
|
|
1670
|
+
output += `└── message: "${this.message}"\n`;
|
|
1671
|
+
return output;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
class VoidElementContentError extends HerbError {
|
|
1675
|
+
tag_name;
|
|
1676
|
+
helper_name;
|
|
1677
|
+
content_type;
|
|
1678
|
+
static from(data) {
|
|
1679
|
+
return new VoidElementContentError({
|
|
1680
|
+
type: data.type,
|
|
1681
|
+
message: data.message,
|
|
1682
|
+
location: Location.from(data.location),
|
|
1683
|
+
tag_name: data.tag_name ? Token.from(data.tag_name) : null,
|
|
1684
|
+
helper_name: data.helper_name,
|
|
1685
|
+
content_type: data.content_type,
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
constructor(props) {
|
|
1689
|
+
super(props.type, props.message, props.location);
|
|
1690
|
+
this.tag_name = props.tag_name;
|
|
1691
|
+
this.helper_name = props.helper_name;
|
|
1692
|
+
this.content_type = props.content_type;
|
|
1693
|
+
}
|
|
1694
|
+
toJSON() {
|
|
1695
|
+
return {
|
|
1696
|
+
...super.toJSON(),
|
|
1697
|
+
type: "VOID_ELEMENT_CONTENT_ERROR",
|
|
1698
|
+
tag_name: this.tag_name ? this.tag_name.toJSON() : null,
|
|
1699
|
+
helper_name: this.helper_name,
|
|
1700
|
+
content_type: this.content_type,
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
toMonacoDiagnostic() {
|
|
1704
|
+
return {
|
|
1705
|
+
line: this.location.start.line,
|
|
1706
|
+
column: this.location.start.column,
|
|
1707
|
+
endLine: this.location.end.line,
|
|
1708
|
+
endColumn: this.location.end.column,
|
|
1709
|
+
message: this.message,
|
|
1710
|
+
severity: 'error'
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
treeInspect() {
|
|
1714
|
+
let output = "";
|
|
1715
|
+
output += `@ VoidElementContentError ${this.location.treeInspectWithLabel()}\n`;
|
|
1716
|
+
output += `├── message: "${this.message}"\n`;
|
|
1717
|
+
output += `├── tag_name: ${this.tag_name ? this.tag_name.treeInspect() : "∅"}\n`;
|
|
1718
|
+
output += `├── helper_name: ${JSON.stringify(this.helper_name)}\n`;
|
|
1719
|
+
output += `└── content_type: ${JSON.stringify(this.content_type)}\n`;
|
|
1720
|
+
return output;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
class DotNotationCasingError extends HerbError {
|
|
1724
|
+
segment;
|
|
1725
|
+
static from(data) {
|
|
1726
|
+
return new DotNotationCasingError({
|
|
1727
|
+
type: data.type,
|
|
1728
|
+
message: data.message,
|
|
1729
|
+
location: Location.from(data.location),
|
|
1730
|
+
segment: data.segment ? Token.from(data.segment) : null,
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
constructor(props) {
|
|
1734
|
+
super(props.type, props.message, props.location);
|
|
1735
|
+
this.segment = props.segment;
|
|
1736
|
+
}
|
|
1737
|
+
toJSON() {
|
|
1738
|
+
return {
|
|
1739
|
+
...super.toJSON(),
|
|
1740
|
+
type: "DOT_NOTATION_CASING_ERROR",
|
|
1741
|
+
segment: this.segment ? this.segment.toJSON() : null,
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
toMonacoDiagnostic() {
|
|
1745
|
+
return {
|
|
1746
|
+
line: this.location.start.line,
|
|
1747
|
+
column: this.location.start.column,
|
|
1748
|
+
endLine: this.location.end.line,
|
|
1749
|
+
endColumn: this.location.end.column,
|
|
1750
|
+
message: this.message,
|
|
1751
|
+
severity: 'error'
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
treeInspect() {
|
|
1755
|
+
let output = "";
|
|
1756
|
+
output += `@ DotNotationCasingError ${this.location.treeInspectWithLabel()}\n`;
|
|
1757
|
+
output += `├── message: "${this.message}"\n`;
|
|
1758
|
+
output += `└── segment: ${this.segment ? this.segment.treeInspect() : "∅"}\n`;
|
|
1759
|
+
return output;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1481
1762
|
function fromSerializedError(error) {
|
|
1482
1763
|
switch (error.type) {
|
|
1483
1764
|
case "UNEXPECTED_ERROR": return UnexpectedError.from(error);
|
|
@@ -1510,6 +1791,13 @@ function fromSerializedError(error) {
|
|
|
1510
1791
|
case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error);
|
|
1511
1792
|
case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error);
|
|
1512
1793
|
case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error);
|
|
1794
|
+
case "STRICT_LOCALS_POSITIONAL_ARGUMENT_ERROR": return StrictLocalsPositionalArgumentError.from(error);
|
|
1795
|
+
case "STRICT_LOCALS_BLOCK_ARGUMENT_ERROR": return StrictLocalsBlockArgumentError.from(error);
|
|
1796
|
+
case "STRICT_LOCALS_SPLAT_ARGUMENT_ERROR": return StrictLocalsSplatArgumentError.from(error);
|
|
1797
|
+
case "STRICT_LOCALS_MISSING_PARENTHESIS_ERROR": return StrictLocalsMissingParenthesisError.from(error);
|
|
1798
|
+
case "STRICT_LOCALS_DUPLICATE_DECLARATION_ERROR": return StrictLocalsDuplicateDeclarationError.from(error);
|
|
1799
|
+
case "VOID_ELEMENT_CONTENT_ERROR": return VoidElementContentError.from(error);
|
|
1800
|
+
case "DOT_NOTATION_CASING_ERROR": return DotNotationCasingError.from(error);
|
|
1513
1801
|
default:
|
|
1514
1802
|
throw new Error(`Unknown node type: ${error.type}`);
|
|
1515
1803
|
}
|
|
@@ -20098,7 +20386,7 @@ function deserializePrismNode(bytes, source) {
|
|
|
20098
20386
|
}
|
|
20099
20387
|
|
|
20100
20388
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
20101
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
20389
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/nodes.ts.erb
|
|
20102
20390
|
class Node {
|
|
20103
20391
|
type;
|
|
20104
20392
|
location;
|
|
@@ -21719,6 +22007,9 @@ class ERBBlockNode extends Node {
|
|
|
21719
22007
|
tag_closing;
|
|
21720
22008
|
prism_node;
|
|
21721
22009
|
body;
|
|
22010
|
+
rescue_clause;
|
|
22011
|
+
else_clause;
|
|
22012
|
+
ensure_clause;
|
|
21722
22013
|
end_node;
|
|
21723
22014
|
static get type() {
|
|
21724
22015
|
return "AST_ERB_BLOCK_NODE";
|
|
@@ -21733,6 +22024,9 @@ class ERBBlockNode extends Node {
|
|
|
21733
22024
|
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
21734
22025
|
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
21735
22026
|
body: (data.body || []).map(node => fromSerializedNode(node)),
|
|
22027
|
+
rescue_clause: data.rescue_clause ? fromSerializedNode((data.rescue_clause)) : null,
|
|
22028
|
+
else_clause: data.else_clause ? fromSerializedNode((data.else_clause)) : null,
|
|
22029
|
+
ensure_clause: data.ensure_clause ? fromSerializedNode((data.ensure_clause)) : null,
|
|
21736
22030
|
end_node: data.end_node ? fromSerializedNode((data.end_node)) : null,
|
|
21737
22031
|
});
|
|
21738
22032
|
}
|
|
@@ -21743,6 +22037,9 @@ class ERBBlockNode extends Node {
|
|
|
21743
22037
|
this.tag_closing = props.tag_closing;
|
|
21744
22038
|
this.prism_node = props.prism_node;
|
|
21745
22039
|
this.body = props.body;
|
|
22040
|
+
this.rescue_clause = props.rescue_clause;
|
|
22041
|
+
this.else_clause = props.else_clause;
|
|
22042
|
+
this.ensure_clause = props.ensure_clause;
|
|
21746
22043
|
this.end_node = props.end_node;
|
|
21747
22044
|
}
|
|
21748
22045
|
accept(visitor) {
|
|
@@ -21751,6 +22048,9 @@ class ERBBlockNode extends Node {
|
|
|
21751
22048
|
childNodes() {
|
|
21752
22049
|
return [
|
|
21753
22050
|
...this.body,
|
|
22051
|
+
this.rescue_clause,
|
|
22052
|
+
this.else_clause,
|
|
22053
|
+
this.ensure_clause,
|
|
21754
22054
|
this.end_node,
|
|
21755
22055
|
];
|
|
21756
22056
|
}
|
|
@@ -21766,6 +22066,9 @@ class ERBBlockNode extends Node {
|
|
|
21766
22066
|
return [
|
|
21767
22067
|
...this.errors,
|
|
21768
22068
|
...this.body.map(node => node.recursiveErrors()),
|
|
22069
|
+
this.rescue_clause ? this.rescue_clause.recursiveErrors() : [],
|
|
22070
|
+
this.else_clause ? this.else_clause.recursiveErrors() : [],
|
|
22071
|
+
this.ensure_clause ? this.ensure_clause.recursiveErrors() : [],
|
|
21769
22072
|
this.end_node ? this.end_node.recursiveErrors() : [],
|
|
21770
22073
|
].flat();
|
|
21771
22074
|
}
|
|
@@ -21778,6 +22081,9 @@ class ERBBlockNode extends Node {
|
|
|
21778
22081
|
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
21779
22082
|
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
21780
22083
|
body: this.body.map(node => node.toJSON()),
|
|
22084
|
+
rescue_clause: this.rescue_clause ? this.rescue_clause.toJSON() : null,
|
|
22085
|
+
else_clause: this.else_clause ? this.else_clause.toJSON() : null,
|
|
22086
|
+
ensure_clause: this.ensure_clause ? this.ensure_clause.toJSON() : null,
|
|
21781
22087
|
end_node: this.end_node ? this.end_node.toJSON() : null,
|
|
21782
22088
|
};
|
|
21783
22089
|
}
|
|
@@ -21792,6 +22098,9 @@ class ERBBlockNode extends Node {
|
|
|
21792
22098
|
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
21793
22099
|
}
|
|
21794
22100
|
output += `├── body: ${this.inspectArray(this.body, "│ ")}`;
|
|
22101
|
+
output += `├── rescue_clause: ${this.inspectNode(this.rescue_clause, "│ ")}`;
|
|
22102
|
+
output += `├── else_clause: ${this.inspectNode(this.else_clause, "│ ")}`;
|
|
22103
|
+
output += `├── ensure_clause: ${this.inspectNode(this.ensure_clause, "│ ")}`;
|
|
21795
22104
|
output += `└── end_node: ${this.inspectNode(this.end_node, " ")}`;
|
|
21796
22105
|
return output;
|
|
21797
22106
|
}
|
|
@@ -22861,6 +23170,150 @@ class ERBRenderNode extends Node {
|
|
|
22861
23170
|
return output;
|
|
22862
23171
|
}
|
|
22863
23172
|
}
|
|
23173
|
+
class RubyStrictLocalNode extends Node {
|
|
23174
|
+
name;
|
|
23175
|
+
default_value;
|
|
23176
|
+
required;
|
|
23177
|
+
double_splat;
|
|
23178
|
+
static get type() {
|
|
23179
|
+
return "AST_RUBY_STRICT_LOCAL_NODE";
|
|
23180
|
+
}
|
|
23181
|
+
static from(data) {
|
|
23182
|
+
return new RubyStrictLocalNode({
|
|
23183
|
+
type: data.type,
|
|
23184
|
+
location: Location.from(data.location),
|
|
23185
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
23186
|
+
name: data.name ? Token.from(data.name) : null,
|
|
23187
|
+
default_value: data.default_value ? fromSerializedNode((data.default_value)) : null,
|
|
23188
|
+
required: data.required,
|
|
23189
|
+
double_splat: data.double_splat,
|
|
23190
|
+
});
|
|
23191
|
+
}
|
|
23192
|
+
constructor(props) {
|
|
23193
|
+
super(props.type, props.location, props.errors);
|
|
23194
|
+
this.name = props.name;
|
|
23195
|
+
this.default_value = props.default_value;
|
|
23196
|
+
this.required = props.required;
|
|
23197
|
+
this.double_splat = props.double_splat;
|
|
23198
|
+
}
|
|
23199
|
+
accept(visitor) {
|
|
23200
|
+
visitor.visitRubyStrictLocalNode(this);
|
|
23201
|
+
}
|
|
23202
|
+
childNodes() {
|
|
23203
|
+
return [
|
|
23204
|
+
this.default_value,
|
|
23205
|
+
];
|
|
23206
|
+
}
|
|
23207
|
+
compactChildNodes() {
|
|
23208
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
23209
|
+
}
|
|
23210
|
+
recursiveErrors() {
|
|
23211
|
+
return [
|
|
23212
|
+
...this.errors,
|
|
23213
|
+
this.default_value ? this.default_value.recursiveErrors() : [],
|
|
23214
|
+
].flat();
|
|
23215
|
+
}
|
|
23216
|
+
toJSON() {
|
|
23217
|
+
return {
|
|
23218
|
+
...super.toJSON(),
|
|
23219
|
+
type: "AST_RUBY_STRICT_LOCAL_NODE",
|
|
23220
|
+
name: this.name ? this.name.toJSON() : null,
|
|
23221
|
+
default_value: this.default_value ? this.default_value.toJSON() : null,
|
|
23222
|
+
required: this.required,
|
|
23223
|
+
double_splat: this.double_splat,
|
|
23224
|
+
};
|
|
23225
|
+
}
|
|
23226
|
+
treeInspect() {
|
|
23227
|
+
let output = "";
|
|
23228
|
+
output += `@ RubyStrictLocalNode ${this.location.treeInspectWithLabel()}\n`;
|
|
23229
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
23230
|
+
output += `├── name: ${this.name ? this.name.treeInspect() : "∅"}\n`;
|
|
23231
|
+
output += `├── default_value: ${this.inspectNode(this.default_value, "│ ")}`;
|
|
23232
|
+
output += `├── required: ${typeof this.required === 'boolean' ? String(this.required) : "∅"}\n`;
|
|
23233
|
+
output += `└── double_splat: ${typeof this.double_splat === 'boolean' ? String(this.double_splat) : "∅"}\n`;
|
|
23234
|
+
return output;
|
|
23235
|
+
}
|
|
23236
|
+
}
|
|
23237
|
+
class ERBStrictLocalsNode extends Node {
|
|
23238
|
+
tag_opening;
|
|
23239
|
+
content;
|
|
23240
|
+
tag_closing;
|
|
23241
|
+
// no-op for analyzed_ruby
|
|
23242
|
+
prism_node;
|
|
23243
|
+
locals;
|
|
23244
|
+
static get type() {
|
|
23245
|
+
return "AST_ERB_STRICT_LOCALS_NODE";
|
|
23246
|
+
}
|
|
23247
|
+
static from(data) {
|
|
23248
|
+
return new ERBStrictLocalsNode({
|
|
23249
|
+
type: data.type,
|
|
23250
|
+
location: Location.from(data.location),
|
|
23251
|
+
errors: (data.errors || []).map(error => HerbError.from(error)),
|
|
23252
|
+
tag_opening: data.tag_opening ? Token.from(data.tag_opening) : null,
|
|
23253
|
+
content: data.content ? Token.from(data.content) : null,
|
|
23254
|
+
tag_closing: data.tag_closing ? Token.from(data.tag_closing) : null,
|
|
23255
|
+
// no-op for analyzed_ruby
|
|
23256
|
+
prism_node: data.prism_node ? new Uint8Array(data.prism_node) : null,
|
|
23257
|
+
locals: (data.locals || []).map(node => fromSerializedNode(node)),
|
|
23258
|
+
});
|
|
23259
|
+
}
|
|
23260
|
+
constructor(props) {
|
|
23261
|
+
super(props.type, props.location, props.errors);
|
|
23262
|
+
this.tag_opening = props.tag_opening;
|
|
23263
|
+
this.content = props.content;
|
|
23264
|
+
this.tag_closing = props.tag_closing;
|
|
23265
|
+
// no-op for analyzed_ruby
|
|
23266
|
+
this.prism_node = props.prism_node;
|
|
23267
|
+
this.locals = props.locals;
|
|
23268
|
+
}
|
|
23269
|
+
accept(visitor) {
|
|
23270
|
+
visitor.visitERBStrictLocalsNode(this);
|
|
23271
|
+
}
|
|
23272
|
+
childNodes() {
|
|
23273
|
+
return [
|
|
23274
|
+
...this.locals,
|
|
23275
|
+
];
|
|
23276
|
+
}
|
|
23277
|
+
compactChildNodes() {
|
|
23278
|
+
return this.childNodes().filter(node => node !== null && node !== undefined);
|
|
23279
|
+
}
|
|
23280
|
+
get prismNode() {
|
|
23281
|
+
if (!this.prism_node || !this.source)
|
|
23282
|
+
return null;
|
|
23283
|
+
return deserializePrismNode(this.prism_node, this.source);
|
|
23284
|
+
}
|
|
23285
|
+
recursiveErrors() {
|
|
23286
|
+
return [
|
|
23287
|
+
...this.errors,
|
|
23288
|
+
...this.locals.map(node => node.recursiveErrors()),
|
|
23289
|
+
].flat();
|
|
23290
|
+
}
|
|
23291
|
+
toJSON() {
|
|
23292
|
+
return {
|
|
23293
|
+
...super.toJSON(),
|
|
23294
|
+
type: "AST_ERB_STRICT_LOCALS_NODE",
|
|
23295
|
+
tag_opening: this.tag_opening ? this.tag_opening.toJSON() : null,
|
|
23296
|
+
content: this.content ? this.content.toJSON() : null,
|
|
23297
|
+
tag_closing: this.tag_closing ? this.tag_closing.toJSON() : null,
|
|
23298
|
+
// no-op for analyzed_ruby
|
|
23299
|
+
prism_node: this.prism_node ? Array.from(this.prism_node) : null,
|
|
23300
|
+
locals: this.locals.map(node => node.toJSON()),
|
|
23301
|
+
};
|
|
23302
|
+
}
|
|
23303
|
+
treeInspect() {
|
|
23304
|
+
let output = "";
|
|
23305
|
+
output += `@ ERBStrictLocalsNode ${this.location.treeInspectWithLabel()}\n`;
|
|
23306
|
+
output += `├── errors: ${this.inspectArray(this.errors, "│ ")}`;
|
|
23307
|
+
output += `├── tag_opening: ${this.tag_opening ? this.tag_opening.treeInspect() : "∅"}\n`;
|
|
23308
|
+
output += `├── content: ${this.content ? this.content.treeInspect() : "∅"}\n`;
|
|
23309
|
+
output += `├── tag_closing: ${this.tag_closing ? this.tag_closing.treeInspect() : "∅"}\n`;
|
|
23310
|
+
if (this.prism_node) {
|
|
23311
|
+
output += `├── prism_node: ${this.source ? inspectPrismSerialized(this.prism_node, this.source, "│ ") : `(${this.prism_node.length} bytes)`}\n`;
|
|
23312
|
+
}
|
|
23313
|
+
output += `└── locals: ${this.inspectArray(this.locals, " ")}`;
|
|
23314
|
+
return output;
|
|
23315
|
+
}
|
|
23316
|
+
}
|
|
22864
23317
|
class ERBYieldNode extends Node {
|
|
22865
23318
|
tag_opening;
|
|
22866
23319
|
content;
|
|
@@ -23026,6 +23479,8 @@ function fromSerializedNode(node) {
|
|
|
23026
23479
|
case "AST_ERB_UNLESS_NODE": return ERBUnlessNode.from(node);
|
|
23027
23480
|
case "AST_RUBY_RENDER_LOCAL_NODE": return RubyRenderLocalNode.from(node);
|
|
23028
23481
|
case "AST_ERB_RENDER_NODE": return ERBRenderNode.from(node);
|
|
23482
|
+
case "AST_RUBY_STRICT_LOCAL_NODE": return RubyStrictLocalNode.from(node);
|
|
23483
|
+
case "AST_ERB_STRICT_LOCALS_NODE": return ERBStrictLocalsNode.from(node);
|
|
23029
23484
|
case "AST_ERB_YIELD_NODE": return ERBYieldNode.from(node);
|
|
23030
23485
|
case "AST_ERB_IN_NODE": return ERBInNode.from(node);
|
|
23031
23486
|
default:
|
|
@@ -23076,9 +23531,12 @@ const DEFAULT_PARSER_OPTIONS = {
|
|
|
23076
23531
|
strict: true,
|
|
23077
23532
|
action_view_helpers: false,
|
|
23078
23533
|
render_nodes: false,
|
|
23534
|
+
strict_locals: false,
|
|
23079
23535
|
prism_nodes: false,
|
|
23080
23536
|
prism_nodes_deep: false,
|
|
23081
23537
|
prism_program: false,
|
|
23538
|
+
dot_notation_tags: false,
|
|
23539
|
+
html: true,
|
|
23082
23540
|
};
|
|
23083
23541
|
/**
|
|
23084
23542
|
* Represents the parser options used during parsing.
|
|
@@ -23094,12 +23552,18 @@ class ParserOptions {
|
|
|
23094
23552
|
action_view_helpers;
|
|
23095
23553
|
/** Whether ActionView render call detection was enabled during parsing. */
|
|
23096
23554
|
render_nodes;
|
|
23555
|
+
/** Whether strict locals analysis was enabled during parsing. */
|
|
23556
|
+
strict_locals;
|
|
23097
23557
|
/** Whether Prism node serialization was enabled during parsing. */
|
|
23098
23558
|
prism_nodes;
|
|
23099
23559
|
/** Whether deep Prism node serialization was enabled during parsing. */
|
|
23100
23560
|
prism_nodes_deep;
|
|
23101
23561
|
/** Whether the full Prism ProgramNode was serialized on the DocumentNode. */
|
|
23102
23562
|
prism_program;
|
|
23563
|
+
/** Whether dot-notation component tags (e.g. Dialog.Button) are parsed as HTML elements. */
|
|
23564
|
+
dot_notation_tags;
|
|
23565
|
+
/** Whether HTML tag parsing is enabled during parsing. When false, HTML-like content is treated as literal text. */
|
|
23566
|
+
html;
|
|
23103
23567
|
static from(options) {
|
|
23104
23568
|
return new ParserOptions(options);
|
|
23105
23569
|
}
|
|
@@ -23109,9 +23573,12 @@ class ParserOptions {
|
|
|
23109
23573
|
this.analyze = options.analyze ?? DEFAULT_PARSER_OPTIONS.analyze;
|
|
23110
23574
|
this.action_view_helpers = options.action_view_helpers ?? DEFAULT_PARSER_OPTIONS.action_view_helpers;
|
|
23111
23575
|
this.render_nodes = options.render_nodes ?? DEFAULT_PARSER_OPTIONS.render_nodes;
|
|
23576
|
+
this.strict_locals = options.strict_locals ?? DEFAULT_PARSER_OPTIONS.strict_locals;
|
|
23112
23577
|
this.prism_nodes = options.prism_nodes ?? DEFAULT_PARSER_OPTIONS.prism_nodes;
|
|
23113
23578
|
this.prism_nodes_deep = options.prism_nodes_deep ?? DEFAULT_PARSER_OPTIONS.prism_nodes_deep;
|
|
23114
23579
|
this.prism_program = options.prism_program ?? DEFAULT_PARSER_OPTIONS.prism_program;
|
|
23580
|
+
this.dot_notation_tags = options.dot_notation_tags ?? DEFAULT_PARSER_OPTIONS.dot_notation_tags;
|
|
23581
|
+
this.html = options.html ?? DEFAULT_PARSER_OPTIONS.html;
|
|
23115
23582
|
}
|
|
23116
23583
|
}
|
|
23117
23584
|
|
|
@@ -23188,7 +23655,7 @@ class ParseResult extends Result {
|
|
|
23188
23655
|
}
|
|
23189
23656
|
|
|
23190
23657
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
23191
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
23658
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
23192
23659
|
/**
|
|
23193
23660
|
* Type guard functions for AST nodes.
|
|
23194
23661
|
* These functions provide type checking by combining both instanceof
|
|
@@ -23499,6 +23966,22 @@ function isERBRenderNode(node) {
|
|
|
23499
23966
|
return false;
|
|
23500
23967
|
return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || node.constructor.type === "AST_ERB_RENDER_NODE";
|
|
23501
23968
|
}
|
|
23969
|
+
/**
|
|
23970
|
+
* Checks if a node is a RubyStrictLocalNode
|
|
23971
|
+
*/
|
|
23972
|
+
function isRubyStrictLocalNode(node) {
|
|
23973
|
+
if (!node)
|
|
23974
|
+
return false;
|
|
23975
|
+
return node instanceof RubyStrictLocalNode || node.type === "AST_RUBY_STRICT_LOCAL_NODE" || node.constructor.type === "AST_RUBY_STRICT_LOCAL_NODE";
|
|
23976
|
+
}
|
|
23977
|
+
/**
|
|
23978
|
+
* Checks if a node is a ERBStrictLocalsNode
|
|
23979
|
+
*/
|
|
23980
|
+
function isERBStrictLocalsNode(node) {
|
|
23981
|
+
if (!node)
|
|
23982
|
+
return false;
|
|
23983
|
+
return node instanceof ERBStrictLocalsNode || node.type === "AST_ERB_STRICT_LOCALS_NODE" || node.constructor.type === "AST_ERB_STRICT_LOCALS_NODE";
|
|
23984
|
+
}
|
|
23502
23985
|
/**
|
|
23503
23986
|
* Checks if a node is a ERBYieldNode
|
|
23504
23987
|
*/
|
|
@@ -23564,6 +24047,8 @@ const NODE_TYPE_GUARDS = new Map([
|
|
|
23564
24047
|
[ERBUnlessNode, isERBUnlessNode],
|
|
23565
24048
|
[RubyRenderLocalNode, isRubyRenderLocalNode],
|
|
23566
24049
|
[ERBRenderNode, isERBRenderNode],
|
|
24050
|
+
[RubyStrictLocalNode, isRubyStrictLocalNode],
|
|
24051
|
+
[ERBStrictLocalsNode, isERBStrictLocalsNode],
|
|
23567
24052
|
[ERBYieldNode, isERBYieldNode],
|
|
23568
24053
|
[ERBInNode, isERBInNode],
|
|
23569
24054
|
]);
|
|
@@ -23616,6 +24101,8 @@ const AST_TYPE_GUARDS = new Map([
|
|
|
23616
24101
|
["AST_ERB_UNLESS_NODE", isERBUnlessNode],
|
|
23617
24102
|
["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
|
|
23618
24103
|
["AST_ERB_RENDER_NODE", isERBRenderNode],
|
|
24104
|
+
["AST_RUBY_STRICT_LOCAL_NODE", isRubyStrictLocalNode],
|
|
24105
|
+
["AST_ERB_STRICT_LOCALS_NODE", isERBStrictLocalsNode],
|
|
23619
24106
|
["AST_ERB_YIELD_NODE", isERBYieldNode],
|
|
23620
24107
|
["AST_ERB_IN_NODE", isERBInNode],
|
|
23621
24108
|
]);
|
|
@@ -23842,7 +24329,7 @@ function createSyntheticToken(value, type = "TOKEN_SYNTHETIC") {
|
|
|
23842
24329
|
}
|
|
23843
24330
|
|
|
23844
24331
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
23845
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
24332
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.3/templates/javascript/packages/core/src/visitor.ts.erb
|
|
23846
24333
|
class Visitor {
|
|
23847
24334
|
visit(node) {
|
|
23848
24335
|
if (!node)
|
|
@@ -24030,6 +24517,15 @@ class Visitor {
|
|
|
24030
24517
|
this.visitERBNode(node);
|
|
24031
24518
|
this.visitChildNodes(node);
|
|
24032
24519
|
}
|
|
24520
|
+
visitRubyStrictLocalNode(node) {
|
|
24521
|
+
this.visitNode(node);
|
|
24522
|
+
this.visitChildNodes(node);
|
|
24523
|
+
}
|
|
24524
|
+
visitERBStrictLocalsNode(node) {
|
|
24525
|
+
this.visitNode(node);
|
|
24526
|
+
this.visitERBNode(node);
|
|
24527
|
+
this.visitChildNodes(node);
|
|
24528
|
+
}
|
|
24033
24529
|
visitERBYieldNode(node) {
|
|
24034
24530
|
this.visitNode(node);
|
|
24035
24531
|
this.visitERBNode(node);
|
|
@@ -24062,6 +24558,34 @@ function createWhitespaceNode() {
|
|
|
24062
24558
|
});
|
|
24063
24559
|
}
|
|
24064
24560
|
class ActionViewTagHelperToHTMLVisitor extends Visitor {
|
|
24561
|
+
shallow;
|
|
24562
|
+
includeBody;
|
|
24563
|
+
constructor(options = {}) {
|
|
24564
|
+
super();
|
|
24565
|
+
this.shallow = options.shallow ?? false;
|
|
24566
|
+
this.includeBody = options.includeBody ?? true;
|
|
24567
|
+
}
|
|
24568
|
+
visitHTMLOpenTagNode(node) {
|
|
24569
|
+
const newChildren = [];
|
|
24570
|
+
for (let index = 0; index < node.children.length; index++) {
|
|
24571
|
+
const child = node.children[index];
|
|
24572
|
+
if (isHTMLAttributeNode(child)) {
|
|
24573
|
+
if (child.equals && child.equals.value !== "=") {
|
|
24574
|
+
asMutable(child).equals = createSyntheticToken("=");
|
|
24575
|
+
}
|
|
24576
|
+
if (child.value) {
|
|
24577
|
+
this.transformAttributeValue(child.value);
|
|
24578
|
+
}
|
|
24579
|
+
const previous = index > 0 ? node.children[index - 1] : null;
|
|
24580
|
+
if (!previous || !isWhitespaceNode(previous)) {
|
|
24581
|
+
newChildren.push(createWhitespaceNode());
|
|
24582
|
+
}
|
|
24583
|
+
}
|
|
24584
|
+
newChildren.push(child);
|
|
24585
|
+
}
|
|
24586
|
+
asMutable(node).children = newChildren;
|
|
24587
|
+
this.visitChildNodes(node);
|
|
24588
|
+
}
|
|
24065
24589
|
visitHTMLElementNode(node) {
|
|
24066
24590
|
if (!node.element_source) {
|
|
24067
24591
|
this.visitChildNodes(node);
|
|
@@ -24132,7 +24656,10 @@ class ActionViewTagHelperToHTMLVisitor extends Visitor {
|
|
|
24132
24656
|
asMutable(node).close_tag = htmlCloseTag;
|
|
24133
24657
|
}
|
|
24134
24658
|
asMutable(node).element_source = "HTML";
|
|
24135
|
-
if (
|
|
24659
|
+
if (!this.includeBody) {
|
|
24660
|
+
asMutable(node).body = [];
|
|
24661
|
+
}
|
|
24662
|
+
else if (node.body) {
|
|
24136
24663
|
asMutable(node).body = node.body.map(child => {
|
|
24137
24664
|
if (isRubyLiteralNode(child)) {
|
|
24138
24665
|
return new ERBContentNode({
|
|
@@ -24147,7 +24674,9 @@ class ActionViewTagHelperToHTMLVisitor extends Visitor {
|
|
|
24147
24674
|
prism_node: null
|
|
24148
24675
|
});
|
|
24149
24676
|
}
|
|
24150
|
-
this.
|
|
24677
|
+
if (!this.shallow) {
|
|
24678
|
+
this.visit(child);
|
|
24679
|
+
}
|
|
24151
24680
|
return child;
|
|
24152
24681
|
});
|
|
24153
24682
|
}
|
|
@@ -24173,11 +24702,11 @@ class ActionViewTagHelperToHTMLVisitor extends Visitor {
|
|
|
24173
24702
|
return child;
|
|
24174
24703
|
});
|
|
24175
24704
|
mutableValue.children = newChildren;
|
|
24176
|
-
|
|
24177
|
-
|
|
24178
|
-
|
|
24179
|
-
|
|
24180
|
-
|
|
24705
|
+
}
|
|
24706
|
+
if (!value.quoted) {
|
|
24707
|
+
mutableValue.quoted = true;
|
|
24708
|
+
mutableValue.open_quote = createSyntheticToken('"');
|
|
24709
|
+
mutableValue.close_quote = createSyntheticToken('"');
|
|
24181
24710
|
}
|
|
24182
24711
|
}
|
|
24183
24712
|
}
|
|
@@ -24188,8 +24717,8 @@ class ActionViewTagHelperToHTMLRewriter extends ASTRewriter {
|
|
|
24188
24717
|
get description() {
|
|
24189
24718
|
return "Converts ActionView tag helpers to raw HTML elements";
|
|
24190
24719
|
}
|
|
24191
|
-
rewrite(node,
|
|
24192
|
-
const visitor = new ActionViewTagHelperToHTMLVisitor();
|
|
24720
|
+
rewrite(node, context) {
|
|
24721
|
+
const visitor = new ActionViewTagHelperToHTMLVisitor({ shallow: context.shallow, includeBody: context.includeBody });
|
|
24193
24722
|
visitor.visit(node);
|
|
24194
24723
|
return node;
|
|
24195
24724
|
}
|
|
@@ -24282,9 +24811,10 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
|
|
|
24282
24811
|
const isAnchor = tagName.value === "a";
|
|
24283
24812
|
const isTurboFrame = tagName.value === "turbo-frame";
|
|
24284
24813
|
const isScript = tagName.value === "script";
|
|
24814
|
+
const isImg = tagName.value === "img";
|
|
24285
24815
|
const attributes = openTag.children.filter(child => !isWhitespaceNode(child));
|
|
24286
|
-
const hasSrcAttribute = isScript && attributes.some(child => isHTMLAttributeNode(child) && getStaticAttributeName(child.name) === "src");
|
|
24287
|
-
const { attributes: attributesString, href, id, src } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame, extractSrc: isScript });
|
|
24816
|
+
const hasSrcAttribute = (isScript || isImg) && attributes.some(child => isHTMLAttributeNode(child) && getStaticAttributeName(child.name) === "src");
|
|
24817
|
+
const { attributes: attributesString, href, id, src } = serializeAttributes(attributes, { extractHref: isAnchor, extractId: isTurboFrame, extractSrc: isScript || isImg });
|
|
24288
24818
|
const hasBody = node.body && node.body.length > 0 && !node.is_void;
|
|
24289
24819
|
const isInlineContent = hasBody && isTextOnlyBody(node.body);
|
|
24290
24820
|
let content;
|
|
@@ -24305,6 +24835,10 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
|
|
|
24305
24835
|
content = this.buildJavascriptTagContent(node, attributesString, isInlineContent);
|
|
24306
24836
|
elementSource = "ActionView::Helpers::JavaScriptHelper#javascript_tag";
|
|
24307
24837
|
}
|
|
24838
|
+
else if (isImg) {
|
|
24839
|
+
content = this.buildImageTagContent(attributesString, src);
|
|
24840
|
+
elementSource = "ActionView::Helpers::AssetTagHelper#image_tag";
|
|
24841
|
+
}
|
|
24308
24842
|
else {
|
|
24309
24843
|
content = this.buildTagContent(tagName.value, node, attributesString, isInlineContent);
|
|
24310
24844
|
elementSource = "ActionView::Helpers::TagHelper#tag";
|
|
@@ -24322,7 +24856,7 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
|
|
|
24322
24856
|
asMutable(node).open_tag = erbOpenTag;
|
|
24323
24857
|
asMutable(node).element_source = elementSource;
|
|
24324
24858
|
const isInlineLiteralContent = isScript && hasBody && node.body.length === 1 && isLiteralNode(node.body[0]) && !node.body[0].content.includes("\n");
|
|
24325
|
-
const isInlineForm = isInlineContent || isInlineLiteralContent || (isTurboFrame && !hasBody) || (isScript && hasSrcAttribute);
|
|
24859
|
+
const isInlineForm = isInlineContent || isInlineLiteralContent || (isTurboFrame && !hasBody) || (isScript && hasSrcAttribute) || isImg;
|
|
24326
24860
|
if (node.is_void) {
|
|
24327
24861
|
asMutable(node).close_tag = null;
|
|
24328
24862
|
}
|
|
@@ -24406,6 +24940,15 @@ class HTMLToActionViewTagHelperVisitor extends Visitor {
|
|
|
24406
24940
|
const argString = args.join(", ");
|
|
24407
24941
|
return argString ? ` javascript_include_tag ${argString} ` : ` javascript_include_tag `;
|
|
24408
24942
|
}
|
|
24943
|
+
buildImageTagContent(attributes, source) {
|
|
24944
|
+
const args = [];
|
|
24945
|
+
if (source)
|
|
24946
|
+
args.push(source);
|
|
24947
|
+
if (attributes)
|
|
24948
|
+
args.push(attributes);
|
|
24949
|
+
const argString = args.join(", ");
|
|
24950
|
+
return argString ? ` image_tag ${argString} ` : ` image_tag `;
|
|
24951
|
+
}
|
|
24409
24952
|
buildLinkToContent(node, attribute, href, isInlineContent) {
|
|
24410
24953
|
const args = [];
|
|
24411
24954
|
if (isInlineContent && isHTMLTextNode(node.body[0])) {
|
|
@@ -24429,7 +24972,7 @@ class HTMLToActionViewTagHelperRewriter extends ASTRewriter {
|
|
|
24429
24972
|
return "html-to-action-view-tag-helper";
|
|
24430
24973
|
}
|
|
24431
24974
|
get description() {
|
|
24432
|
-
return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag, javascript_tag, javascript_include_tag)";
|
|
24975
|
+
return "Converts raw HTML elements to ActionView tag helpers (tag.*, turbo_frame_tag, javascript_tag, javascript_include_tag, image_tag)";
|
|
24433
24976
|
}
|
|
24434
24977
|
rewrite(node, _context) {
|
|
24435
24978
|
const visitor = new HTMLToActionViewTagHelperVisitor();
|
|
@@ -24856,6 +25399,15 @@ class IdentityPrinter extends Printer {
|
|
|
24856
25399
|
if (node.body) {
|
|
24857
25400
|
node.body.forEach(child => this.visit(child));
|
|
24858
25401
|
}
|
|
25402
|
+
if (node.rescue_clause) {
|
|
25403
|
+
this.visit(node.rescue_clause);
|
|
25404
|
+
}
|
|
25405
|
+
if (node.else_clause) {
|
|
25406
|
+
this.visit(node.else_clause);
|
|
25407
|
+
}
|
|
25408
|
+
if (node.ensure_clause) {
|
|
25409
|
+
this.visit(node.ensure_clause);
|
|
25410
|
+
}
|
|
24859
25411
|
if (node.end_node) {
|
|
24860
25412
|
this.visit(node.end_node);
|
|
24861
25413
|
}
|
|
@@ -24959,6 +25511,12 @@ class IdentityPrinter extends Printer {
|
|
|
24959
25511
|
visitRubyRenderLocalNode(_node) {
|
|
24960
25512
|
// extracted metadata, nothing to print
|
|
24961
25513
|
}
|
|
25514
|
+
visitERBStrictLocalsNode(node) {
|
|
25515
|
+
this.printERBNode(node);
|
|
25516
|
+
}
|
|
25517
|
+
visitRubyStrictLocalNode(_node) {
|
|
25518
|
+
// extracted metadata, nothing to print
|
|
25519
|
+
}
|
|
24962
25520
|
visitERBYieldNode(node) {
|
|
24963
25521
|
this.printERBNode(node);
|
|
24964
25522
|
}
|