@herb-tools/core 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-core.browser.js +557 -10
- package/dist/herb-core.browser.js.map +1 -1
- package/dist/herb-core.cjs +570 -10
- package/dist/herb-core.cjs.map +1 -1
- package/dist/herb-core.esm.js +557 -10
- package/dist/herb-core.esm.js.map +1 -1
- package/dist/herb-core.umd.js +570 -10
- package/dist/herb-core.umd.js.map +1 -1
- package/dist/types/ast-utils.d.ts +2 -3
- package/dist/types/diagnostic.d.ts +6 -0
- package/dist/types/errors.d.ts +141 -1
- package/dist/types/node-type-guards.d.ts +19 -1
- package/dist/types/nodes.d.ts +115 -4
- package/dist/types/parser-options.d.ts +3 -0
- package/dist/types/visitor.d.ts +5 -1
- package/package.json +1 -1
- package/src/ast-utils.ts +3 -4
- package/src/diagnostic.ts +7 -0
- package/src/errors.ts +465 -17
- package/src/node-type-guards.ts +42 -1
- package/src/nodes.ts +322 -2
- package/src/parser-options.ts +6 -0
- package/src/visitor.ts +16 -1
package/src/errors.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/errors.ts.erb
|
|
3
3
|
|
|
4
4
|
import { Location, SerializedLocation } from "./location.js"
|
|
5
5
|
import { Position, SerializedPosition } from "./position.js"
|
|
@@ -30,6 +30,13 @@ export type HerbErrorType =
|
|
|
30
30
|
| "UNCLOSED_ERB_TAG_ERROR"
|
|
31
31
|
| "STRAY_ERB_CLOSING_TAG_ERROR"
|
|
32
32
|
| "NESTED_ERB_TAG_ERROR"
|
|
33
|
+
| "RENDER_AMBIGUOUS_LOCALS_ERROR"
|
|
34
|
+
| "RENDER_MISSING_LOCALS_ERROR"
|
|
35
|
+
| "RENDER_NO_ARGUMENTS_ERROR"
|
|
36
|
+
| "RENDER_CONFLICTING_PARTIAL_ERROR"
|
|
37
|
+
| "RENDER_INVALID_AS_OPTION_ERROR"
|
|
38
|
+
| "RENDER_OBJECT_AND_COLLECTION_ERROR"
|
|
39
|
+
| "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR"
|
|
33
40
|
|
|
34
41
|
export type SerializedErrorType = string
|
|
35
42
|
|
|
@@ -865,16 +872,16 @@ export interface SerializedConditionalElementMultipleTagsError {
|
|
|
865
872
|
type: "CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR";
|
|
866
873
|
message: string;
|
|
867
874
|
location: SerializedLocation;
|
|
868
|
-
line: any; // #<Herb::Template::SizeTField:
|
|
869
|
-
column: any; // #<Herb::Template::SizeTField:
|
|
875
|
+
line: any; // #<Herb::Template::SizeTField:0x000000011e9df368 @name="line", @options={kind: nil}>
|
|
876
|
+
column: any; // #<Herb::Template::SizeTField:0x000000011e9df160 @name="column", @options={kind: nil}>
|
|
870
877
|
}
|
|
871
878
|
|
|
872
879
|
export interface ConditionalElementMultipleTagsErrorProps {
|
|
873
880
|
type: string;
|
|
874
881
|
message: string;
|
|
875
882
|
location: Location;
|
|
876
|
-
line: any; // #<Herb::Template::SizeTField:
|
|
877
|
-
column: any; // #<Herb::Template::SizeTField:
|
|
883
|
+
line: any; // #<Herb::Template::SizeTField:0x000000011e9df368 @name="line", @options={kind: nil}>
|
|
884
|
+
column: any; // #<Herb::Template::SizeTField:0x000000011e9df160 @name="column", @options={kind: nil}>
|
|
878
885
|
}
|
|
879
886
|
|
|
880
887
|
export class ConditionalElementMultipleTagsError extends HerbError {
|
|
@@ -936,11 +943,11 @@ export interface SerializedConditionalElementConditionMismatchError {
|
|
|
936
943
|
location: SerializedLocation;
|
|
937
944
|
tag_name: string;
|
|
938
945
|
open_condition: string;
|
|
939
|
-
open_line: any; // #<Herb::Template::SizeTField:
|
|
940
|
-
open_column: any; // #<Herb::Template::SizeTField:
|
|
946
|
+
open_line: any; // #<Herb::Template::SizeTField:0x000000011e9deb70 @name="open_line", @options={kind: nil}>
|
|
947
|
+
open_column: any; // #<Herb::Template::SizeTField:0x000000011e9deb48 @name="open_column", @options={kind: nil}>
|
|
941
948
|
close_condition: string;
|
|
942
|
-
close_line: any; // #<Herb::Template::SizeTField:
|
|
943
|
-
close_column: any; // #<Herb::Template::SizeTField:
|
|
949
|
+
close_line: any; // #<Herb::Template::SizeTField:0x000000011e9deaf8 @name="close_line", @options={kind: nil}>
|
|
950
|
+
close_column: any; // #<Herb::Template::SizeTField:0x000000011e9de990 @name="close_column", @options={kind: nil}>
|
|
944
951
|
}
|
|
945
952
|
|
|
946
953
|
export interface ConditionalElementConditionMismatchErrorProps {
|
|
@@ -949,11 +956,11 @@ export interface ConditionalElementConditionMismatchErrorProps {
|
|
|
949
956
|
location: Location;
|
|
950
957
|
tag_name: string;
|
|
951
958
|
open_condition: string;
|
|
952
|
-
open_line: any; // #<Herb::Template::SizeTField:
|
|
953
|
-
open_column: any; // #<Herb::Template::SizeTField:
|
|
959
|
+
open_line: any; // #<Herb::Template::SizeTField:0x000000011e9deb70 @name="open_line", @options={kind: nil}>
|
|
960
|
+
open_column: any; // #<Herb::Template::SizeTField:0x000000011e9deb48 @name="open_column", @options={kind: nil}>
|
|
954
961
|
close_condition: string;
|
|
955
|
-
close_line: any; // #<Herb::Template::SizeTField:
|
|
956
|
-
close_column: any; // #<Herb::Template::SizeTField:
|
|
962
|
+
close_line: any; // #<Herb::Template::SizeTField:0x000000011e9deaf8 @name="close_line", @options={kind: nil}>
|
|
963
|
+
close_column: any; // #<Herb::Template::SizeTField:0x000000011e9de990 @name="close_column", @options={kind: nil}>
|
|
957
964
|
}
|
|
958
965
|
|
|
959
966
|
export class ConditionalElementConditionMismatchError extends HerbError {
|
|
@@ -1535,8 +1542,8 @@ export interface SerializedNestedERBTagError {
|
|
|
1535
1542
|
message: string;
|
|
1536
1543
|
location: SerializedLocation;
|
|
1537
1544
|
opening_tag: SerializedToken | null;
|
|
1538
|
-
nested_tag_line: any; // #<Herb::Template::SizeTField:
|
|
1539
|
-
nested_tag_column: any; // #<Herb::Template::SizeTField:
|
|
1545
|
+
nested_tag_line: any; // #<Herb::Template::SizeTField:0x000000011e9dac00 @name="nested_tag_line", @options={kind: nil}>
|
|
1546
|
+
nested_tag_column: any; // #<Herb::Template::SizeTField:0x000000011e9dab60 @name="nested_tag_column", @options={kind: nil}>
|
|
1540
1547
|
}
|
|
1541
1548
|
|
|
1542
1549
|
export interface NestedERBTagErrorProps {
|
|
@@ -1544,8 +1551,8 @@ export interface NestedERBTagErrorProps {
|
|
|
1544
1551
|
message: string;
|
|
1545
1552
|
location: Location;
|
|
1546
1553
|
opening_tag: Token | null;
|
|
1547
|
-
nested_tag_line: any; // #<Herb::Template::SizeTField:
|
|
1548
|
-
nested_tag_column: any; // #<Herb::Template::SizeTField:
|
|
1554
|
+
nested_tag_line: any; // #<Herb::Template::SizeTField:0x000000011e9dac00 @name="nested_tag_line", @options={kind: nil}>
|
|
1555
|
+
nested_tag_column: any; // #<Herb::Template::SizeTField:0x000000011e9dab60 @name="nested_tag_column", @options={kind: nil}>
|
|
1549
1556
|
}
|
|
1550
1557
|
|
|
1551
1558
|
export class NestedERBTagError extends HerbError {
|
|
@@ -1606,6 +1613,440 @@ export class NestedERBTagError extends HerbError {
|
|
|
1606
1613
|
}
|
|
1607
1614
|
}
|
|
1608
1615
|
|
|
1616
|
+
export interface SerializedRenderAmbiguousLocalsError {
|
|
1617
|
+
type: "RENDER_AMBIGUOUS_LOCALS_ERROR";
|
|
1618
|
+
message: string;
|
|
1619
|
+
location: SerializedLocation;
|
|
1620
|
+
partial: string;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
export interface RenderAmbiguousLocalsErrorProps {
|
|
1624
|
+
type: string;
|
|
1625
|
+
message: string;
|
|
1626
|
+
location: Location;
|
|
1627
|
+
partial: string;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
export class RenderAmbiguousLocalsError extends HerbError {
|
|
1631
|
+
readonly partial: string;
|
|
1632
|
+
|
|
1633
|
+
static from(data: SerializedRenderAmbiguousLocalsError): RenderAmbiguousLocalsError {
|
|
1634
|
+
return new RenderAmbiguousLocalsError({
|
|
1635
|
+
type: data.type,
|
|
1636
|
+
message: data.message,
|
|
1637
|
+
location: Location.from(data.location),
|
|
1638
|
+
partial: data.partial,
|
|
1639
|
+
})
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
constructor(props: RenderAmbiguousLocalsErrorProps) {
|
|
1643
|
+
super(props.type, props.message, props.location);
|
|
1644
|
+
|
|
1645
|
+
this.partial = props.partial;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
toJSON(): SerializedRenderAmbiguousLocalsError {
|
|
1649
|
+
return {
|
|
1650
|
+
...super.toJSON(),
|
|
1651
|
+
type: "RENDER_AMBIGUOUS_LOCALS_ERROR",
|
|
1652
|
+
partial: this.partial,
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
1657
|
+
return {
|
|
1658
|
+
line: this.location.start.line,
|
|
1659
|
+
column: this.location.start.column,
|
|
1660
|
+
endLine: this.location.end.line,
|
|
1661
|
+
endColumn: this.location.end.column,
|
|
1662
|
+
message: this.message,
|
|
1663
|
+
severity: 'error'
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
treeInspect(): string {
|
|
1668
|
+
let output = "";
|
|
1669
|
+
|
|
1670
|
+
output += `@ RenderAmbiguousLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1671
|
+
output += `├── message: "${this.message}"\n`;
|
|
1672
|
+
output += `└── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1673
|
+
|
|
1674
|
+
return output;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
export interface SerializedRenderMissingLocalsError {
|
|
1679
|
+
type: "RENDER_MISSING_LOCALS_ERROR";
|
|
1680
|
+
message: string;
|
|
1681
|
+
location: SerializedLocation;
|
|
1682
|
+
partial: string;
|
|
1683
|
+
keywords: string;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
export interface RenderMissingLocalsErrorProps {
|
|
1687
|
+
type: string;
|
|
1688
|
+
message: string;
|
|
1689
|
+
location: Location;
|
|
1690
|
+
partial: string;
|
|
1691
|
+
keywords: string;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
export class RenderMissingLocalsError extends HerbError {
|
|
1695
|
+
readonly partial: string;
|
|
1696
|
+
readonly keywords: string;
|
|
1697
|
+
|
|
1698
|
+
static from(data: SerializedRenderMissingLocalsError): RenderMissingLocalsError {
|
|
1699
|
+
return new RenderMissingLocalsError({
|
|
1700
|
+
type: data.type,
|
|
1701
|
+
message: data.message,
|
|
1702
|
+
location: Location.from(data.location),
|
|
1703
|
+
partial: data.partial,
|
|
1704
|
+
keywords: data.keywords,
|
|
1705
|
+
})
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
constructor(props: RenderMissingLocalsErrorProps) {
|
|
1709
|
+
super(props.type, props.message, props.location);
|
|
1710
|
+
|
|
1711
|
+
this.partial = props.partial;
|
|
1712
|
+
this.keywords = props.keywords;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
toJSON(): SerializedRenderMissingLocalsError {
|
|
1716
|
+
return {
|
|
1717
|
+
...super.toJSON(),
|
|
1718
|
+
type: "RENDER_MISSING_LOCALS_ERROR",
|
|
1719
|
+
partial: this.partial,
|
|
1720
|
+
keywords: this.keywords,
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
1725
|
+
return {
|
|
1726
|
+
line: this.location.start.line,
|
|
1727
|
+
column: this.location.start.column,
|
|
1728
|
+
endLine: this.location.end.line,
|
|
1729
|
+
endColumn: this.location.end.column,
|
|
1730
|
+
message: this.message,
|
|
1731
|
+
severity: 'error'
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
treeInspect(): string {
|
|
1736
|
+
let output = "";
|
|
1737
|
+
|
|
1738
|
+
output += `@ RenderMissingLocalsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1739
|
+
output += `├── message: "${this.message}"\n`;
|
|
1740
|
+
output += `├── partial: ${JSON.stringify(this.partial)}\n`;
|
|
1741
|
+
output += `└── keywords: ${JSON.stringify(this.keywords)}\n`;
|
|
1742
|
+
|
|
1743
|
+
return output;
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
export interface SerializedRenderNoArgumentsError {
|
|
1748
|
+
type: "RENDER_NO_ARGUMENTS_ERROR";
|
|
1749
|
+
message: string;
|
|
1750
|
+
location: SerializedLocation;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
export interface RenderNoArgumentsErrorProps {
|
|
1754
|
+
type: string;
|
|
1755
|
+
message: string;
|
|
1756
|
+
location: Location;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
export class RenderNoArgumentsError extends HerbError {
|
|
1760
|
+
|
|
1761
|
+
static from(data: SerializedRenderNoArgumentsError): RenderNoArgumentsError {
|
|
1762
|
+
return new RenderNoArgumentsError({
|
|
1763
|
+
type: data.type,
|
|
1764
|
+
message: data.message,
|
|
1765
|
+
location: Location.from(data.location),
|
|
1766
|
+
})
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
constructor(props: RenderNoArgumentsErrorProps) {
|
|
1770
|
+
super(props.type, props.message, props.location);
|
|
1771
|
+
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
toJSON(): SerializedRenderNoArgumentsError {
|
|
1775
|
+
return {
|
|
1776
|
+
...super.toJSON(),
|
|
1777
|
+
type: "RENDER_NO_ARGUMENTS_ERROR",
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
1782
|
+
return {
|
|
1783
|
+
line: this.location.start.line,
|
|
1784
|
+
column: this.location.start.column,
|
|
1785
|
+
endLine: this.location.end.line,
|
|
1786
|
+
endColumn: this.location.end.column,
|
|
1787
|
+
message: this.message,
|
|
1788
|
+
severity: 'error'
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
treeInspect(): string {
|
|
1793
|
+
let output = "";
|
|
1794
|
+
|
|
1795
|
+
output += `@ RenderNoArgumentsError ${this.location.treeInspectWithLabel()}\n`;
|
|
1796
|
+
output += `└── message: "${this.message}"\n`;
|
|
1797
|
+
|
|
1798
|
+
return output;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
export interface SerializedRenderConflictingPartialError {
|
|
1803
|
+
type: "RENDER_CONFLICTING_PARTIAL_ERROR";
|
|
1804
|
+
message: string;
|
|
1805
|
+
location: SerializedLocation;
|
|
1806
|
+
positional_partial: string;
|
|
1807
|
+
keyword_partial: string;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
export interface RenderConflictingPartialErrorProps {
|
|
1811
|
+
type: string;
|
|
1812
|
+
message: string;
|
|
1813
|
+
location: Location;
|
|
1814
|
+
positional_partial: string;
|
|
1815
|
+
keyword_partial: string;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
export class RenderConflictingPartialError extends HerbError {
|
|
1819
|
+
readonly positional_partial: string;
|
|
1820
|
+
readonly keyword_partial: string;
|
|
1821
|
+
|
|
1822
|
+
static from(data: SerializedRenderConflictingPartialError): RenderConflictingPartialError {
|
|
1823
|
+
return new RenderConflictingPartialError({
|
|
1824
|
+
type: data.type,
|
|
1825
|
+
message: data.message,
|
|
1826
|
+
location: Location.from(data.location),
|
|
1827
|
+
positional_partial: data.positional_partial,
|
|
1828
|
+
keyword_partial: data.keyword_partial,
|
|
1829
|
+
})
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
constructor(props: RenderConflictingPartialErrorProps) {
|
|
1833
|
+
super(props.type, props.message, props.location);
|
|
1834
|
+
|
|
1835
|
+
this.positional_partial = props.positional_partial;
|
|
1836
|
+
this.keyword_partial = props.keyword_partial;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
toJSON(): SerializedRenderConflictingPartialError {
|
|
1840
|
+
return {
|
|
1841
|
+
...super.toJSON(),
|
|
1842
|
+
type: "RENDER_CONFLICTING_PARTIAL_ERROR",
|
|
1843
|
+
positional_partial: this.positional_partial,
|
|
1844
|
+
keyword_partial: this.keyword_partial,
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
1849
|
+
return {
|
|
1850
|
+
line: this.location.start.line,
|
|
1851
|
+
column: this.location.start.column,
|
|
1852
|
+
endLine: this.location.end.line,
|
|
1853
|
+
endColumn: this.location.end.column,
|
|
1854
|
+
message: this.message,
|
|
1855
|
+
severity: 'error'
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
treeInspect(): string {
|
|
1860
|
+
let output = "";
|
|
1861
|
+
|
|
1862
|
+
output += `@ RenderConflictingPartialError ${this.location.treeInspectWithLabel()}\n`;
|
|
1863
|
+
output += `├── message: "${this.message}"\n`;
|
|
1864
|
+
output += `├── positional_partial: ${JSON.stringify(this.positional_partial)}\n`;
|
|
1865
|
+
output += `└── keyword_partial: ${JSON.stringify(this.keyword_partial)}\n`;
|
|
1866
|
+
|
|
1867
|
+
return output;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
export interface SerializedRenderInvalidAsOptionError {
|
|
1872
|
+
type: "RENDER_INVALID_AS_OPTION_ERROR";
|
|
1873
|
+
message: string;
|
|
1874
|
+
location: SerializedLocation;
|
|
1875
|
+
as_value: string;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
export interface RenderInvalidAsOptionErrorProps {
|
|
1879
|
+
type: string;
|
|
1880
|
+
message: string;
|
|
1881
|
+
location: Location;
|
|
1882
|
+
as_value: string;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
export class RenderInvalidAsOptionError extends HerbError {
|
|
1886
|
+
readonly as_value: string;
|
|
1887
|
+
|
|
1888
|
+
static from(data: SerializedRenderInvalidAsOptionError): RenderInvalidAsOptionError {
|
|
1889
|
+
return new RenderInvalidAsOptionError({
|
|
1890
|
+
type: data.type,
|
|
1891
|
+
message: data.message,
|
|
1892
|
+
location: Location.from(data.location),
|
|
1893
|
+
as_value: data.as_value,
|
|
1894
|
+
})
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
constructor(props: RenderInvalidAsOptionErrorProps) {
|
|
1898
|
+
super(props.type, props.message, props.location);
|
|
1899
|
+
|
|
1900
|
+
this.as_value = props.as_value;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
toJSON(): SerializedRenderInvalidAsOptionError {
|
|
1904
|
+
return {
|
|
1905
|
+
...super.toJSON(),
|
|
1906
|
+
type: "RENDER_INVALID_AS_OPTION_ERROR",
|
|
1907
|
+
as_value: this.as_value,
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
1912
|
+
return {
|
|
1913
|
+
line: this.location.start.line,
|
|
1914
|
+
column: this.location.start.column,
|
|
1915
|
+
endLine: this.location.end.line,
|
|
1916
|
+
endColumn: this.location.end.column,
|
|
1917
|
+
message: this.message,
|
|
1918
|
+
severity: 'error'
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
treeInspect(): string {
|
|
1923
|
+
let output = "";
|
|
1924
|
+
|
|
1925
|
+
output += `@ RenderInvalidAsOptionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1926
|
+
output += `├── message: "${this.message}"\n`;
|
|
1927
|
+
output += `└── as_value: ${JSON.stringify(this.as_value)}\n`;
|
|
1928
|
+
|
|
1929
|
+
return output;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
export interface SerializedRenderObjectAndCollectionError {
|
|
1934
|
+
type: "RENDER_OBJECT_AND_COLLECTION_ERROR";
|
|
1935
|
+
message: string;
|
|
1936
|
+
location: SerializedLocation;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
export interface RenderObjectAndCollectionErrorProps {
|
|
1940
|
+
type: string;
|
|
1941
|
+
message: string;
|
|
1942
|
+
location: Location;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
export class RenderObjectAndCollectionError extends HerbError {
|
|
1946
|
+
|
|
1947
|
+
static from(data: SerializedRenderObjectAndCollectionError): RenderObjectAndCollectionError {
|
|
1948
|
+
return new RenderObjectAndCollectionError({
|
|
1949
|
+
type: data.type,
|
|
1950
|
+
message: data.message,
|
|
1951
|
+
location: Location.from(data.location),
|
|
1952
|
+
})
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
constructor(props: RenderObjectAndCollectionErrorProps) {
|
|
1956
|
+
super(props.type, props.message, props.location);
|
|
1957
|
+
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
toJSON(): SerializedRenderObjectAndCollectionError {
|
|
1961
|
+
return {
|
|
1962
|
+
...super.toJSON(),
|
|
1963
|
+
type: "RENDER_OBJECT_AND_COLLECTION_ERROR",
|
|
1964
|
+
};
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
1968
|
+
return {
|
|
1969
|
+
line: this.location.start.line,
|
|
1970
|
+
column: this.location.start.column,
|
|
1971
|
+
endLine: this.location.end.line,
|
|
1972
|
+
endColumn: this.location.end.column,
|
|
1973
|
+
message: this.message,
|
|
1974
|
+
severity: 'error'
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
treeInspect(): string {
|
|
1979
|
+
let output = "";
|
|
1980
|
+
|
|
1981
|
+
output += `@ RenderObjectAndCollectionError ${this.location.treeInspectWithLabel()}\n`;
|
|
1982
|
+
output += `└── message: "${this.message}"\n`;
|
|
1983
|
+
|
|
1984
|
+
return output;
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
export interface SerializedRenderLayoutWithoutBlockError {
|
|
1989
|
+
type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR";
|
|
1990
|
+
message: string;
|
|
1991
|
+
location: SerializedLocation;
|
|
1992
|
+
layout: string;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
export interface RenderLayoutWithoutBlockErrorProps {
|
|
1996
|
+
type: string;
|
|
1997
|
+
message: string;
|
|
1998
|
+
location: Location;
|
|
1999
|
+
layout: string;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
export class RenderLayoutWithoutBlockError extends HerbError {
|
|
2003
|
+
readonly layout: string;
|
|
2004
|
+
|
|
2005
|
+
static from(data: SerializedRenderLayoutWithoutBlockError): RenderLayoutWithoutBlockError {
|
|
2006
|
+
return new RenderLayoutWithoutBlockError({
|
|
2007
|
+
type: data.type,
|
|
2008
|
+
message: data.message,
|
|
2009
|
+
location: Location.from(data.location),
|
|
2010
|
+
layout: data.layout,
|
|
2011
|
+
})
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
constructor(props: RenderLayoutWithoutBlockErrorProps) {
|
|
2015
|
+
super(props.type, props.message, props.location);
|
|
2016
|
+
|
|
2017
|
+
this.layout = props.layout;
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
toJSON(): SerializedRenderLayoutWithoutBlockError {
|
|
2021
|
+
return {
|
|
2022
|
+
...super.toJSON(),
|
|
2023
|
+
type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR",
|
|
2024
|
+
layout: this.layout,
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
toMonacoDiagnostic(): MonacoDiagnostic {
|
|
2029
|
+
return {
|
|
2030
|
+
line: this.location.start.line,
|
|
2031
|
+
column: this.location.start.column,
|
|
2032
|
+
endLine: this.location.end.line,
|
|
2033
|
+
endColumn: this.location.end.column,
|
|
2034
|
+
message: this.message,
|
|
2035
|
+
severity: 'error'
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
treeInspect(): string {
|
|
2040
|
+
let output = "";
|
|
2041
|
+
|
|
2042
|
+
output += `@ RenderLayoutWithoutBlockError ${this.location.treeInspectWithLabel()}\n`;
|
|
2043
|
+
output += `├── message: "${this.message}"\n`;
|
|
2044
|
+
output += `└── layout: ${JSON.stringify(this.layout)}\n`;
|
|
2045
|
+
|
|
2046
|
+
return output;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
|
|
1609
2050
|
|
|
1610
2051
|
export function fromSerializedError(error: SerializedHerbError): HerbError {
|
|
1611
2052
|
switch (error.type) {
|
|
@@ -1632,6 +2073,13 @@ export function fromSerializedError(error: SerializedHerbError): HerbError {
|
|
|
1632
2073
|
case "UNCLOSED_ERB_TAG_ERROR": return UnclosedERBTagError.from(error as SerializedUnclosedERBTagError);
|
|
1633
2074
|
case "STRAY_ERB_CLOSING_TAG_ERROR": return StrayERBClosingTagError.from(error as SerializedStrayERBClosingTagError);
|
|
1634
2075
|
case "NESTED_ERB_TAG_ERROR": return NestedERBTagError.from(error as SerializedNestedERBTagError);
|
|
2076
|
+
case "RENDER_AMBIGUOUS_LOCALS_ERROR": return RenderAmbiguousLocalsError.from(error as SerializedRenderAmbiguousLocalsError);
|
|
2077
|
+
case "RENDER_MISSING_LOCALS_ERROR": return RenderMissingLocalsError.from(error as SerializedRenderMissingLocalsError);
|
|
2078
|
+
case "RENDER_NO_ARGUMENTS_ERROR": return RenderNoArgumentsError.from(error as SerializedRenderNoArgumentsError);
|
|
2079
|
+
case "RENDER_CONFLICTING_PARTIAL_ERROR": return RenderConflictingPartialError.from(error as SerializedRenderConflictingPartialError);
|
|
2080
|
+
case "RENDER_INVALID_AS_OPTION_ERROR": return RenderInvalidAsOptionError.from(error as SerializedRenderInvalidAsOptionError);
|
|
2081
|
+
case "RENDER_OBJECT_AND_COLLECTION_ERROR": return RenderObjectAndCollectionError.from(error as SerializedRenderObjectAndCollectionError);
|
|
2082
|
+
case "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR": return RenderLayoutWithoutBlockError.from(error as SerializedRenderLayoutWithoutBlockError);
|
|
1635
2083
|
|
|
1636
2084
|
default:
|
|
1637
2085
|
throw new Error(`Unknown node type: ${error.type}`);
|
package/src/node-type-guards.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.9.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
3
3
|
|
|
4
4
|
import type { Node, NodeType, ERBNode } from "./nodes.js"
|
|
5
5
|
|
|
@@ -43,6 +43,8 @@ import {
|
|
|
43
43
|
ERBEnsureNode,
|
|
44
44
|
ERBBeginNode,
|
|
45
45
|
ERBUnlessNode,
|
|
46
|
+
RubyRenderLocalNode,
|
|
47
|
+
ERBRenderNode,
|
|
46
48
|
ERBYieldNode,
|
|
47
49
|
ERBInNode,
|
|
48
50
|
} from "./nodes.js"
|
|
@@ -378,6 +380,24 @@ export function isERBUnlessNode(node: Node | null | undefined): node is ERBUnle
|
|
|
378
380
|
return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || (node.constructor as any).type === "AST_ERB_UNLESS_NODE"
|
|
379
381
|
}
|
|
380
382
|
|
|
383
|
+
/**
|
|
384
|
+
* Checks if a node is a RubyRenderLocalNode
|
|
385
|
+
*/
|
|
386
|
+
export function isRubyRenderLocalNode(node: Node | null | undefined): node is RubyRenderLocalNode {
|
|
387
|
+
if (!node) return false
|
|
388
|
+
|
|
389
|
+
return node instanceof RubyRenderLocalNode || node.type === "AST_RUBY_RENDER_LOCAL_NODE" || (node.constructor as any).type === "AST_RUBY_RENDER_LOCAL_NODE"
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Checks if a node is a ERBRenderNode
|
|
394
|
+
*/
|
|
395
|
+
export function isERBRenderNode(node: Node | null | undefined): node is ERBRenderNode {
|
|
396
|
+
if (!node) return false
|
|
397
|
+
|
|
398
|
+
return node instanceof ERBRenderNode || node.type === "AST_ERB_RENDER_NODE" || (node.constructor as any).type === "AST_ERB_RENDER_NODE"
|
|
399
|
+
}
|
|
400
|
+
|
|
381
401
|
/**
|
|
382
402
|
* Checks if a node is a ERBYieldNode
|
|
383
403
|
*/
|
|
@@ -439,6 +459,7 @@ export function isERBNode(node: Node): node is ERBNode {
|
|
|
439
459
|
isERBEnsureNode(node) ||
|
|
440
460
|
isERBBeginNode(node) ||
|
|
441
461
|
isERBUnlessNode(node) ||
|
|
462
|
+
isERBRenderNode(node) ||
|
|
442
463
|
isERBYieldNode(node) ||
|
|
443
464
|
isERBInNode(node)
|
|
444
465
|
}
|
|
@@ -490,6 +511,8 @@ export const NODE_TYPE_GUARDS = new Map<new (...args: any[]) => Node, (node: Nod
|
|
|
490
511
|
[ERBEnsureNode, isERBEnsureNode],
|
|
491
512
|
[ERBBeginNode, isERBBeginNode],
|
|
492
513
|
[ERBUnlessNode, isERBUnlessNode],
|
|
514
|
+
[RubyRenderLocalNode, isRubyRenderLocalNode],
|
|
515
|
+
[ERBRenderNode, isERBRenderNode],
|
|
493
516
|
[ERBYieldNode, isERBYieldNode],
|
|
494
517
|
[ERBInNode, isERBInNode],
|
|
495
518
|
])
|
|
@@ -541,6 +564,8 @@ export const AST_TYPE_GUARDS = new Map<NodeType, (node: Node) => boolean>([
|
|
|
541
564
|
["AST_ERB_ENSURE_NODE", isERBEnsureNode],
|
|
542
565
|
["AST_ERB_BEGIN_NODE", isERBBeginNode],
|
|
543
566
|
["AST_ERB_UNLESS_NODE", isERBUnlessNode],
|
|
567
|
+
["AST_RUBY_RENDER_LOCAL_NODE", isRubyRenderLocalNode],
|
|
568
|
+
["AST_ERB_RENDER_NODE", isERBRenderNode],
|
|
544
569
|
["AST_ERB_YIELD_NODE", isERBYieldNode],
|
|
545
570
|
["AST_ERB_IN_NODE", isERBInNode],
|
|
546
571
|
])
|
|
@@ -582,6 +607,8 @@ type NodeTypeToClass = {
|
|
|
582
607
|
"AST_ERB_ENSURE_NODE": ERBEnsureNode;
|
|
583
608
|
"AST_ERB_BEGIN_NODE": ERBBeginNode;
|
|
584
609
|
"AST_ERB_UNLESS_NODE": ERBUnlessNode;
|
|
610
|
+
"AST_RUBY_RENDER_LOCAL_NODE": RubyRenderLocalNode;
|
|
611
|
+
"AST_ERB_RENDER_NODE": ERBRenderNode;
|
|
585
612
|
"AST_ERB_YIELD_NODE": ERBYieldNode;
|
|
586
613
|
"AST_ERB_IN_NODE": ERBInNode;
|
|
587
614
|
}
|
|
@@ -1069,6 +1096,20 @@ export function filterERBUnlessNodes(nodes: Node[]): ERBUnlessNode[] {
|
|
|
1069
1096
|
return nodes.filter(isERBUnlessNode) as ERBUnlessNode[]
|
|
1070
1097
|
}
|
|
1071
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* Filters an array of nodes to only include RubyRenderLocalNode nodes
|
|
1101
|
+
*/
|
|
1102
|
+
export function filterRubyRenderLocalNodes(nodes: Node[]): RubyRenderLocalNode[] {
|
|
1103
|
+
return nodes.filter(isRubyRenderLocalNode) as RubyRenderLocalNode[]
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* Filters an array of nodes to only include ERBRenderNode nodes
|
|
1108
|
+
*/
|
|
1109
|
+
export function filterERBRenderNodes(nodes: Node[]): ERBRenderNode[] {
|
|
1110
|
+
return nodes.filter(isERBRenderNode) as ERBRenderNode[]
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1072
1113
|
/**
|
|
1073
1114
|
* Filters an array of nodes to only include ERBYieldNode nodes
|
|
1074
1115
|
*/
|