@@ -4077,8 +4077,7 @@ module ts {
4077
4077
var offset = 0 ;
4078
4078
var lastTokenOrCommentEnd = 0 ;
4079
4079
var lastNonTriviaToken = SyntaxKind . Unknown ;
4080
- var inUnterminatedMultiLineComment = false ;
4081
-
4080
+
4082
4081
// If we're in a string literal, then prepend: "\
4083
4082
// (and a newline). That way when we lex we'll think we're still in a string literal.
4084
4083
//
@@ -4104,7 +4103,7 @@ module ts {
4104
4103
entries : [ ]
4105
4104
} ;
4106
4105
4107
- scanner = createScanner ( ScriptTarget . ES5 , /*skipTrivia*/ false , text , onError , /*onComment*/ undefined ) ;
4106
+ scanner = createScanner ( ScriptTarget . ES5 , /*skipTrivia*/ false , text , /* onError*/ undefined , /*onComment*/ undefined ) ;
4108
4107
4109
4108
var token = SyntaxKind . Unknown ;
4110
4109
do {
@@ -4130,11 +4129,6 @@ module ts {
4130
4129
4131
4130
return result ;
4132
4131
4133
-
4134
- function onError ( message : DiagnosticMessage ) : void {
4135
- inUnterminatedMultiLineComment = message . key === Diagnostics . Asterisk_Slash_expected . key ;
4136
- }
4137
-
4138
4132
function processToken ( ) : void {
4139
4133
var start = scanner . getTokenPos ( ) ;
4140
4134
var end = scanner . getTextPos ( ) ;
@@ -4144,10 +4138,8 @@ module ts {
4144
4138
4145
4139
if ( end >= text . length ) {
4146
4140
// We're at the end.
4147
- if ( inUnterminatedMultiLineComment ) {
4148
- result . finalLexState = EndOfLineState . InMultiLineCommentTrivia ;
4149
- }
4150
- else if ( token === SyntaxKind . StringLiteral ) {
4141
+ if ( token === SyntaxKind . StringLiteral ) {
4142
+ // Check to see if we finished up on a multiline string literal.
4151
4143
var tokenText = scanner . getTokenText ( ) ;
4152
4144
if ( tokenText . length > 0 && tokenText . charCodeAt ( tokenText . length - 1 ) === CharacterCodes . backslash ) {
4153
4145
var quoteChar = tokenText . charCodeAt ( 0 ) ;
@@ -4156,6 +4148,15 @@ module ts {
4156
4148
: EndOfLineState . InSingleQuoteStringLiteral ;
4157
4149
}
4158
4150
}
4151
+ else if ( token === SyntaxKind . MultiLineCommentTrivia ) {
4152
+ // Check to see if the multiline comment was unclosed.
4153
+ var tokenText = scanner . getTokenText ( )
4154
+ if ( ! ( tokenText . length > 3 && // need to avoid catching '/*/'
4155
+ tokenText . charCodeAt ( tokenText . length - 2 ) === CharacterCodes . asterisk &&
4156
+ tokenText . charCodeAt ( tokenText . length - 1 ) === CharacterCodes . slash ) ) {
4157
+ result . finalLexState = EndOfLineState . InMultiLineCommentTrivia ;
4158
+ }
4159
+ }
4159
4160
}
4160
4161
}
4161
4162
0 commit comments