@@ -5620,6 +5620,10 @@ module ts {
56205620 noRegexTable [ SyntaxKind . TrueKeyword ] = true ;
56215621 noRegexTable [ SyntaxKind . FalseKeyword ] = true ;
56225622
5623+ // Just a stack of TemplateHeads and OpenCurlyBraces, used
5624+ // to perform rudimentary classification on templates.
5625+ var templateStack : SyntaxKind [ ] = [ ] ;
5626+
56235627 function isAccessibilityModifier ( kind : SyntaxKind ) {
56245628 switch ( kind ) {
56255629 case SyntaxKind . PublicKeyword :
@@ -5658,7 +5662,6 @@ module ts {
56585662 var offset = 0 ;
56595663 var token = SyntaxKind . Unknown ;
56605664 var lastNonTriviaToken = SyntaxKind . Unknown ;
5661- var templateStack : SyntaxKind [ ] ;
56625665
56635666 // If we're in a string literal, then prepend: "\
56645667 // (and a newline). That way when we lex we'll think we're still in a string literal.
@@ -5725,6 +5728,11 @@ module ts {
57255728 // work well enough in practice.
57265729 var angleBracketStack = 0 ;
57275730
5731+ // Empty out the template stack for reuse.
5732+ while ( templateStack . length > 0 ) {
5733+ templateStack . pop ( ) ;
5734+ }
5735+
57285736 do {
57295737 token = scanner . scan ( ) ;
57305738
@@ -5767,24 +5775,19 @@ module ts {
57675775 }
57685776 }
57695777 else if ( token === SyntaxKind . TemplateHead && syntacticClassifierAbsent ) {
5770- if ( ! templateStack ) {
5771- templateStack = [ token ] ;
5772- }
5773- else {
5774- templateStack . push ( token ) ;
5775- }
5778+ templateStack . push ( token ) ;
57765779 }
57775780 else if ( token === SyntaxKind . OpenBraceToken && syntacticClassifierAbsent ) {
57785781 // If we don't have anything on the template stack,
57795782 // then we aren't trying to keep track of a previously scanned template head.
5780- if ( templateStack && templateStack . length > 0 ) {
5783+ if ( templateStack . length > 0 ) {
57815784 templateStack . push ( token ) ;
57825785 }
57835786 }
57845787 else if ( token === SyntaxKind . CloseBraceToken && syntacticClassifierAbsent ) {
57855788 // If we don't have anything on the template stack,
57865789 // then we aren't trying to keep track of a previously scanned template head.
5787- if ( templateStack && templateStack . length > 0 ) {
5790+ if ( templateStack . length > 0 ) {
57885791 var lastTemplateStackToken = lastOrUndefined ( templateStack ) ;
57895792
57905793 if ( lastTemplateStackToken === SyntaxKind . TemplateHead ) {
@@ -5860,7 +5863,7 @@ module ts {
58605863 }
58615864 }
58625865 }
5863- else if ( templateStack && templateStack . length > 0 && lastOrUndefined ( templateStack ) === SyntaxKind . TemplateHead ) {
5866+ else if ( templateStack . length > 0 && lastOrUndefined ( templateStack ) === SyntaxKind . TemplateHead ) {
58645867 result . finalLexState = EndOfLineState . InTemplateSubstitutionPosition ;
58655868 }
58665869 }
0 commit comments