@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.
@@ -131,7 +131,7 @@ class Token {
131
131
  }
132
132
 
133
133
  // NOTE: This file is generated by the templates/template.rb script and should not
134
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/errors.ts.erb
134
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/errors.ts.erb
135
135
  class HerbError {
136
136
  type;
137
137
  message;
@@ -588,7 +588,7 @@ function convertToUTF8(string) {
588
588
  }
589
589
 
590
590
  // NOTE: This file is generated by the templates/template.rb script and should not
591
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/nodes.ts.erb
591
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/nodes.ts.erb
592
592
  class Node {
593
593
  type;
594
594
  location;
@@ -596,6 +596,9 @@ class Node {
596
596
  static from(node) {
597
597
  return fromSerializedNode(node);
598
598
  }
599
+ static get type() {
600
+ throw new Error("AST_NODE");
601
+ }
599
602
  constructor(type, location, errors) {
600
603
  this.type = type;
601
604
  this.location = location;
@@ -611,6 +614,12 @@ class Node {
611
614
  inspect() {
612
615
  return this.treeInspect(0);
613
616
  }
617
+ is(nodeClass) {
618
+ return this.type === nodeClass.type;
619
+ }
620
+ isOfType(type) {
621
+ return this.type === type;
622
+ }
614
623
  get isSingleLine() {
615
624
  return this.location.start.line === this.location.end.line;
616
625
  }
@@ -652,6 +661,9 @@ class Node {
652
661
  }
653
662
  class DocumentNode extends Node {
654
663
  children;
664
+ static get type() {
665
+ return "AST_DOCUMENT_NODE";
666
+ }
655
667
  static from(data) {
656
668
  return new DocumentNode({
657
669
  type: data.type,
@@ -698,6 +710,9 @@ class DocumentNode extends Node {
698
710
  }
699
711
  class LiteralNode extends Node {
700
712
  content;
713
+ static get type() {
714
+ return "AST_LITERAL_NODE";
715
+ }
701
716
  static from(data) {
702
717
  return new LiteralNode({
703
718
  type: data.type,
@@ -745,6 +760,9 @@ class HTMLOpenTagNode extends Node {
745
760
  tag_closing;
746
761
  children;
747
762
  is_void;
763
+ static get type() {
764
+ return "AST_HTML_OPEN_TAG_NODE";
765
+ }
748
766
  static from(data) {
749
767
  return new HTMLOpenTagNode({
750
768
  type: data.type,
@@ -810,6 +828,9 @@ class HTMLCloseTagNode extends Node {
810
828
  tag_name;
811
829
  children;
812
830
  tag_closing;
831
+ static get type() {
832
+ return "AST_HTML_CLOSE_TAG_NODE";
833
+ }
813
834
  static from(data) {
814
835
  return new HTMLCloseTagNode({
815
836
  type: data.type,
@@ -872,6 +893,9 @@ class HTMLElementNode extends Node {
872
893
  body;
873
894
  close_tag;
874
895
  is_void;
896
+ static get type() {
897
+ return "AST_HTML_ELEMENT_NODE";
898
+ }
875
899
  static from(data) {
876
900
  return new HTMLElementNode({
877
901
  type: data.type,
@@ -941,6 +965,9 @@ class HTMLAttributeValueNode extends Node {
941
965
  children;
942
966
  close_quote;
943
967
  quoted;
968
+ static get type() {
969
+ return "AST_HTML_ATTRIBUTE_VALUE_NODE";
970
+ }
944
971
  static from(data) {
945
972
  return new HTMLAttributeValueNode({
946
973
  type: data.type,
@@ -999,6 +1026,9 @@ class HTMLAttributeValueNode extends Node {
999
1026
  }
1000
1027
  class HTMLAttributeNameNode extends Node {
1001
1028
  children;
1029
+ static get type() {
1030
+ return "AST_HTML_ATTRIBUTE_NAME_NODE";
1031
+ }
1002
1032
  static from(data) {
1003
1033
  return new HTMLAttributeNameNode({
1004
1034
  type: data.type,
@@ -1047,6 +1077,9 @@ class HTMLAttributeNode extends Node {
1047
1077
  name;
1048
1078
  equals;
1049
1079
  value;
1080
+ static get type() {
1081
+ return "AST_HTML_ATTRIBUTE_NODE";
1082
+ }
1050
1083
  static from(data) {
1051
1084
  return new HTMLAttributeNode({
1052
1085
  type: data.type,
@@ -1103,6 +1136,9 @@ class HTMLAttributeNode extends Node {
1103
1136
  }
1104
1137
  class HTMLTextNode extends Node {
1105
1138
  content;
1139
+ static get type() {
1140
+ return "AST_HTML_TEXT_NODE";
1141
+ }
1106
1142
  static from(data) {
1107
1143
  return new HTMLTextNode({
1108
1144
  type: data.type,
@@ -1148,6 +1184,9 @@ class HTMLCommentNode extends Node {
1148
1184
  comment_start;
1149
1185
  children;
1150
1186
  comment_end;
1187
+ static get type() {
1188
+ return "AST_HTML_COMMENT_NODE";
1189
+ }
1151
1190
  static from(data) {
1152
1191
  return new HTMLCommentNode({
1153
1192
  type: data.type,
@@ -1204,6 +1243,9 @@ class HTMLDoctypeNode extends Node {
1204
1243
  tag_opening;
1205
1244
  children;
1206
1245
  tag_closing;
1246
+ static get type() {
1247
+ return "AST_HTML_DOCTYPE_NODE";
1248
+ }
1207
1249
  static from(data) {
1208
1250
  return new HTMLDoctypeNode({
1209
1251
  type: data.type,
@@ -1260,6 +1302,9 @@ class XMLDeclarationNode extends Node {
1260
1302
  tag_opening;
1261
1303
  children;
1262
1304
  tag_closing;
1305
+ static get type() {
1306
+ return "AST_XML_DECLARATION_NODE";
1307
+ }
1263
1308
  static from(data) {
1264
1309
  return new XMLDeclarationNode({
1265
1310
  type: data.type,
@@ -1316,6 +1361,9 @@ class CDATANode extends Node {
1316
1361
  tag_opening;
1317
1362
  children;
1318
1363
  tag_closing;
1364
+ static get type() {
1365
+ return "AST_CDATA_NODE";
1366
+ }
1319
1367
  static from(data) {
1320
1368
  return new CDATANode({
1321
1369
  type: data.type,
@@ -1370,6 +1418,9 @@ class CDATANode extends Node {
1370
1418
  }
1371
1419
  class WhitespaceNode extends Node {
1372
1420
  value;
1421
+ static get type() {
1422
+ return "AST_WHITESPACE_NODE";
1423
+ }
1373
1424
  static from(data) {
1374
1425
  return new WhitespaceNode({
1375
1426
  type: data.type,
@@ -1418,6 +1469,9 @@ class ERBContentNode extends Node {
1418
1469
  // no-op for analyzed_ruby
1419
1470
  parsed;
1420
1471
  valid;
1472
+ static get type() {
1473
+ return "AST_ERB_CONTENT_NODE";
1474
+ }
1421
1475
  static from(data) {
1422
1476
  return new ERBContentNode({
1423
1477
  type: data.type,
@@ -1483,6 +1537,9 @@ class ERBEndNode extends Node {
1483
1537
  tag_opening;
1484
1538
  content;
1485
1539
  tag_closing;
1540
+ static get type() {
1541
+ return "AST_ERB_END_NODE";
1542
+ }
1486
1543
  static from(data) {
1487
1544
  return new ERBEndNode({
1488
1545
  type: data.type,
@@ -1537,6 +1594,9 @@ class ERBElseNode extends Node {
1537
1594
  content;
1538
1595
  tag_closing;
1539
1596
  statements;
1597
+ static get type() {
1598
+ return "AST_ERB_ELSE_NODE";
1599
+ }
1540
1600
  static from(data) {
1541
1601
  return new ERBElseNode({
1542
1602
  type: data.type,
@@ -1600,6 +1660,9 @@ class ERBIfNode extends Node {
1600
1660
  statements;
1601
1661
  subsequent;
1602
1662
  end_node;
1663
+ static get type() {
1664
+ return "AST_ERB_IF_NODE";
1665
+ }
1603
1666
  static from(data) {
1604
1667
  return new ERBIfNode({
1605
1668
  type: data.type,
@@ -1674,6 +1737,9 @@ class ERBBlockNode extends Node {
1674
1737
  tag_closing;
1675
1738
  body;
1676
1739
  end_node;
1740
+ static get type() {
1741
+ return "AST_ERB_BLOCK_NODE";
1742
+ }
1677
1743
  static from(data) {
1678
1744
  return new ERBBlockNode({
1679
1745
  type: data.type,
@@ -1741,6 +1807,9 @@ class ERBWhenNode extends Node {
1741
1807
  content;
1742
1808
  tag_closing;
1743
1809
  statements;
1810
+ static get type() {
1811
+ return "AST_ERB_WHEN_NODE";
1812
+ }
1744
1813
  static from(data) {
1745
1814
  return new ERBWhenNode({
1746
1815
  type: data.type,
@@ -1805,6 +1874,9 @@ class ERBCaseNode extends Node {
1805
1874
  conditions;
1806
1875
  else_clause;
1807
1876
  end_node;
1877
+ static get type() {
1878
+ return "AST_ERB_CASE_NODE";
1879
+ }
1808
1880
  static from(data) {
1809
1881
  return new ERBCaseNode({
1810
1882
  type: data.type,
@@ -1887,6 +1959,9 @@ class ERBCaseMatchNode extends Node {
1887
1959
  conditions;
1888
1960
  else_clause;
1889
1961
  end_node;
1962
+ static get type() {
1963
+ return "AST_ERB_CASE_MATCH_NODE";
1964
+ }
1890
1965
  static from(data) {
1891
1966
  return new ERBCaseMatchNode({
1892
1967
  type: data.type,
@@ -1967,6 +2042,9 @@ class ERBWhileNode extends Node {
1967
2042
  tag_closing;
1968
2043
  statements;
1969
2044
  end_node;
2045
+ static get type() {
2046
+ return "AST_ERB_WHILE_NODE";
2047
+ }
1970
2048
  static from(data) {
1971
2049
  return new ERBWhileNode({
1972
2050
  type: data.type,
@@ -2035,6 +2113,9 @@ class ERBUntilNode extends Node {
2035
2113
  tag_closing;
2036
2114
  statements;
2037
2115
  end_node;
2116
+ static get type() {
2117
+ return "AST_ERB_UNTIL_NODE";
2118
+ }
2038
2119
  static from(data) {
2039
2120
  return new ERBUntilNode({
2040
2121
  type: data.type,
@@ -2103,6 +2184,9 @@ class ERBForNode extends Node {
2103
2184
  tag_closing;
2104
2185
  statements;
2105
2186
  end_node;
2187
+ static get type() {
2188
+ return "AST_ERB_FOR_NODE";
2189
+ }
2106
2190
  static from(data) {
2107
2191
  return new ERBForNode({
2108
2192
  type: data.type,
@@ -2171,6 +2255,9 @@ class ERBRescueNode extends Node {
2171
2255
  tag_closing;
2172
2256
  statements;
2173
2257
  subsequent;
2258
+ static get type() {
2259
+ return "AST_ERB_RESCUE_NODE";
2260
+ }
2174
2261
  static from(data) {
2175
2262
  return new ERBRescueNode({
2176
2263
  type: data.type,
@@ -2238,6 +2325,9 @@ class ERBEnsureNode extends Node {
2238
2325
  content;
2239
2326
  tag_closing;
2240
2327
  statements;
2328
+ static get type() {
2329
+ return "AST_ERB_ENSURE_NODE";
2330
+ }
2241
2331
  static from(data) {
2242
2332
  return new ERBEnsureNode({
2243
2333
  type: data.type,
@@ -2303,6 +2393,9 @@ class ERBBeginNode extends Node {
2303
2393
  else_clause;
2304
2394
  ensure_clause;
2305
2395
  end_node;
2396
+ static get type() {
2397
+ return "AST_ERB_BEGIN_NODE";
2398
+ }
2306
2399
  static from(data) {
2307
2400
  return new ERBBeginNode({
2308
2401
  type: data.type,
@@ -2390,6 +2483,9 @@ class ERBUnlessNode extends Node {
2390
2483
  statements;
2391
2484
  else_clause;
2392
2485
  end_node;
2486
+ static get type() {
2487
+ return "AST_ERB_UNLESS_NODE";
2488
+ }
2393
2489
  static from(data) {
2394
2490
  return new ERBUnlessNode({
2395
2491
  type: data.type,
@@ -2462,6 +2558,9 @@ class ERBYieldNode extends Node {
2462
2558
  tag_opening;
2463
2559
  content;
2464
2560
  tag_closing;
2561
+ static get type() {
2562
+ return "AST_ERB_YIELD_NODE";
2563
+ }
2465
2564
  static from(data) {
2466
2565
  return new ERBYieldNode({
2467
2566
  type: data.type,
@@ -2516,6 +2615,9 @@ class ERBInNode extends Node {
2516
2615
  content;
2517
2616
  tag_closing;
2518
2617
  statements;
2618
+ static get type() {
2619
+ return "AST_ERB_IN_NODE";
2620
+ }
2519
2621
  static from(data) {
2520
2622
  return new ERBInNode({
2521
2623
  type: data.type,
@@ -2734,7 +2836,7 @@ class ParseResult extends Result {
2734
2836
  }
2735
2837
 
2736
2838
  // NOTE: This file is generated by the templates/template.rb script and should not
2737
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/node-type-guards.ts.erb
2839
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/node-type-guards.ts.erb
2738
2840
  /**
2739
2841
  * Type guard functions for AST nodes.
2740
2842
  * These functions provide type checking by combining both instanceof
@@ -2745,187 +2847,187 @@ class ParseResult extends Result {
2745
2847
  * Checks if a node is a DocumentNode
2746
2848
  */
2747
2849
  function isDocumentNode(node) {
2748
- return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE";
2850
+ return node instanceof DocumentNode || node.type === "AST_DOCUMENT_NODE" || node.constructor.type === "AST_DOCUMENT_NODE";
2749
2851
  }
2750
2852
  /**
2751
2853
  * Checks if a node is a LiteralNode
2752
2854
  */
2753
2855
  function isLiteralNode(node) {
2754
- return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE";
2856
+ return node instanceof LiteralNode || node.type === "AST_LITERAL_NODE" || node.constructor.type === "AST_LITERAL_NODE";
2755
2857
  }
2756
2858
  /**
2757
2859
  * Checks if a node is a HTMLOpenTagNode
2758
2860
  */
2759
2861
  function isHTMLOpenTagNode(node) {
2760
- return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE";
2862
+ return node instanceof HTMLOpenTagNode || node.type === "AST_HTML_OPEN_TAG_NODE" || node.constructor.type === "AST_HTML_OPEN_TAG_NODE";
2761
2863
  }
2762
2864
  /**
2763
2865
  * Checks if a node is a HTMLCloseTagNode
2764
2866
  */
2765
2867
  function isHTMLCloseTagNode(node) {
2766
- return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE";
2868
+ return node instanceof HTMLCloseTagNode || node.type === "AST_HTML_CLOSE_TAG_NODE" || node.constructor.type === "AST_HTML_CLOSE_TAG_NODE";
2767
2869
  }
2768
2870
  /**
2769
2871
  * Checks if a node is a HTMLElementNode
2770
2872
  */
2771
2873
  function isHTMLElementNode(node) {
2772
- return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE";
2874
+ return node instanceof HTMLElementNode || node.type === "AST_HTML_ELEMENT_NODE" || node.constructor.type === "AST_HTML_ELEMENT_NODE";
2773
2875
  }
2774
2876
  /**
2775
2877
  * Checks if a node is a HTMLAttributeValueNode
2776
2878
  */
2777
2879
  function isHTMLAttributeValueNode(node) {
2778
- return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE";
2880
+ return node instanceof HTMLAttributeValueNode || node.type === "AST_HTML_ATTRIBUTE_VALUE_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_VALUE_NODE";
2779
2881
  }
2780
2882
  /**
2781
2883
  * Checks if a node is a HTMLAttributeNameNode
2782
2884
  */
2783
2885
  function isHTMLAttributeNameNode(node) {
2784
- return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE";
2886
+ return node instanceof HTMLAttributeNameNode || node.type === "AST_HTML_ATTRIBUTE_NAME_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_NAME_NODE";
2785
2887
  }
2786
2888
  /**
2787
2889
  * Checks if a node is a HTMLAttributeNode
2788
2890
  */
2789
2891
  function isHTMLAttributeNode(node) {
2790
- return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE";
2892
+ return node instanceof HTMLAttributeNode || node.type === "AST_HTML_ATTRIBUTE_NODE" || node.constructor.type === "AST_HTML_ATTRIBUTE_NODE";
2791
2893
  }
2792
2894
  /**
2793
2895
  * Checks if a node is a HTMLTextNode
2794
2896
  */
2795
2897
  function isHTMLTextNode(node) {
2796
- return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE";
2898
+ return node instanceof HTMLTextNode || node.type === "AST_HTML_TEXT_NODE" || node.constructor.type === "AST_HTML_TEXT_NODE";
2797
2899
  }
2798
2900
  /**
2799
2901
  * Checks if a node is a HTMLCommentNode
2800
2902
  */
2801
2903
  function isHTMLCommentNode(node) {
2802
- return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE";
2904
+ return node instanceof HTMLCommentNode || node.type === "AST_HTML_COMMENT_NODE" || node.constructor.type === "AST_HTML_COMMENT_NODE";
2803
2905
  }
2804
2906
  /**
2805
2907
  * Checks if a node is a HTMLDoctypeNode
2806
2908
  */
2807
2909
  function isHTMLDoctypeNode(node) {
2808
- return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE";
2910
+ return node instanceof HTMLDoctypeNode || node.type === "AST_HTML_DOCTYPE_NODE" || node.constructor.type === "AST_HTML_DOCTYPE_NODE";
2809
2911
  }
2810
2912
  /**
2811
2913
  * Checks if a node is a XMLDeclarationNode
2812
2914
  */
2813
2915
  function isXMLDeclarationNode(node) {
2814
- return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE";
2916
+ return node instanceof XMLDeclarationNode || node.type === "AST_XML_DECLARATION_NODE" || node.constructor.type === "AST_XML_DECLARATION_NODE";
2815
2917
  }
2816
2918
  /**
2817
2919
  * Checks if a node is a CDATANode
2818
2920
  */
2819
2921
  function isCDATANode(node) {
2820
- return node instanceof CDATANode || node.type === "AST_CDATA_NODE";
2922
+ return node instanceof CDATANode || node.type === "AST_CDATA_NODE" || node.constructor.type === "AST_CDATA_NODE";
2821
2923
  }
2822
2924
  /**
2823
2925
  * Checks if a node is a WhitespaceNode
2824
2926
  */
2825
2927
  function isWhitespaceNode(node) {
2826
- return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE";
2928
+ return node instanceof WhitespaceNode || node.type === "AST_WHITESPACE_NODE" || node.constructor.type === "AST_WHITESPACE_NODE";
2827
2929
  }
2828
2930
  /**
2829
2931
  * Checks if a node is a ERBContentNode
2830
2932
  */
2831
2933
  function isERBContentNode(node) {
2832
- return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE";
2934
+ return node instanceof ERBContentNode || node.type === "AST_ERB_CONTENT_NODE" || node.constructor.type === "AST_ERB_CONTENT_NODE";
2833
2935
  }
2834
2936
  /**
2835
2937
  * Checks if a node is a ERBEndNode
2836
2938
  */
2837
2939
  function isERBEndNode(node) {
2838
- return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE";
2940
+ return node instanceof ERBEndNode || node.type === "AST_ERB_END_NODE" || node.constructor.type === "AST_ERB_END_NODE";
2839
2941
  }
2840
2942
  /**
2841
2943
  * Checks if a node is a ERBElseNode
2842
2944
  */
2843
2945
  function isERBElseNode(node) {
2844
- return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE";
2946
+ return node instanceof ERBElseNode || node.type === "AST_ERB_ELSE_NODE" || node.constructor.type === "AST_ERB_ELSE_NODE";
2845
2947
  }
2846
2948
  /**
2847
2949
  * Checks if a node is a ERBIfNode
2848
2950
  */
2849
2951
  function isERBIfNode(node) {
2850
- return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE";
2952
+ return node instanceof ERBIfNode || node.type === "AST_ERB_IF_NODE" || node.constructor.type === "AST_ERB_IF_NODE";
2851
2953
  }
2852
2954
  /**
2853
2955
  * Checks if a node is a ERBBlockNode
2854
2956
  */
2855
2957
  function isERBBlockNode(node) {
2856
- return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE";
2958
+ return node instanceof ERBBlockNode || node.type === "AST_ERB_BLOCK_NODE" || node.constructor.type === "AST_ERB_BLOCK_NODE";
2857
2959
  }
2858
2960
  /**
2859
2961
  * Checks if a node is a ERBWhenNode
2860
2962
  */
2861
2963
  function isERBWhenNode(node) {
2862
- return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE";
2964
+ return node instanceof ERBWhenNode || node.type === "AST_ERB_WHEN_NODE" || node.constructor.type === "AST_ERB_WHEN_NODE";
2863
2965
  }
2864
2966
  /**
2865
2967
  * Checks if a node is a ERBCaseNode
2866
2968
  */
2867
2969
  function isERBCaseNode(node) {
2868
- return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE";
2970
+ return node instanceof ERBCaseNode || node.type === "AST_ERB_CASE_NODE" || node.constructor.type === "AST_ERB_CASE_NODE";
2869
2971
  }
2870
2972
  /**
2871
2973
  * Checks if a node is a ERBCaseMatchNode
2872
2974
  */
2873
2975
  function isERBCaseMatchNode(node) {
2874
- return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE";
2976
+ return node instanceof ERBCaseMatchNode || node.type === "AST_ERB_CASE_MATCH_NODE" || node.constructor.type === "AST_ERB_CASE_MATCH_NODE";
2875
2977
  }
2876
2978
  /**
2877
2979
  * Checks if a node is a ERBWhileNode
2878
2980
  */
2879
2981
  function isERBWhileNode(node) {
2880
- return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE";
2982
+ return node instanceof ERBWhileNode || node.type === "AST_ERB_WHILE_NODE" || node.constructor.type === "AST_ERB_WHILE_NODE";
2881
2983
  }
2882
2984
  /**
2883
2985
  * Checks if a node is a ERBUntilNode
2884
2986
  */
2885
2987
  function isERBUntilNode(node) {
2886
- return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE";
2988
+ return node instanceof ERBUntilNode || node.type === "AST_ERB_UNTIL_NODE" || node.constructor.type === "AST_ERB_UNTIL_NODE";
2887
2989
  }
2888
2990
  /**
2889
2991
  * Checks if a node is a ERBForNode
2890
2992
  */
2891
2993
  function isERBForNode(node) {
2892
- return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE";
2994
+ return node instanceof ERBForNode || node.type === "AST_ERB_FOR_NODE" || node.constructor.type === "AST_ERB_FOR_NODE";
2893
2995
  }
2894
2996
  /**
2895
2997
  * Checks if a node is a ERBRescueNode
2896
2998
  */
2897
2999
  function isERBRescueNode(node) {
2898
- return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE";
3000
+ return node instanceof ERBRescueNode || node.type === "AST_ERB_RESCUE_NODE" || node.constructor.type === "AST_ERB_RESCUE_NODE";
2899
3001
  }
2900
3002
  /**
2901
3003
  * Checks if a node is a ERBEnsureNode
2902
3004
  */
2903
3005
  function isERBEnsureNode(node) {
2904
- return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE";
3006
+ return node instanceof ERBEnsureNode || node.type === "AST_ERB_ENSURE_NODE" || node.constructor.type === "AST_ERB_ENSURE_NODE";
2905
3007
  }
2906
3008
  /**
2907
3009
  * Checks if a node is a ERBBeginNode
2908
3010
  */
2909
3011
  function isERBBeginNode(node) {
2910
- return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE";
3012
+ return node instanceof ERBBeginNode || node.type === "AST_ERB_BEGIN_NODE" || node.constructor.type === "AST_ERB_BEGIN_NODE";
2911
3013
  }
2912
3014
  /**
2913
3015
  * Checks if a node is a ERBUnlessNode
2914
3016
  */
2915
3017
  function isERBUnlessNode(node) {
2916
- return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE";
3018
+ return node instanceof ERBUnlessNode || node.type === "AST_ERB_UNLESS_NODE" || node.constructor.type === "AST_ERB_UNLESS_NODE";
2917
3019
  }
2918
3020
  /**
2919
3021
  * Checks if a node is a ERBYieldNode
2920
3022
  */
2921
3023
  function isERBYieldNode(node) {
2922
- return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE";
3024
+ return node instanceof ERBYieldNode || node.type === "AST_ERB_YIELD_NODE" || node.constructor.type === "AST_ERB_YIELD_NODE";
2923
3025
  }
2924
3026
  /**
2925
3027
  * Checks if a node is a ERBInNode
2926
3028
  */
2927
3029
  function isERBInNode(node) {
2928
- return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE";
3030
+ return node instanceof ERBInNode || node.type === "AST_ERB_IN_NODE" || node.constructor.type === "AST_ERB_IN_NODE";
2929
3031
  }
2930
3032
  /**
2931
3033
  * Convenience type guards for common node categories
@@ -3114,6 +3216,8 @@ function filterNodes(nodes, ...types) {
3114
3216
  return nodes.filter(node => isAnyOf(node, ...types));
3115
3217
  }
3116
3218
  function isNode(node, type) {
3219
+ if (!node)
3220
+ return false;
3117
3221
  if (typeof type === 'string') {
3118
3222
  const guard = AST_TYPE_GUARDS.get(type);
3119
3223
  return guard ? guard(node) : false;
@@ -3489,6 +3593,87 @@ function getTagName(node) {
3489
3593
  function isCommentNode(node) {
3490
3594
  return isNode(node, HTMLCommentNode) || (isERBNode(node) && !isERBControlFlowNode(node));
3491
3595
  }
3596
+ /**
3597
+ * Compares two positions to determine if the first comes before the second
3598
+ * Returns true if pos1 comes before pos2 in source order
3599
+ * @param inclusive - If true, returns true when positions are equal
3600
+ */
3601
+ function isPositionBefore(position1, position2, inclusive = false) {
3602
+ if (position1.line < position2.line)
3603
+ return true;
3604
+ if (position1.line > position2.line)
3605
+ return false;
3606
+ return inclusive ? position1.column <= position2.column : position1.column < position2.column;
3607
+ }
3608
+ /**
3609
+ * Compares two positions to determine if they are equal
3610
+ * Returns true if pos1 and pos2 are at the same location
3611
+ */
3612
+ function isPositionEqual(position1, position2) {
3613
+ return position1.line === position2.line && position1.column === position2.column;
3614
+ }
3615
+ /**
3616
+ * Compares two positions to determine if the first comes after the second
3617
+ * Returns true if pos1 comes after pos2 in source order
3618
+ * @param inclusive - If true, returns true when positions are equal
3619
+ */
3620
+ function isPositionAfter(position1, position2, inclusive = false) {
3621
+ if (position1.line > position2.line)
3622
+ return true;
3623
+ if (position1.line < position2.line)
3624
+ return false;
3625
+ return inclusive ? position1.column >= position2.column : position1.column > position2.column;
3626
+ }
3627
+ /**
3628
+ * Gets nodes that appear before the specified location in source order
3629
+ * Uses line and column positions to determine ordering
3630
+ */
3631
+ function getNodesBeforeLocation(nodes, location) {
3632
+ return nodes.filter(node => node.location && isPositionBefore(node.location.end, location.start));
3633
+ }
3634
+ /**
3635
+ * Gets nodes that appear after the specified location in source order
3636
+ * Uses line and column positions to determine ordering
3637
+ */
3638
+ function getNodesAfterLocation(nodes, location) {
3639
+ return nodes.filter(node => node.location && isPositionAfter(node.location.start, location.end));
3640
+ }
3641
+ /**
3642
+ * Splits nodes into before and after the specified location
3643
+ * Returns an object with `before` and `after` arrays
3644
+ */
3645
+ function splitNodesAroundLocation(nodes, location) {
3646
+ return {
3647
+ before: getNodesBeforeLocation(nodes, location),
3648
+ after: getNodesAfterLocation(nodes, location)
3649
+ };
3650
+ }
3651
+ /**
3652
+ * Splits nodes at a specific position
3653
+ * Returns nodes that end before the position and nodes that start after the position
3654
+ * More precise than splitNodesAroundLocation as it uses a single position point
3655
+ * Uses the same defaults as the individual functions: before=exclusive, after=inclusive
3656
+ */
3657
+ function splitNodesAroundPosition(nodes, position) {
3658
+ return {
3659
+ before: getNodesBeforePosition(nodes, position), // uses default: inclusive = false
3660
+ after: getNodesAfterPosition(nodes, position) // uses default: inclusive = true
3661
+ };
3662
+ }
3663
+ /**
3664
+ * Gets nodes that end before the specified position
3665
+ * @param inclusive - If true, includes nodes that end exactly at the position (default: false, matching half-open interval semantics)
3666
+ */
3667
+ function getNodesBeforePosition(nodes, position, inclusive = false) {
3668
+ return nodes.filter(node => node.location && isPositionBefore(node.location.end, position, inclusive));
3669
+ }
3670
+ /**
3671
+ * Gets nodes that start after the specified position
3672
+ * @param inclusive - If true, includes nodes that start exactly at the position (default: true, matching typical boundary behavior)
3673
+ */
3674
+ function getNodesAfterPosition(nodes, position, inclusive = true) {
3675
+ return nodes.filter(node => node.location && isPositionAfter(node.location.start, position, inclusive));
3676
+ }
3492
3677
 
3493
3678
  const expectedFunctions = [
3494
3679
  "parse",
@@ -3541,7 +3726,7 @@ function toMonacoDiagnostic(diagnostic) {
3541
3726
  }
3542
3727
 
3543
3728
  var name = "@herb-tools/core";
3544
- var version = "0.6.0";
3729
+ var version = "0.6.1";
3545
3730
  var packageJSON = {
3546
3731
  name: name,
3547
3732
  version: version};
@@ -3764,7 +3949,7 @@ class HerbBackend {
3764
3949
  }
3765
3950
 
3766
3951
  // NOTE: This file is generated by the templates/template.rb script and should not
3767
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.0/templates/javascript/packages/core/src/visitor.ts.erb
3952
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.6.1/templates/javascript/packages/core/src/visitor.ts.erb
3768
3953
  class Visitor {
3769
3954
  visit(node) {
3770
3955
  if (!node)
@@ -3970,6 +4155,10 @@ exports.fromSerializedError = fromSerializedError;
3970
4155
  exports.fromSerializedNode = fromSerializedNode;
3971
4156
  exports.getCombinedAttributeName = getCombinedAttributeName;
3972
4157
  exports.getCombinedStringFromNodes = getCombinedStringFromNodes;
4158
+ exports.getNodesAfterLocation = getNodesAfterLocation;
4159
+ exports.getNodesAfterPosition = getNodesAfterPosition;
4160
+ exports.getNodesBeforeLocation = getNodesBeforeLocation;
4161
+ exports.getNodesBeforePosition = getNodesBeforePosition;
3973
4162
  exports.getStaticAttributeName = getStaticAttributeName;
3974
4163
  exports.getStaticContentFromNodes = getStaticContentFromNodes;
3975
4164
  exports.getStaticStringFromNodes = getStaticStringFromNodes;
@@ -4021,8 +4210,12 @@ exports.isLiteralNode = isLiteralNode;
4021
4210
  exports.isNode = isNode;
4022
4211
  exports.isNoneOf = isNoneOf;
4023
4212
  exports.isParseResult = isParseResult;
4213
+ exports.isPositionAfter = isPositionAfter;
4214
+ exports.isPositionEqual = isPositionEqual;
4024
4215
  exports.isToken = isToken;
4025
4216
  exports.isWhitespaceNode = isWhitespaceNode;
4026
4217
  exports.isXMLDeclarationNode = isXMLDeclarationNode;
4218
+ exports.splitNodesAroundLocation = splitNodesAroundLocation;
4219
+ exports.splitNodesAroundPosition = splitNodesAroundPosition;
4027
4220
  exports.toMonacoDiagnostic = toMonacoDiagnostic;
4028
4221
  //# sourceMappingURL=herb-core.cjs.map