source: imaps-frontend/node_modules/eslint/lib/source-code/token-store/padded-token-cursor.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @fileoverview Define the cursor which iterates tokens only, with inflated range.
3 * @author Toru Nagashima
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Requirements
9//------------------------------------------------------------------------------
10
11const ForwardTokenCursor = require("./forward-token-cursor");
12
13//------------------------------------------------------------------------------
14// Exports
15//------------------------------------------------------------------------------
16
17/**
18 * The cursor which iterates tokens only, with inflated range.
19 * This is for the backward compatibility of padding options.
20 */
21module.exports = class PaddedTokenCursor extends ForwardTokenCursor {
22
23 /**
24 * Initializes this cursor.
25 * @param {Token[]} tokens The array of tokens.
26 * @param {Comment[]} comments The array of comments.
27 * @param {Object} indexMap The map from locations to indices in `tokens`.
28 * @param {number} startLoc The start location of the iteration range.
29 * @param {number} endLoc The end location of the iteration range.
30 * @param {number} beforeCount The number of tokens this cursor iterates before start.
31 * @param {number} afterCount The number of tokens this cursor iterates after end.
32 */
33 constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
34 super(tokens, comments, indexMap, startLoc, endLoc);
35 this.index = Math.max(0, this.index - beforeCount);
36 this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount);
37 }
38};
Note: See TracBrowser for help on using the repository browser.