MCPcopy Create free account
hub / github.com/eslint/rewrite / getLoc

Method getLoc

packages/plugin-kit/src/source-code.js:402–414  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 2

getLocFromIndexMethod · 0.95
getIndexFromLocMethod · 0.95

Calls 2

hasESTreeStyleLocFunction · 0.85
hasPosStyleLocFunction · 0.85

Tested by

no test coverage detected