* Checks whether this javascript parser is asi position. * @param {number} pos source code position * @returns {boolean} true when a semicolon has been inserted before this position, false if not
(pos)
| 5369 | * @returns {boolean} true when a semicolon has been inserted before this position, false if not |
| 5370 | */ |
| 5371 | isAsiPosition(pos) { |
| 5372 | const currentStatement = |
| 5373 | /** @type {StatementPath} */ |
| 5374 | (this.statementPath)[ |
| 5375 | /** @type {StatementPath} */ |
| 5376 | (this.statementPath).length - 1 |
| 5377 | ]; |
| 5378 | if (currentStatement === undefined) throw new Error("Not in statement"); |
| 5379 | const range = /** @type {Range} */ (currentStatement.range); |
| 5380 | |
| 5381 | return ( |
| 5382 | // Either asking directly for the end position of the current statement |
| 5383 | (range[1] === pos && |
| 5384 | /** @type {Set<number>} */ (this.semicolons).has(pos)) || |
| 5385 | // Or asking for the start position of the current statement, |
| 5386 | // here we have to check multiple things |
| 5387 | (range[0] === pos && |
| 5388 | // is there a previous statement which might be relevant? |
| 5389 | this.prevStatement !== undefined && |
| 5390 | // is the end position of the previous statement an ASI position? |
| 5391 | /** @type {Set<number>} */ (this.semicolons).has( |
| 5392 | /** @type {Range} */ (this.prevStatement.range)[1] |
| 5393 | )) |
| 5394 | ); |
| 5395 | } |
| 5396 | |
| 5397 | /** |
| 5398 | * Updates asi position using the provided po. |
no test coverage detected