clarity-pattern-parser 10.0.8 → 10.1.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.
@@ -97,10 +97,28 @@ export class Reference implements Pattern {
97
97
  }
98
98
 
99
99
  private _findPattern(): Pattern | null {
100
- const root = this._getRoot();
100
+ let pattern = this._parent;
101
+
102
+ while (pattern != null) {
103
+ if (pattern.type !== "context") {
104
+ pattern = pattern.parent;
105
+ continue;
106
+ }
101
107
 
108
+ const foundPattern = findPattern(pattern, (pattern: Pattern) => {
109
+ return pattern.name === this._name && pattern.type !== "reference" && pattern.type !== "context";
110
+ });
111
+
112
+ if (foundPattern != null) {
113
+ return foundPattern;
114
+ }
115
+
116
+ pattern = pattern.parent;
117
+ }
118
+
119
+ const root = this._getRoot();
102
120
  return findPattern(root, (pattern: Pattern) => {
103
- return pattern.name === this._name && pattern.type !== "reference";
121
+ return pattern.name === this._name && pattern.type !== "reference" && pattern.type !== "context";
104
122
  });
105
123
  }
106
124