55namespace ts . formatting {
66 const standardScanner = createScanner ( ScriptTarget . Latest , /*skipTrivia*/ false , LanguageVariant . Standard ) ;
77 const jsxScanner = createScanner ( ScriptTarget . Latest , /*skipTrivia*/ false , LanguageVariant . JSX ) ;
8-
8+
99 /**
1010 * Scanner that is currently used for formatting
1111 */
1212 let scanner : Scanner ;
13-
13+
1414 export interface FormattingScanner {
1515 advance ( ) : void ;
1616 isOnToken ( ) : boolean ;
@@ -20,7 +20,7 @@ namespace ts.formatting {
2020 close ( ) : void ;
2121 }
2222
23- const enum ScanAction {
23+ const enum ScanAction {
2424 Scan ,
2525 RescanGreaterThanToken ,
2626 RescanSlashToken ,
@@ -38,7 +38,7 @@ namespace ts.formatting {
3838 let wasNewLine : boolean = true ;
3939 let leadingTrivia : TextRangeWithKind [ ] ;
4040 let trailingTrivia : TextRangeWithKind [ ] ;
41-
41+
4242 let savedPos : number ;
4343 let lastScanAction : ScanAction ;
4444 let lastTokenInfo : TokenInfo ;
@@ -51,7 +51,7 @@ namespace ts.formatting {
5151 lastTrailingTriviaWasNewLine : ( ) => wasNewLine ,
5252 close : ( ) => {
5353 Debug . assert ( scanner !== undefined ) ;
54-
54+
5555 lastTokenInfo = undefined ;
5656 scanner . setText ( undefined ) ;
5757 scanner = undefined ;
@@ -60,7 +60,7 @@ namespace ts.formatting {
6060
6161 function advance ( ) : void {
6262 Debug . assert ( scanner !== undefined ) ;
63-
63+
6464 lastTokenInfo = undefined ;
6565 let isStarted = scanner . getStartPos ( ) !== startPos ;
6666
@@ -83,7 +83,7 @@ namespace ts.formatting {
8383
8484 let t : SyntaxKind ;
8585 let pos = scanner . getStartPos ( ) ;
86-
86+
8787 // Read leading trivia and token
8888 while ( pos < endPos ) {
8989 let t = scanner . getToken ( ) ;
@@ -124,18 +124,18 @@ namespace ts.formatting {
124124
125125 return false ;
126126 }
127-
127+
128128 function shouldRescanJsxIdentifier ( node : Node ) : boolean {
129129 if ( node . parent ) {
130- switch ( node . parent . kind ) {
130+ switch ( node . parent . kind ) {
131131 case SyntaxKind . JsxAttribute :
132132 case SyntaxKind . JsxOpeningElement :
133133 case SyntaxKind . JsxClosingElement :
134134 case SyntaxKind . JsxSelfClosingElement :
135135 return node . kind === SyntaxKind . Identifier ;
136136 }
137137 }
138-
138+
139139 return false ;
140140 }
141141
@@ -144,7 +144,7 @@ namespace ts.formatting {
144144 }
145145
146146 function shouldRescanTemplateToken ( container : Node ) : boolean {
147- return container . kind === SyntaxKind . TemplateMiddle ||
147+ return container . kind === SyntaxKind . TemplateMiddle ||
148148 container . kind === SyntaxKind . TemplateTail ;
149149 }
150150
@@ -154,7 +154,7 @@ namespace ts.formatting {
154154
155155 function readTokenInfo ( n : Node ) : TokenInfo {
156156 Debug . assert ( scanner !== undefined ) ;
157-
157+
158158 if ( ! isOnToken ( ) ) {
159159 // scanner is not on the token (either advance was not called yet or scanner is already past the end position)
160160 return {
@@ -166,7 +166,7 @@ namespace ts.formatting {
166166
167167 // normally scanner returns the smallest available token
168168 // check the kind of context node to determine if scanner should have more greedy behavior and consume more text.
169- let expectedScanAction =
169+ let expectedScanAction =
170170 shouldRescanGreaterThanToken ( n )
171171 ? ScanAction . RescanGreaterThanToken
172172 : shouldRescanSlashToken ( n )
@@ -228,7 +228,7 @@ namespace ts.formatting {
228228 if ( trailingTrivia ) {
229229 trailingTrivia = undefined ;
230230 }
231- while ( scanner . getStartPos ( ) < endPos ) {
231+ while ( scanner . getStartPos ( ) < endPos ) {
232232 currentToken = scanner . scan ( ) ;
233233 if ( ! isTrivia ( currentToken ) ) {
234234 break ;
@@ -263,7 +263,7 @@ namespace ts.formatting {
263263
264264 function isOnToken ( ) : boolean {
265265 Debug . assert ( scanner !== undefined ) ;
266-
266+
267267 let current = ( lastTokenInfo && lastTokenInfo . token . kind ) || scanner . getToken ( ) ;
268268 let startPos = ( lastTokenInfo && lastTokenInfo . token . pos ) || scanner . getStartPos ( ) ;
269269 return startPos < endPos && current !== SyntaxKind . EndOfFileToken && ! isTrivia ( current ) ;
0 commit comments