Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d49a2a

Browse files
committed
Move getNodeAtPosition back
1 parent a368a48 commit 5d49a2a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/compiler/program.ts

+17
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,23 @@ namespace ts {
23572357

23582358
}
23592359

2360+
/** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */
2361+
function getNodeAtPosition(sourceFile: SourceFile, position: number): Node {
2362+
let current: Node = sourceFile;
2363+
const getContainingChild = (child: Node) => {
2364+
if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === SyntaxKind.EndOfFileToken)))) {
2365+
return child;
2366+
}
2367+
};
2368+
while (true) {
2369+
const child = isSourceFileJS(sourceFile) && hasJSDocNodes(current) && forEach(current.jsDoc, getContainingChild) || forEachChild(current, getContainingChild);
2370+
if (!child) {
2371+
return current;
2372+
}
2373+
current = child;
2374+
}
2375+
}
2376+
23602377
function getLibFileFromReference(ref: FileReference) {
23612378
const libName = toFileNameLowerCase(ref.fileName);
23622379
const libFileName = libMap.get(libName);

src/compiler/utilities.ts

-17
Original file line numberDiff line numberDiff line change
@@ -7119,23 +7119,6 @@ namespace ts {
71197119
}
71207120
}
71217121

7122-
/** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */
7123-
export function getNodeAtPosition(sourceFile: SourceFile, position: number): Node {
7124-
let current: Node = sourceFile;
7125-
const getContainingChild = (child: Node) => {
7126-
if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === SyntaxKind.EndOfFileToken)))) {
7127-
return child;
7128-
}
7129-
};
7130-
while (true) {
7131-
const child = isSourceFileJS(sourceFile) && hasJSDocNodes(current) && forEach(current.jsDoc, getContainingChild) || forEachChild(current, getContainingChild);
7132-
if (!child) {
7133-
return current;
7134-
}
7135-
current = child;
7136-
}
7137-
}
7138-
71397122
export function nodeIsFirstNodeAtOrAfterPosition(sourceFile: SourceFile, node: Node, position: number): boolean {
71407123
if (node.pos === position) return true;
71417124
if (node.pos < position) return false;

0 commit comments

Comments
 (0)