skippableTokenAwareRuleWalker.js 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var ruleWalker_1 = require("./ruleWalker");
  8. var SkippableTokenAwareRuleWalker = (function (_super) {
  9. __extends(SkippableTokenAwareRuleWalker, _super);
  10. function SkippableTokenAwareRuleWalker(sourceFile, options) {
  11. _super.call(this, sourceFile, options);
  12. this.tokensToSkipStartEndMap = {};
  13. }
  14. SkippableTokenAwareRuleWalker.prototype.visitRegularExpressionLiteral = function (node) {
  15. this.addTokenToSkipFromNode(node);
  16. _super.prototype.visitRegularExpressionLiteral.call(this, node);
  17. };
  18. SkippableTokenAwareRuleWalker.prototype.visitIdentifier = function (node) {
  19. this.addTokenToSkipFromNode(node);
  20. _super.prototype.visitIdentifier.call(this, node);
  21. };
  22. SkippableTokenAwareRuleWalker.prototype.visitTemplateExpression = function (node) {
  23. this.addTokenToSkipFromNode(node);
  24. _super.prototype.visitTemplateExpression.call(this, node);
  25. };
  26. SkippableTokenAwareRuleWalker.prototype.addTokenToSkipFromNode = function (node) {
  27. if (node.getStart() < node.getEnd()) {
  28. this.tokensToSkipStartEndMap[node.getStart()] = node.getEnd();
  29. }
  30. };
  31. return SkippableTokenAwareRuleWalker;
  32. }(ruleWalker_1.RuleWalker));
  33. exports.SkippableTokenAwareRuleWalker = SkippableTokenAwareRuleWalker;