clarity-pattern-parser 11.0.14 → 11.0.16

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.
@@ -861,18 +861,19 @@
861
861
  }
862
862
  parse(cursor) {
863
863
  this._firstIndex = cursor.index;
864
- this._cacheAncestors();
864
+ const pattern = this.getReferencePatternSafely();
865
+ this._cacheAncestors(pattern.id);
865
866
  if (this._isBeyondRecursiveAllowance()) {
866
867
  cursor.recordErrorAt(this._firstIndex, this._firstIndex, this);
867
868
  return null;
868
869
  }
869
- return this.getReferencePatternSafely().parse(cursor);
870
+ return pattern.parse(cursor);
870
871
  }
871
- _cacheAncestors() {
872
+ _cacheAncestors(id) {
872
873
  if (!this._cachedAncestors) {
873
874
  let pattern = this.parent;
874
875
  while (pattern != null) {
875
- if (pattern.type === this.type && pattern.id === this._id) {
876
+ if (pattern.id === id) {
876
877
  this._recursiveAncestors.push(pattern);
877
878
  }
878
879
  pattern = pattern.parent;
@@ -884,7 +885,7 @@
884
885
  for (let pattern of this._recursiveAncestors) {
885
886
  if (pattern._firstIndex === this._firstIndex) {
886
887
  depth++;
887
- if (depth > 2) {
888
+ if (depth > 1) {
888
889
  return true;
889
890
  }
890
891
  }