@herb-tools/core 0.6.0 → 0.6.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.
@@ -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.6.0/templates/javascript/packages/core/src/node-type-guards.ts.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.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
 
@@ -51,217 +51,217 @@ import {
51
51
  * Checks if a node is a DocumentNode
52
52
  */
53
53
  export function isDocumentNode(node: Node): node is DocumentNode {
54
- return node instanceof DocumentNode || (node as any).type === "AST_DOCUMENT_NODE"
54
+ return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE" || (node.constructor as any).type === "AST_DOCUMENT_NODE"
55
55
  }
56
56
 
57
57
  /**
58
58
  * Checks if a node is a LiteralNode
59
59
  */
60
60
  export function isLiteralNode(node: Node): node is LiteralNode {
61
- return node instanceof LiteralNode || (node as any).type === "AST_LITERAL_NODE"
61
+ return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE" || (node.constructor as any).type === "AST_LITERAL_NODE"
62
62
  }
63
63
 
64
64
  /**
65
65
  * Checks if a node is a HTMLOpenTagNode
66
66
  */
67
67
  export function isHTMLOpenTagNode(node: Node): node is HTMLOpenTagNode {
68
- return node instanceof HTMLOpenTagNode || (node as any).type === "AST_HTML_OPEN_TAG_NODE"
68
+ return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE" || (node.constructor as any).type === "AST_HTML_OPEN_TAG_NODE"
69
69
  }
70
70
 
71
71
  /**
72
72
  * Checks if a node is a HTMLCloseTagNode
73
73
  */
74
74
  export function isHTMLCloseTagNode(node: Node): node is HTMLCloseTagNode {
75
- return node instanceof HTMLCloseTagNode || (node as any).type === "AST_HTML_CLOSE_TAG_NODE"
75
+ return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE" || (node.constructor as any).type === "AST_HTML_CLOSE_TAG_NODE"
76
76
  }
77
77
 
78
78
  /**
79
79
  * Checks if a node is a HTMLElementNode
80
80
  */
81
81
  export function isHTMLElementNode(node: Node): node is HTMLElementNode {
82
- return node instanceof HTMLElementNode || (node as any).type === "AST_HTML_ELEMENT_NODE"
82
+ return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE" || (node.constructor as any).type === "AST_HTML_ELEMENT_NODE"
83
83
  }
84
84
 
85
85
  /**
86
86
  * Checks if a node is a HTMLAttributeValueNode
87
87
  */
88
88
  export function isHTMLAttributeValueNode(node: Node): node is HTMLAttributeValueNode {
89
- return node instanceof HTMLAttributeValueNode || (node as any).type === "AST_HTML_ATTRIBUTE_VALUE_NODE"
89
+ return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE" || (node.constructor as any).type === "AST_HTML_ATTRIBUTE_VALUE_NODE"
90
90
  }
91
91
 
92
92
  /**
93
93
  * Checks if a node is a HTMLAttributeNameNode
94
94
  */
95
95
  export function isHTMLAttributeNameNode(node: Node): node is HTMLAttributeNameNode {
96
- return node instanceof HTMLAttributeNameNode || (node as any).type === "AST_HTML_ATTRIBUTE_NAME_NODE"
96
+ return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE" || (node.constructor as any).type === "AST_HTML_ATTRIBUTE_NAME_NODE"
97
97
  }
98
98
 
99
99
  /**
100
100
  * Checks if a node is a HTMLAttributeNode
101
101
  */
102
102
  export function isHTMLAttributeNode(node: Node): node is HTMLAttributeNode {
103
- return node instanceof HTMLAttributeNode || (node as any).type === "AST_HTML_ATTRIBUTE_NODE"
103
+ return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE" || (node.constructor as any).type === "AST_HTML_ATTRIBUTE_NODE"
104
104
  }
105
105
 
106
106
  /**
107
107
  * Checks if a node is a HTMLTextNode
108
108
  */
109
109
  export function isHTMLTextNode(node: Node): node is HTMLTextNode {
110
- return node instanceof HTMLTextNode || (node as any).type === "AST_HTML_TEXT_NODE"
110
+ return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE" || (node.constructor as any).type === "AST_HTML_TEXT_NODE"
111
111
  }
112
112
 
113
113
  /**
114
114
  * Checks if a node is a HTMLCommentNode
115
115
  */
116
116
  export function isHTMLCommentNode(node: Node): node is HTMLCommentNode {
117
- return node instanceof HTMLCommentNode || (node as any).type === "AST_HTML_COMMENT_NODE"
117
+ return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE" || (node.constructor as any).type === "AST_HTML_COMMENT_NODE"
118
118
  }
119
119
 
120
120
  /**
121
121
  * Checks if a node is a HTMLDoctypeNode
122
122
  */
123
123
  export function isHTMLDoctypeNode(node: Node): node is HTMLDoctypeNode {
124
- return node instanceof HTMLDoctypeNode || (node as any).type === "AST_HTML_DOCTYPE_NODE"
124
+ return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE" || (node.constructor as any).type === "AST_HTML_DOCTYPE_NODE"
125
125
  }
126
126
 
127
127
  /**
128
128
  * Checks if a node is a XMLDeclarationNode
129
129
  */
130
130
  export function isXMLDeclarationNode(node: Node): node is XMLDeclarationNode {
131
- return node instanceof XMLDeclarationNode || (node as any).type === "AST_XML_DECLARATION_NODE"
131
+ return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE" || (node.constructor as any).type === "AST_XML_DECLARATION_NODE"
132
132
  }
133
133
 
134
134
  /**
135
135
  * Checks if a node is a CDATANode
136
136
  */
137
137
  export function isCDATANode(node: Node): node is CDATANode {
138
- return node instanceof CDATANode || (node as any).type === "AST_CDATA_NODE"
138
+ return node instanceof CDATANode || node.type === "AST_CDATA_NODE" || (node.constructor as any).type === "AST_CDATA_NODE"
139
139
  }
140
140
 
141
141
  /**
142
142
  * Checks if a node is a WhitespaceNode
143
143
  */
144
144
  export function isWhitespaceNode(node: Node): node is WhitespaceNode {
145
- return node instanceof WhitespaceNode || (node as any).type === "AST_WHITESPACE_NODE"
145
+ return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE" || (node.constructor as any).type === "AST_WHITESPACE_NODE"
146
146
  }
147
147
 
148
148
  /**
149
149
  * Checks if a node is a ERBContentNode
150
150
  */
151
151
  export function isERBContentNode(node: Node): node is ERBContentNode {
152
- return node instanceof ERBContentNode || (node as any).type === "AST_ERB_CONTENT_NODE"
152
+ return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE" || (node.constructor as any).type === "AST_ERB_CONTENT_NODE"
153
153
  }
154
154
 
155
155
  /**
156
156
  * Checks if a node is a ERBEndNode
157
157
  */
158
158
  export function isERBEndNode(node: Node): node is ERBEndNode {
159
- return node instanceof ERBEndNode || (node as any).type === "AST_ERB_END_NODE"
159
+ return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE" || (node.constructor as any).type === "AST_ERB_END_NODE"
160
160
  }
161
161
 
162
162
  /**
163
163
  * Checks if a node is a ERBElseNode
164
164
  */
165
165
  export function isERBElseNode(node: Node): node is ERBElseNode {
166
- return node instanceof ERBElseNode || (node as any).type === "AST_ERB_ELSE_NODE"
166
+ return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE" || (node.constructor as any).type === "AST_ERB_ELSE_NODE"
167
167
  }
168
168
 
169
169
  /**
170
170
  * Checks if a node is a ERBIfNode
171
171
  */
172
172
  export function isERBIfNode(node: Node): node is ERBIfNode {
173
- return node instanceof ERBIfNode || (node as any).type === "AST_ERB_IF_NODE"
173
+ return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE" || (node.constructor as any).type === "AST_ERB_IF_NODE"
174
174
  }
175
175
 
176
176
  /**
177
177
  * Checks if a node is a ERBBlockNode
178
178
  */
179
179
  export function isERBBlockNode(node: Node): node is ERBBlockNode {
180
- return node instanceof ERBBlockNode || (node as any).type === "AST_ERB_BLOCK_NODE"
180
+ return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE" || (node.constructor as any).type === "AST_ERB_BLOCK_NODE"
181
181
  }
182
182
 
183
183
  /**
184
184
  * Checks if a node is a ERBWhenNode
185
185
  */
186
186
  export function isERBWhenNode(node: Node): node is ERBWhenNode {
187
- return node instanceof ERBWhenNode || (node as any).type === "AST_ERB_WHEN_NODE"
187
+ return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE" || (node.constructor as any).type === "AST_ERB_WHEN_NODE"
188
188
  }
189
189
 
190
190
  /**
191
191
  * Checks if a node is a ERBCaseNode
192
192
  */
193
193
  export function isERBCaseNode(node: Node): node is ERBCaseNode {
194
- return node instanceof ERBCaseNode || (node as any).type === "AST_ERB_CASE_NODE"
194
+ return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE" || (node.constructor as any).type === "AST_ERB_CASE_NODE"
195
195
  }
196
196
 
197
197
  /**
198
198
  * Checks if a node is a ERBCaseMatchNode
199
199
  */
200
200
  export function isERBCaseMatchNode(node: Node): node is ERBCaseMatchNode {
201
- return node instanceof ERBCaseMatchNode || (node as any).type === "AST_ERB_CASE_MATCH_NODE"
201
+ return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE" || (node.constructor as any).type === "AST_ERB_CASE_MATCH_NODE"
202
202
  }
203
203
 
204
204
  /**
205
205
  * Checks if a node is a ERBWhileNode
206
206
  */
207
207
  export function isERBWhileNode(node: Node): node is ERBWhileNode {
208
- return node instanceof ERBWhileNode || (node as any).type === "AST_ERB_WHILE_NODE"
208
+ return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE" || (node.constructor as any).type === "AST_ERB_WHILE_NODE"
209
209
  }
210
210
 
211
211
  /**
212
212
  * Checks if a node is a ERBUntilNode
213
213
  */
214
214
  export function isERBUntilNode(node: Node): node is ERBUntilNode {
215
- return node instanceof ERBUntilNode || (node as any).type === "AST_ERB_UNTIL_NODE"
215
+ return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE" || (node.constructor as any).type === "AST_ERB_UNTIL_NODE"
216
216
  }
217
217
 
218
218
  /**
219
219
  * Checks if a node is a ERBForNode
220
220
  */
221
221
  export function isERBForNode(node: Node): node is ERBForNode {
222
- return node instanceof ERBForNode || (node as any).type === "AST_ERB_FOR_NODE"
222
+ return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE" || (node.constructor as any).type === "AST_ERB_FOR_NODE"
223
223
  }
224
224
 
225
225
  /**
226
226
  * Checks if a node is a ERBRescueNode
227
227
  */
228
228
  export function isERBRescueNode(node: Node): node is ERBRescueNode {
229
- return node instanceof ERBRescueNode || (node as any).type === "AST_ERB_RESCUE_NODE"
229
+ return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE" || (node.constructor as any).type === "AST_ERB_RESCUE_NODE"
230
230
  }
231
231
 
232
232
  /**
233
233
  * Checks if a node is a ERBEnsureNode
234
234
  */
235
235
  export function isERBEnsureNode(node: Node): node is ERBEnsureNode {
236
- return node instanceof ERBEnsureNode || (node as any).type === "AST_ERB_ENSURE_NODE"
236
+ return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE" || (node.constructor as any).type === "AST_ERB_ENSURE_NODE"
237
237
  }
238
238
 
239
239
  /**
240
240
  * Checks if a node is a ERBBeginNode
241
241
  */
242
242
  export function isERBBeginNode(node: Node): node is ERBBeginNode {
243
- return node instanceof ERBBeginNode || (node as any).type === "AST_ERB_BEGIN_NODE"
243
+ return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE" || (node.constructor as any).type === "AST_ERB_BEGIN_NODE"
244
244
  }
245
245
 
246
246
  /**
247
247
  * Checks if a node is a ERBUnlessNode
248
248
  */
249
249
  export function isERBUnlessNode(node: Node): node is ERBUnlessNode {
250
- return node instanceof ERBUnlessNode || (node as any).type === "AST_ERB_UNLESS_NODE"
250
+ return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || (node.constructor as any).type === "AST_ERB_UNLESS_NODE"
251
251
  }
252
252
 
253
253
  /**
254
254
  * Checks if a node is a ERBYieldNode
255
255
  */
256
256
  export function isERBYieldNode(node: Node): node is ERBYieldNode {
257
- return node instanceof ERBYieldNode || (node as any).type === "AST_ERB_YIELD_NODE"
257
+ return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE" || (node.constructor as any).type === "AST_ERB_YIELD_NODE"
258
258
  }
259
259
 
260
260
  /**
261
261
  * Checks if a node is a ERBInNode
262
262
  */
263
263
  export function isERBInNode(node: Node): node is ERBInNode {
264
- return node instanceof ERBInNode || (node as any).type === "AST_ERB_IN_NODE"
264
+ return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE" || (node.constructor as any).type === "AST_ERB_IN_NODE"
265
265
  }
266
266
 
267
267
  /**
@@ -360,7 +360,7 @@ export const NODE_TYPE_GUARDS = new Map<new (...args: any[]) => Node, (node: Nod
360
360
  * // node is HTMLTextNode
361
361
  * }
362
362
  */
363
- export const AST_TYPE_GUARDS = new Map<string, (node: Node) => boolean>([
363
+ export const AST_TYPE_GUARDS = new Map<NodeType, (node: Node) => boolean>([
364
364
  ["AST_DOCUMENT_NODE", isDocumentNode],
365
365
  ["AST_LITERAL_NODE", isLiteralNode],
366
366
  ["AST_HTML_OPEN_TAG_NODE", isHTMLOpenTagNode],
@@ -591,19 +591,21 @@ export function filterNodes(
591
591
  */
592
592
 
593
593
  export function isNode<T extends NodeType>(
594
- node: Node,
594
+ node: Node | null | undefined,
595
595
  type: T
596
596
  ): node is NodeTypeToClass[T]
597
597
 
598
598
  export function isNode<T extends new (...args: any[]) => Node>(
599
- node: Node,
599
+ node: Node | null | undefined,
600
600
  type: T
601
601
  ): node is ClassToInstance<T>
602
602
 
603
603
  export function isNode(
604
- node: Node,
604
+ node: Node | null | undefined,
605
605
  type: NodeType | (new (...args: any[]) => Node)
606
606
  ): boolean {
607
+ if (!node) return false
608
+
607
609
  if (typeof type === 'string') {
608
610
  const guard = AST_TYPE_GUARDS.get(type)
609
611
 
package/src/nodes.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.6.0/templates/javascript/packages/core/src/nodes.ts.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/nodes.ts.erb
3
3
 
4
4
  import { Location } from "./location.js"
5
5
  import { Token, SerializedToken } from "./token.js"
@@ -33,6 +33,10 @@ export abstract class Node implements BaseNodeProps {
33
33
  return fromSerializedNode(node)
34
34
  }
35
35
 
36
+ static get type(): NodeType {
37
+ throw new Error("AST_NODE")
38
+ }
39
+
36
40
  constructor(type: NodeType, location: Location, errors: HerbError[]) {
37
41
  this.type = type
38
42
  this.location = location
@@ -51,6 +55,14 @@ export abstract class Node implements BaseNodeProps {
51
55
  return this.treeInspect(0)
52
56
  }
53
57
 
58
+ is<T extends Node>(nodeClass: { new(...args: any[]): T; prototype: T, type: NodeType }): this is T {
59
+ return this.type === nodeClass.type
60
+ }
61
+
62
+ isOfType<T extends Node>(type: NodeType): this is T {
63
+ return this.type === type
64
+ }
65
+
54
66
  get isSingleLine(): boolean {
55
67
  return this.location.start.line === this.location.end.line
56
68
  }
@@ -133,6 +145,10 @@ export interface DocumentNodeProps extends BaseNodeProps {
133
145
  export class DocumentNode extends Node {
134
146
  readonly children: Node[];
135
147
 
148
+ static get type(): NodeType {
149
+ return "AST_DOCUMENT_NODE"
150
+ }
151
+
136
152
  static from(data: SerializedDocumentNode): DocumentNode {
137
153
  return new DocumentNode({
138
154
  type: data.type,
@@ -199,6 +215,10 @@ export interface LiteralNodeProps extends BaseNodeProps {
199
215
  export class LiteralNode extends Node {
200
216
  readonly content: string;
201
217
 
218
+ static get type(): NodeType {
219
+ return "AST_LITERAL_NODE"
220
+ }
221
+
202
222
  static from(data: SerializedLiteralNode): LiteralNode {
203
223
  return new LiteralNode({
204
224
  type: data.type,
@@ -275,6 +295,10 @@ export class HTMLOpenTagNode extends Node {
275
295
  readonly children: Node[];
276
296
  readonly is_void: boolean;
277
297
 
298
+ static get type(): NodeType {
299
+ return "AST_HTML_OPEN_TAG_NODE"
300
+ }
301
+
278
302
  static from(data: SerializedHTMLOpenTagNode): HTMLOpenTagNode {
279
303
  return new HTMLOpenTagNode({
280
304
  type: data.type,
@@ -366,6 +390,10 @@ export class HTMLCloseTagNode extends Node {
366
390
  readonly children: Node[];
367
391
  readonly tag_closing: Token | null;
368
392
 
393
+ static get type(): NodeType {
394
+ return "AST_HTML_CLOSE_TAG_NODE"
395
+ }
396
+
369
397
  static from(data: SerializedHTMLCloseTagNode): HTMLCloseTagNode {
370
398
  return new HTMLCloseTagNode({
371
399
  type: data.type,
@@ -456,6 +484,10 @@ export class HTMLElementNode extends Node {
456
484
  readonly close_tag: HTMLCloseTagNode | null;
457
485
  readonly is_void: boolean;
458
486
 
487
+ static get type(): NodeType {
488
+ return "AST_HTML_ELEMENT_NODE"
489
+ }
490
+
459
491
  static from(data: SerializedHTMLElementNode): HTMLElementNode {
460
492
  return new HTMLElementNode({
461
493
  type: data.type,
@@ -551,6 +583,10 @@ export class HTMLAttributeValueNode extends Node {
551
583
  readonly close_quote: Token | null;
552
584
  readonly quoted: boolean;
553
585
 
586
+ static get type(): NodeType {
587
+ return "AST_HTML_ATTRIBUTE_VALUE_NODE"
588
+ }
589
+
554
590
  static from(data: SerializedHTMLAttributeValueNode): HTMLAttributeValueNode {
555
591
  return new HTMLAttributeValueNode({
556
592
  type: data.type,
@@ -629,6 +665,10 @@ export interface HTMLAttributeNameNodeProps extends BaseNodeProps {
629
665
  export class HTMLAttributeNameNode extends Node {
630
666
  readonly children: Node[];
631
667
 
668
+ static get type(): NodeType {
669
+ return "AST_HTML_ATTRIBUTE_NAME_NODE"
670
+ }
671
+
632
672
  static from(data: SerializedHTMLAttributeNameNode): HTMLAttributeNameNode {
633
673
  return new HTMLAttributeNameNode({
634
674
  type: data.type,
@@ -701,6 +741,10 @@ export class HTMLAttributeNode extends Node {
701
741
  readonly equals: Token | null;
702
742
  readonly value: HTMLAttributeValueNode | null;
703
743
 
744
+ static get type(): NodeType {
745
+ return "AST_HTML_ATTRIBUTE_NODE"
746
+ }
747
+
704
748
  static from(data: SerializedHTMLAttributeNode): HTMLAttributeNode {
705
749
  return new HTMLAttributeNode({
706
750
  type: data.type,
@@ -777,6 +821,10 @@ export interface HTMLTextNodeProps extends BaseNodeProps {
777
821
  export class HTMLTextNode extends Node {
778
822
  readonly content: string;
779
823
 
824
+ static get type(): NodeType {
825
+ return "AST_HTML_TEXT_NODE"
826
+ }
827
+
780
828
  static from(data: SerializedHTMLTextNode): HTMLTextNode {
781
829
  return new HTMLTextNode({
782
830
  type: data.type,
@@ -847,6 +895,10 @@ export class HTMLCommentNode extends Node {
847
895
  readonly children: Node[];
848
896
  readonly comment_end: Token | null;
849
897
 
898
+ static get type(): NodeType {
899
+ return "AST_HTML_COMMENT_NODE"
900
+ }
901
+
850
902
  static from(data: SerializedHTMLCommentNode): HTMLCommentNode {
851
903
  return new HTMLCommentNode({
852
904
  type: data.type,
@@ -927,6 +979,10 @@ export class HTMLDoctypeNode extends Node {
927
979
  readonly children: Node[];
928
980
  readonly tag_closing: Token | null;
929
981
 
982
+ static get type(): NodeType {
983
+ return "AST_HTML_DOCTYPE_NODE"
984
+ }
985
+
930
986
  static from(data: SerializedHTMLDoctypeNode): HTMLDoctypeNode {
931
987
  return new HTMLDoctypeNode({
932
988
  type: data.type,
@@ -1007,6 +1063,10 @@ export class XMLDeclarationNode extends Node {
1007
1063
  readonly children: Node[];
1008
1064
  readonly tag_closing: Token | null;
1009
1065
 
1066
+ static get type(): NodeType {
1067
+ return "AST_XML_DECLARATION_NODE"
1068
+ }
1069
+
1010
1070
  static from(data: SerializedXMLDeclarationNode): XMLDeclarationNode {
1011
1071
  return new XMLDeclarationNode({
1012
1072
  type: data.type,
@@ -1087,6 +1147,10 @@ export class CDATANode extends Node {
1087
1147
  readonly children: Node[];
1088
1148
  readonly tag_closing: Token | null;
1089
1149
 
1150
+ static get type(): NodeType {
1151
+ return "AST_CDATA_NODE"
1152
+ }
1153
+
1090
1154
  static from(data: SerializedCDATANode): CDATANode {
1091
1155
  return new CDATANode({
1092
1156
  type: data.type,
@@ -1161,6 +1225,10 @@ export interface WhitespaceNodeProps extends BaseNodeProps {
1161
1225
  export class WhitespaceNode extends Node {
1162
1226
  readonly value: Token | null;
1163
1227
 
1228
+ static get type(): NodeType {
1229
+ return "AST_WHITESPACE_NODE"
1230
+ }
1231
+
1164
1232
  static from(data: SerializedWhitespaceNode): WhitespaceNode {
1165
1233
  return new WhitespaceNode({
1166
1234
  type: data.type,
@@ -1240,6 +1308,10 @@ export class ERBContentNode extends Node {
1240
1308
  readonly parsed: boolean;
1241
1309
  readonly valid: boolean;
1242
1310
 
1311
+ static get type(): NodeType {
1312
+ return "AST_ERB_CONTENT_NODE"
1313
+ }
1314
+
1243
1315
  static from(data: SerializedERBContentNode): ERBContentNode {
1244
1316
  return new ERBContentNode({
1245
1317
  type: data.type,
@@ -1330,6 +1402,10 @@ export class ERBEndNode extends Node {
1330
1402
  readonly content: Token | null;
1331
1403
  readonly tag_closing: Token | null;
1332
1404
 
1405
+ static get type(): NodeType {
1406
+ return "AST_ERB_END_NODE"
1407
+ }
1408
+
1333
1409
  static from(data: SerializedERBEndNode): ERBEndNode {
1334
1410
  return new ERBEndNode({
1335
1411
  type: data.type,
@@ -1411,6 +1487,10 @@ export class ERBElseNode extends Node {
1411
1487
  readonly tag_closing: Token | null;
1412
1488
  readonly statements: Node[];
1413
1489
 
1490
+ static get type(): NodeType {
1491
+ return "AST_ERB_ELSE_NODE"
1492
+ }
1493
+
1414
1494
  static from(data: SerializedERBElseNode): ERBElseNode {
1415
1495
  return new ERBElseNode({
1416
1496
  type: data.type,
@@ -1504,6 +1584,10 @@ export class ERBIfNode extends Node {
1504
1584
  readonly subsequent: Node | null;
1505
1585
  readonly end_node: ERBEndNode | null;
1506
1586
 
1587
+ static get type(): NodeType {
1588
+ return "AST_ERB_IF_NODE"
1589
+ }
1590
+
1507
1591
  static from(data: SerializedERBIfNode): ERBIfNode {
1508
1592
  return new ERBIfNode({
1509
1593
  type: data.type,
@@ -1606,6 +1690,10 @@ export class ERBBlockNode extends Node {
1606
1690
  readonly body: Node[];
1607
1691
  readonly end_node: ERBEndNode | null;
1608
1692
 
1693
+ static get type(): NodeType {
1694
+ return "AST_ERB_BLOCK_NODE"
1695
+ }
1696
+
1609
1697
  static from(data: SerializedERBBlockNode): ERBBlockNode {
1610
1698
  return new ERBBlockNode({
1611
1699
  type: data.type,
@@ -1699,6 +1787,10 @@ export class ERBWhenNode extends Node {
1699
1787
  readonly tag_closing: Token | null;
1700
1788
  readonly statements: Node[];
1701
1789
 
1790
+ static get type(): NodeType {
1791
+ return "AST_ERB_WHEN_NODE"
1792
+ }
1793
+
1702
1794
  static from(data: SerializedERBWhenNode): ERBWhenNode {
1703
1795
  return new ERBWhenNode({
1704
1796
  type: data.type,
@@ -1795,6 +1887,10 @@ export class ERBCaseNode extends Node {
1795
1887
  readonly else_clause: ERBElseNode | null;
1796
1888
  readonly end_node: ERBEndNode | null;
1797
1889
 
1890
+ static get type(): NodeType {
1891
+ return "AST_ERB_CASE_NODE"
1892
+ }
1893
+
1798
1894
  static from(data: SerializedERBCaseNode): ERBCaseNode {
1799
1895
  return new ERBCaseNode({
1800
1896
  type: data.type,
@@ -1909,6 +2005,10 @@ export class ERBCaseMatchNode extends Node {
1909
2005
  readonly else_clause: ERBElseNode | null;
1910
2006
  readonly end_node: ERBEndNode | null;
1911
2007
 
2008
+ static get type(): NodeType {
2009
+ return "AST_ERB_CASE_MATCH_NODE"
2010
+ }
2011
+
1912
2012
  static from(data: SerializedERBCaseMatchNode): ERBCaseMatchNode {
1913
2013
  return new ERBCaseMatchNode({
1914
2014
  type: data.type,
@@ -2017,6 +2117,10 @@ export class ERBWhileNode extends Node {
2017
2117
  readonly statements: Node[];
2018
2118
  readonly end_node: ERBEndNode | null;
2019
2119
 
2120
+ static get type(): NodeType {
2121
+ return "AST_ERB_WHILE_NODE"
2122
+ }
2123
+
2020
2124
  static from(data: SerializedERBWhileNode): ERBWhileNode {
2021
2125
  return new ERBWhileNode({
2022
2126
  type: data.type,
@@ -2113,6 +2217,10 @@ export class ERBUntilNode extends Node {
2113
2217
  readonly statements: Node[];
2114
2218
  readonly end_node: ERBEndNode | null;
2115
2219
 
2220
+ static get type(): NodeType {
2221
+ return "AST_ERB_UNTIL_NODE"
2222
+ }
2223
+
2116
2224
  static from(data: SerializedERBUntilNode): ERBUntilNode {
2117
2225
  return new ERBUntilNode({
2118
2226
  type: data.type,
@@ -2209,6 +2317,10 @@ export class ERBForNode extends Node {
2209
2317
  readonly statements: Node[];
2210
2318
  readonly end_node: ERBEndNode | null;
2211
2319
 
2320
+ static get type(): NodeType {
2321
+ return "AST_ERB_FOR_NODE"
2322
+ }
2323
+
2212
2324
  static from(data: SerializedERBForNode): ERBForNode {
2213
2325
  return new ERBForNode({
2214
2326
  type: data.type,
@@ -2305,6 +2417,10 @@ export class ERBRescueNode extends Node {
2305
2417
  readonly statements: Node[];
2306
2418
  readonly subsequent: ERBRescueNode | null;
2307
2419
 
2420
+ static get type(): NodeType {
2421
+ return "AST_ERB_RESCUE_NODE"
2422
+ }
2423
+
2308
2424
  static from(data: SerializedERBRescueNode): ERBRescueNode {
2309
2425
  return new ERBRescueNode({
2310
2426
  type: data.type,
@@ -2398,6 +2514,10 @@ export class ERBEnsureNode extends Node {
2398
2514
  readonly tag_closing: Token | null;
2399
2515
  readonly statements: Node[];
2400
2516
 
2517
+ static get type(): NodeType {
2518
+ return "AST_ERB_ENSURE_NODE"
2519
+ }
2520
+
2401
2521
  static from(data: SerializedERBEnsureNode): ERBEnsureNode {
2402
2522
  return new ERBEnsureNode({
2403
2523
  type: data.type,
@@ -2497,6 +2617,10 @@ export class ERBBeginNode extends Node {
2497
2617
  readonly ensure_clause: ERBEnsureNode | null;
2498
2618
  readonly end_node: ERBEndNode | null;
2499
2619
 
2620
+ static get type(): NodeType {
2621
+ return "AST_ERB_BEGIN_NODE"
2622
+ }
2623
+
2500
2624
  static from(data: SerializedERBBeginNode): ERBBeginNode {
2501
2625
  return new ERBBeginNode({
2502
2626
  type: data.type,
@@ -2614,6 +2738,10 @@ export class ERBUnlessNode extends Node {
2614
2738
  readonly else_clause: ERBElseNode | null;
2615
2739
  readonly end_node: ERBEndNode | null;
2616
2740
 
2741
+ static get type(): NodeType {
2742
+ return "AST_ERB_UNLESS_NODE"
2743
+ }
2744
+
2617
2745
  static from(data: SerializedERBUnlessNode): ERBUnlessNode {
2618
2746
  return new ERBUnlessNode({
2619
2747
  type: data.type,
@@ -2710,6 +2838,10 @@ export class ERBYieldNode extends Node {
2710
2838
  readonly content: Token | null;
2711
2839
  readonly tag_closing: Token | null;
2712
2840
 
2841
+ static get type(): NodeType {
2842
+ return "AST_ERB_YIELD_NODE"
2843
+ }
2844
+
2713
2845
  static from(data: SerializedERBYieldNode): ERBYieldNode {
2714
2846
  return new ERBYieldNode({
2715
2847
  type: data.type,
@@ -2791,6 +2923,10 @@ export class ERBInNode extends Node {
2791
2923
  readonly tag_closing: Token | null;
2792
2924
  readonly statements: Node[];
2793
2925
 
2926
+ static get type(): NodeType {
2927
+ return "AST_ERB_IN_NODE"
2928
+ }
2929
+
2794
2930
  static from(data: SerializedERBInNode): ERBInNode {
2795
2931
  return new ERBInNode({
2796
2932
  type: data.type,
package/src/visitor.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.6.0/templates/javascript/packages/core/src/visitor.ts.erb
2
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/visitor.ts.erb
3
3
 
4
4
  import {
5
5
  Node,