File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ module ts {
4040 }
4141
4242 export function getTokenPosOfNode ( node : Node , sourceFile ?: SourceFile ) : number {
43+ if ( node . pos === node . end ) {
44+ return node . pos ;
45+ }
4346 return skipTrivia ( ( sourceFile || getSourceFileOfNode ( node ) ) . text , node . pos ) ;
4447 }
4548
Original file line number Diff line number Diff line change @@ -220,19 +220,13 @@ module ts {
220220 }
221221
222222 function nodeHasTokens ( n : Node ) : boolean {
223- if ( n . kind === SyntaxKind . ExpressionStatement ) {
224- return nodeHasTokens ( ( < ExpressionStatement > n ) . expression ) ;
225- }
226-
227- if ( n . kind === SyntaxKind . EndOfFileToken ||
228- n . kind === SyntaxKind . OmittedExpression ||
229- n . kind === SyntaxKind . Missing ||
230- n . kind === SyntaxKind . Unknown ) {
223+ if ( n . kind === SyntaxKind . Unknown ) {
231224 return false ;
232225 }
233226
234- // SyntaxList is already realized so getChildCount should be fast and non-expensive
235- return n . kind !== SyntaxKind . SyntaxList || n . getChildCount ( ) !== 0 ;
227+ // If we have a token or node that has a non-zero width, it must have tokens.
228+ // Note, that getWidth() does not take trivia into account.
229+ return n . getWidth ( ) !== 0 ;
236230 }
237231
238232 export function getTypeArgumentOrTypeParameterList ( node : Node ) : NodeArray < Node > {
You can’t perform that action at this time.
0 commit comments