text: // LICENSE : MIT
  "use strict";
  var __extends = (this && this.__extends) || (function () {
      var extendStatics = function (d, b) {
          extendStatics = Object.setPrototypeOf ||
              ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
              function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
          return extendStatics(d, b);
      };
      return function (d, b) {
          extendStatics(d, b);
          function __() { this.constructor = d; }
          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
  })();
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var textlint_core_task_1 = __importDefault(require("./textlint-core-task"));
  var rule_severity_1 = require("../shared/rule-severity");
  var TextlintRuleContextImpl_1 = require("../context/TextlintRuleContextImpl");
  var TextlintFilterRuleContextImpl_1 = require("../context/TextlintFilterRuleContextImpl");
  var TextLintCoreTask = /** @class */ (function (_super) {
      __extends(TextLintCoreTask, _super);
      function TextLintCoreTask(_a) {
          var config = _a.config, configBaseDir = _a.configBaseDir, ruleDescriptors = _a.ruleDescriptors, filterRuleDescriptors = _a.filterRuleDescriptors, sourceCode = _a.sourceCode;
          var _this = _super.call(this) || this;
          _this.config = config;
          _this.configBaseDir = configBaseDir;
          _this.ruleDescriptors = ruleDescriptors;
          _this.filterRuleDescriptors = filterRuleDescriptors;
          _this.sourceCode = sourceCode;
          _this._setupRules();
          return _this;
      }
      TextLintCoreTask.prototype.start = function () {
          this.startTraverser(this.sourceCode);
      };
      TextLintCoreTask.prototype._setupRules = function () {
          var _this = this;
          // rule
          var sourceCode = this.sourceCode;
          var report = this.createReporter(sourceCode);
          var ignoreReport = this.createShouldIgnore();
          // setup "rules" field
          // filter duplicated rules for improving experience
          // see https://github.com/textlint/textlint/issues/219
          this.ruleDescriptors.lintableDescriptors.forEach(function (ruleDescriptor) {
              var ruleOptions = ruleDescriptor.normalizedOptions;
              var ruleContext = new TextlintRuleContextImpl_1.TextlintRuleContextImpl({
                  ruleId: ruleDescriptor.id,
                  severityLevel: rule_severity_1.getSeverity(ruleOptions),
                  sourceCode: sourceCode,
                  report: report,
                  configBaseDir: _this.configBaseDir
              });
              _this.tryToAddListenRule(ruleDescriptor.linter, ruleContext, ruleOptions);
          });
          // setup "filters" field
          this.filterRuleDescriptors.descriptors.forEach(function (filterDescriptor) {
              var ruleContext = new TextlintFilterRuleContextImpl_1.TextlintFilterRuleContextImpl({
                  ruleId: filterDescriptor.id,
                  sourceCode: sourceCode,
                  ignoreReport: ignoreReport,
                  configBaseDir: _this.configBaseDir,
                  severityLevel: rule_severity_1.getSeverity(filterDescriptor.normalizedOptions)
              });
              _this.tryToAddListenRule(filterDescriptor.filter, ruleContext, filterDescriptor.normalizedOptions);
          });
      };
      return TextLintCoreTask;
  }(textlint_core_task_1.default));
  exports.default = TextLintCoreTask;
  //# sourceMappingURL=linter-task.js.map