clarity-pattern-parser 11.5.0 → 11.5.2
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.
- package/dist/index.browser.js +11 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +11 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/patterns/Expression.d.ts +1 -0
- package/package.json +1 -1
- package/src/patterns/Expression.ts +12 -5
package/dist/index.js
CHANGED
|
@@ -2901,6 +2901,7 @@ class Expression {
|
|
|
2901
2901
|
this._name = name;
|
|
2902
2902
|
this._originalName = name;
|
|
2903
2903
|
this._parent = null;
|
|
2904
|
+
this._cachedParent = null;
|
|
2904
2905
|
this._firstIndex = 0;
|
|
2905
2906
|
this._atomPatterns = [];
|
|
2906
2907
|
this._prefixPatterns = [];
|
|
@@ -3051,7 +3052,8 @@ class Expression {
|
|
|
3051
3052
|
return pattern.name === this._originalName;
|
|
3052
3053
|
}
|
|
3053
3054
|
build() {
|
|
3054
|
-
if (!this._hasOrganized) {
|
|
3055
|
+
if (!this._hasOrganized || this._cachedParent !== this.parent) {
|
|
3056
|
+
this._cachedParent = this.parent;
|
|
3055
3057
|
this._hasOrganized = true;
|
|
3056
3058
|
this._organizePatterns(this._originalPatterns);
|
|
3057
3059
|
this._cacheAncestors();
|
|
@@ -3222,18 +3224,20 @@ class Expression {
|
|
|
3222
3224
|
return execPattern(this, text, record);
|
|
3223
3225
|
}
|
|
3224
3226
|
getTokens() {
|
|
3227
|
+
this.build();
|
|
3225
3228
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3226
3229
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3227
3230
|
return [...prefixTokens, ...atomTokens];
|
|
3228
3231
|
}
|
|
3229
3232
|
getTokensAfter(childReference) {
|
|
3233
|
+
this.build();
|
|
3230
3234
|
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3231
3235
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3232
3236
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3233
3237
|
return [...prefixTokens, ...atomTokens];
|
|
3234
3238
|
}
|
|
3235
3239
|
if (this._atomPatterns.includes(childReference)) {
|
|
3236
|
-
const postfixTokens = this.
|
|
3240
|
+
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3237
3241
|
if (postfixTokens.length === 0) {
|
|
3238
3242
|
return this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3239
3243
|
}
|
|
@@ -3253,27 +3257,29 @@ class Expression {
|
|
|
3253
3257
|
return this._parent.getTokensAfter(this);
|
|
3254
3258
|
}
|
|
3255
3259
|
getPatterns() {
|
|
3260
|
+
this.build();
|
|
3256
3261
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3257
3262
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3258
3263
|
return [...prefixPatterns, ...atomPatterns];
|
|
3259
3264
|
}
|
|
3260
3265
|
getPatternsAfter(childReference) {
|
|
3266
|
+
this.build();
|
|
3261
3267
|
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3262
3268
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3263
3269
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3264
3270
|
return [...prefixPatterns, ...atomPatterns];
|
|
3265
3271
|
}
|
|
3266
3272
|
if (this._atomPatterns.includes(childReference)) {
|
|
3267
|
-
const postfixPatterns = this.
|
|
3273
|
+
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3268
3274
|
if (postfixPatterns.length === 0) {
|
|
3269
3275
|
return this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3270
3276
|
}
|
|
3271
3277
|
return postfixPatterns;
|
|
3272
3278
|
}
|
|
3273
3279
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3274
|
-
const
|
|
3280
|
+
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3275
3281
|
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3276
|
-
return [...
|
|
3282
|
+
return [...postfixPatterns, ...binaryPatterns];
|
|
3277
3283
|
}
|
|
3278
3284
|
return [];
|
|
3279
3285
|
}
|