File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed
tests/cases/unittests/services Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -648,6 +648,10 @@ module ts {
648
648
return SyntaxKind . FirstKeyword <= token && token <= SyntaxKind . LastKeyword ;
649
649
}
650
650
651
+ export function isTrivia ( token : SyntaxKind ) {
652
+ return SyntaxKind . FirstTriviaToken <= token && token <= SyntaxKind . LastTriviaToken ;
653
+ }
654
+
651
655
export function isModifier ( token : SyntaxKind ) : boolean {
652
656
switch ( token ) {
653
657
case SyntaxKind . PublicKeyword :
Original file line number Diff line number Diff line change @@ -4538,17 +4538,16 @@ module ts {
4538
4538
do {
4539
4539
token = scanner . scan ( ) ;
4540
4540
4541
- if ( ( token === SyntaxKind . SlashToken || token === SyntaxKind . SlashEqualsToken ) && ! noRegexTable [ lastNonTriviaToken ] ) {
4542
- if ( scanner . reScanSlashToken ( ) === SyntaxKind . RegularExpressionLiteral ) {
4543
- token = SyntaxKind . RegularExpressionLiteral ;
4541
+ if ( ! isTrivia ( token ) ) {
4542
+ if ( ( token === SyntaxKind . SlashToken || token === SyntaxKind . SlashEqualsToken ) && ! noRegexTable [ lastNonTriviaToken ] ) {
4543
+ if ( scanner . reScanSlashToken ( ) === SyntaxKind . RegularExpressionLiteral ) {
4544
+ token = SyntaxKind . RegularExpressionLiteral ;
4545
+ }
4546
+ }
4547
+ else if ( lastNonTriviaToken === SyntaxKind . DotToken && isKeyword ( token ) ) {
4548
+ token = SyntaxKind . Identifier ;
4544
4549
}
4545
- }
4546
- else if ( lastNonTriviaToken === SyntaxKind . DotToken ) {
4547
- token = SyntaxKind . Identifier ;
4548
- }
4549
4550
4550
- // Only recall the token if it was *not* trivia.
4551
- if ( ! ( SyntaxKind . FirstTriviaToken <= token && token <= SyntaxKind . LastTriviaToken ) ) {
4552
4551
lastNonTriviaToken = token ;
4553
4552
}
4554
4553
Original file line number Diff line number Diff line change @@ -189,6 +189,21 @@ describe('Colorization', function () {
189
189
identifier ( "var" ) ) ;
190
190
} ) ;
191
191
192
+ it ( "correctly classifies a string literal after a dot" , function ( ) {
193
+ test ( "a.\"var\"" ,
194
+ ts . EndOfLineState . Start ,
195
+ stringLiteral ( "\"var\"" ) ) ;
196
+ } ) ;
197
+
198
+ it ( "correctly classifies a keyword after a dot separated by comment trivia" , function ( ) {
199
+ test ( "a./*hello world*/ var" ,
200
+ ts . EndOfLineState . Start ,
201
+ identifier ( "a" ) ,
202
+ punctuation ( "." ) ,
203
+ comment ( "/*hello world*/" ) ,
204
+ identifier ( "var" ) ) ;
205
+ } ) ;
206
+
192
207
it ( "classifies a property access with whitespace around the dot" , function ( ) {
193
208
test ( " x .\tfoo ()" ,
194
209
ts . EndOfLineState . Start ,
You can’t perform that action at this time.
0 commit comments