MCPcopy Create free account
hub / github.com/nodejs/node / getNodeAtPosition

Function getNodeAtPosition

test/fixtures/snapshot/typescript.js:118073–118087  ·  view source on GitHub ↗

Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files

(sourceFile, position)

Source from the content-addressed store, hash-verified

118071 }
118072 /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */
118073 function getNodeAtPosition(sourceFile, position) {
118074 var current = sourceFile;
118075 var getContainingChild = function (child) {
118076 if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) {
118077 return child;
118078 }
118079 };
118080 while (true) {
118081 var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
118082 if (!child) {
118083 return current;
118084 }
118085 current = child;
118086 }
118087 }
118088 }
118089 function getLibFileFromReference(ref) {
118090 var libName = ts.toFileNameLowerCase(ref.fileName);

Callers 1

Calls 2

forEachChildMethod · 0.80
forEachMethod · 0.65

Tested by

no test coverage detected