File tree 2 files changed +16
-17
lines changed
2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -2355,6 +2355,22 @@ namespace ts {
2355
2355
}
2356
2356
}
2357
2357
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
+ }
2358
2374
}
2359
2375
2360
2376
function getLibFileFromReference ( ref : FileReference ) {
Original file line number Diff line number Diff line change @@ -7119,23 +7119,6 @@ namespace ts {
7119
7119
}
7120
7120
}
7121
7121
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
-
7139
7122
export function nodeIsFirstNodeAtOrAfterPosition ( sourceFile : SourceFile , node : Node , position : number ) : boolean {
7140
7123
if ( node . pos === position ) return true ;
7141
7124
if ( node . pos < position ) return false ;
You can’t perform that action at this time.
0 commit comments