clarity-pattern-parser 10.1.20 → 10.1.21

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.
@@ -1050,8 +1050,11 @@
1050
1050
  }
1051
1051
  getTokens() {
1052
1052
  const tokens = [];
1053
- for (const child of this._children) {
1054
- tokens.push(...child.getTokens());
1053
+ for (const pattern of this._children) {
1054
+ if (pattern.type === "reference" && pattern.name === this.name) {
1055
+ continue;
1056
+ }
1057
+ tokens.push(...pattern.getTokens());
1055
1058
  }
1056
1059
  return tokens;
1057
1060
  }
@@ -1070,6 +1073,9 @@
1070
1073
  getPatterns() {
1071
1074
  const patterns = [];
1072
1075
  for (const pattern of this._children) {
1076
+ if (pattern.type === "reference" && pattern.name === this.name) {
1077
+ continue;
1078
+ }
1073
1079
  patterns.push(...pattern.getPatterns());
1074
1080
  }
1075
1081
  return patterns;
@@ -1797,9 +1803,12 @@
1797
1803
  }
1798
1804
  getTokens() {
1799
1805
  const tokens = [];
1800
- for (const child of this._children) {
1801
- tokens.push(...child.getTokens());
1802
- if (child.type !== "optional" && child.type !== "not") {
1806
+ for (const pattern of this._children) {
1807
+ if (pattern.type === "reference" && pattern.name === this.name && pattern === this.children[0]) {
1808
+ return tokens;
1809
+ }
1810
+ tokens.push(...pattern.getTokens());
1811
+ if (pattern.type !== "optional" && pattern.type !== "not") {
1803
1812
  break;
1804
1813
  }
1805
1814
  }
@@ -1819,9 +1828,12 @@
1819
1828
  }
1820
1829
  getPatterns() {
1821
1830
  const patterns = [];
1822
- for (const child of this._children) {
1823
- patterns.push(...child.getPatterns());
1824
- if (child.type !== "optional" && child.type !== "not") {
1831
+ for (const pattern of this._children) {
1832
+ if (pattern.type === "reference" && pattern.name === this.name && pattern === this.children[0]) {
1833
+ return patterns;
1834
+ }
1835
+ patterns.push(...pattern.getPatterns());
1836
+ if (pattern.type !== "optional" && pattern.type !== "not") {
1825
1837
  break;
1826
1838
  }
1827
1839
  }