clarity-pattern-parser 10.1.6 → 10.1.8

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.
@@ -848,16 +848,25 @@
848
848
  continue;
849
849
  }
850
850
  const foundPattern = pattern.getPatternWithinContext(this.name);
851
- if (foundPattern != null && foundPattern.type !== "reference") {
851
+ if (foundPattern != null && this._isValidPattern(foundPattern)) {
852
852
  return foundPattern;
853
853
  }
854
854
  pattern = pattern.parent;
855
855
  }
856
856
  const root = this._getRoot();
857
857
  return findPattern(root, (pattern) => {
858
- return pattern.name === this._name && pattern.type !== "reference";
858
+ return pattern.name === this._name && this._isValidPattern(pattern);
859
859
  });
860
860
  }
861
+ _isValidPattern(pattern) {
862
+ if (pattern.type === "reference") {
863
+ return false;
864
+ }
865
+ if (pattern.type === "context" && pattern.children[0].type === "reference") {
866
+ return false;
867
+ }
868
+ return true;
869
+ }
861
870
  _getRoot() {
862
871
  let node = this;
863
872
  while (true) {
@@ -2626,12 +2635,6 @@
2626
2635
  this._parseContext = new ParseContext(this._params);
2627
2636
  this._autoComplete = new AutoComplete(grammar, {
2628
2637
  greedyPatternNames: ["spaces", "optional-spaces", "whitespace", "new-line"],
2629
- customTokens: {
2630
- "regex-literal": ["[Regular Expression]"],
2631
- "literal": ["[String]"],
2632
- "name": ["[Pattern Name]"],
2633
- "pattern-name": ["[Pattern Name]"]
2634
- }
2635
2638
  });
2636
2639
  }
2637
2640
  import(path) {