context.js 583 B

1234567891011121314151617181920
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Context = void 0;
  4. const lines_and_columns_1 = require("lines-and-columns");
  5. class Context {
  6. constructor(text) {
  7. this.text = text;
  8. this.locator = new Locator(this.text);
  9. }
  10. }
  11. exports.Context = Context;
  12. class Locator {
  13. constructor(text) {
  14. this._lineAndColumn = new lines_and_columns_1.default(text);
  15. }
  16. locationForIndex(index) {
  17. const { line, column } = this._lineAndColumn.locationForIndex(index);
  18. return { line: line + 1, column };
  19. }
  20. }