* Returns the loc information for the given node or token. * @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for. * @returns {SourceLocation} The loc information for the node or token. * @throws {Error} If the node or token does not have loc in
(nodeOrToken)
| 400 | * @throws {Error} If the node or token does not have loc information. |
| 401 | */ |
| 402 | getLoc(nodeOrToken) { |
| 403 | if (hasESTreeStyleLoc(nodeOrToken)) { |
| 404 | return nodeOrToken.loc; |
| 405 | } |
| 406 | |
| 407 | if (hasPosStyleLoc(nodeOrToken)) { |
| 408 | return nodeOrToken.position; |
| 409 | } |
| 410 | |
| 411 | throw new Error( |
| 412 | "Custom getLoc() method must be implemented in the subclass.", |
| 413 | ); |
| 414 | } |
| 415 | |
| 416 | /** |
| 417 | * Converts a source text index into a `{ line: number, column: number }` pair. |
no test coverage detected