@@ -31,6 +31,7 @@ namespace ts {
3131 scanJsxToken ( ) : SyntaxKind ;
3232 scanJSDocToken ( ) : SyntaxKind ;
3333 scan ( ) : SyntaxKind ;
34+ getText ( ) : string ;
3435 // Sets the text for the scanner to scan. An optional subrange starting point and length
3536 // can be provided to have the scanner only scan a portion of the text.
3637 setText ( text : string , start ?: number , length ?: number ) : void ;
@@ -365,6 +366,11 @@ namespace ts {
365366 const hasOwnProperty = Object . prototype . hasOwnProperty ;
366367
367368 export function isWhiteSpace ( ch : number ) : boolean {
369+ return isWhiteSpaceSingleLine ( ch ) || isLineBreak ( ch ) ;
370+ }
371+
372+ /** Does not include line breaks. For that, see isWhiteSpaceLike. */
373+ export function isWhiteSpaceSingleLine ( ch : number ) : boolean {
368374 // Note: nextLine is in the Zs space, and should be considered to be a whitespace.
369375 // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript.
370376 return ch === CharacterCodes . space ||
@@ -505,7 +511,7 @@ namespace ts {
505511 break ;
506512
507513 default :
508- if ( ch > CharacterCodes . maxAsciiCharacter && ( isWhiteSpace ( ch ) || isLineBreak ( ch ) ) ) {
514+ if ( ch > CharacterCodes . maxAsciiCharacter && ( isWhiteSpace ( ch ) ) ) {
509515 pos ++ ;
510516 continue ;
511517 }
@@ -658,7 +664,7 @@ namespace ts {
658664 }
659665 break ;
660666 default :
661- if ( ch > CharacterCodes . maxAsciiCharacter && ( isWhiteSpace ( ch ) || isLineBreak ( ch ) ) ) {
667+ if ( ch > CharacterCodes . maxAsciiCharacter && ( isWhiteSpace ( ch ) ) ) {
662668 if ( result && result . length && isLineBreak ( ch ) ) {
663669 lastOrUndefined ( result ) . hasTrailingNewLine = true ;
664670 }
@@ -763,6 +769,7 @@ namespace ts {
763769 scanJsxToken,
764770 scanJSDocToken,
765771 scan,
772+ getText,
766773 setText,
767774 setScriptTarget,
768775 setLanguageVariant,
@@ -1202,7 +1209,7 @@ namespace ts {
12021209 continue ;
12031210 }
12041211 else {
1205- while ( pos < end && isWhiteSpace ( text . charCodeAt ( pos ) ) ) {
1212+ while ( pos < end && isWhiteSpaceSingleLine ( text . charCodeAt ( pos ) ) ) {
12061213 pos ++ ;
12071214 }
12081215 return token = SyntaxKind . WhitespaceTrivia ;
@@ -1520,7 +1527,7 @@ namespace ts {
15201527 }
15211528 return token = getIdentifierToken ( ) ;
15221529 }
1523- else if ( isWhiteSpace ( ch ) ) {
1530+ else if ( isWhiteSpaceSingleLine ( ch ) ) {
15241531 pos ++ ;
15251532 continue ;
15261533 }
@@ -1689,7 +1696,7 @@ namespace ts {
16891696 let ch = text . charCodeAt ( pos ) ;
16901697 while ( pos < end ) {
16911698 ch = text . charCodeAt ( pos ) ;
1692- if ( isWhiteSpace ( ch ) ) {
1699+ if ( isWhiteSpaceSingleLine ( ch ) ) {
16931700 pos ++ ;
16941701 }
16951702 else {
@@ -1789,6 +1796,10 @@ namespace ts {
17891796 return speculationHelper ( callback , /*isLookahead*/ false ) ;
17901797 }
17911798
1799+ function getText ( ) : string {
1800+ return text ;
1801+ }
1802+
17921803 function setText ( newText : string , start : number , length : number ) {
17931804 text = newText || "" ;
17941805 end = length === undefined ? text . length : start + length ;
0 commit comments