File tree Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -2355,6 +2355,22 @@ namespace ts {
23552355 }
23562356 }
23572357
2358+ /** Returns a token if position is in [start-of-leading-trivia, end), includes JSDoc only in JS files */
2359+ function getNodeAtPosition ( sourceFile : SourceFile , position : number ) : Node {
2360+ let current : Node = sourceFile ;
2361+ const getContainingChild = ( child : Node ) => {
2362+ if ( child . pos <= position && ( position < child . end || ( position === child . end && ( child . kind === SyntaxKind . EndOfFileToken ) ) ) ) {
2363+ return child ;
2364+ }
2365+ } ;
2366+ while ( true ) {
2367+ const child = isSourceFileJS ( sourceFile ) && hasJSDocNodes ( current ) && forEach ( current . jsDoc , getContainingChild ) || forEachChild ( current , getContainingChild ) ;
2368+ if ( ! child ) {
2369+ return current ;
2370+ }
2371+ current = child ;
2372+ }
2373+ }
23582374 }
23592375
23602376 function getLibFileFromReference ( ref : FileReference ) {
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments