@@ -246,7 +246,7 @@ module FourSlash {
246246
247247 export class TestState {
248248 // Language service instance
249- private languageServiceAdaptorHost : Harness . LanguageService . LanguageServiceAdaptorHost ;
249+ private languageServiceAdapterHost : Harness . LanguageService . LanguageServiceAdapterHost ;
250250 private languageService : ts . LanguageService ;
251251 private cancellationToken : TestCancellationToken ;
252252
@@ -272,32 +272,28 @@ module FourSlash {
272272 private addMatchedInputFile ( referenceFilePath : string ) {
273273 var inputFile = this . inputFiles [ referenceFilePath ] ;
274274 if ( inputFile && ! Harness . isLibraryFile ( referenceFilePath ) ) {
275- this . languageServiceAdaptorHost . addScript ( referenceFilePath , inputFile ) ;
275+ this . languageServiceAdapterHost . addScript ( referenceFilePath , inputFile ) ;
276276 }
277277 }
278278
279- private getLanguageServiceAdaptor ( testType : FourSlashTestType ) :
280- { new ( cancellationToken ?: ts . CancellationToken , options ?: ts . CompilerOptions ) : Harness . LanguageService . LanguageServiceAdaptor } {
279+ private getLanguageServiceAdapter ( testType : FourSlashTestType , cancellationToken : TestCancellationToken , compilationOptions : ts . CompilerOptions ) : Harness . LanguageService . LanguageServiceAdapter {
281280 switch ( testType ) {
282281 case FourSlashTestType . Native :
283- return Harness . LanguageService . NativeLanugageServiceAdaptor ;
284- break ;
282+ return new Harness . LanguageService . NativeLanugageServiceAdapter ( cancellationToken , compilationOptions ) ;
285283 case FourSlashTestType . Shims :
286- return Harness . LanguageService . ShimLanugageServiceAdaptor ;
287- break ;
284+ return new Harness . LanguageService . ShimLanugageServiceAdapter ( cancellationToken , compilationOptions ) ;
288285 default :
289286 throw new Error ( "Unknown FourSlash test type: " ) ;
290287 }
291288 }
292289
293290 constructor ( private basePath : string , private testType : FourSlashTestType , public testData : FourSlashData ) {
294- // Create a new Services Adaptor
291+ // Create a new Services Adapter
295292 this . cancellationToken = new TestCancellationToken ( ) ;
296293 var compilationOptions = convertGlobalOptionsToCompilerOptions ( this . testData . globalOptions ) ;
297- var languageserviceAdaptorFactory = this . getLanguageServiceAdaptor ( testType ) ;
298- var languageServiceAdaptor = new languageserviceAdaptorFactory ( this . cancellationToken , compilationOptions ) ;
299- this . languageServiceAdaptorHost = languageServiceAdaptor . getHost ( ) ;
300- this . languageService = languageServiceAdaptor . getLanguageService ( ) ;
294+ var languageServiceAdapter = this . getLanguageServiceAdapter ( testType , this . cancellationToken , compilationOptions ) ;
295+ this . languageServiceAdapterHost = languageServiceAdapter . getHost ( ) ;
296+ this . languageService = languageServiceAdapter . getLanguageService ( ) ;
301297
302298 // Initialize the language service with all the scripts
303299 var startResolveFileRef : FourSlashFile ;
@@ -315,16 +311,16 @@ module FourSlash {
315311
316312 if ( startResolveFileRef ) {
317313 // Add the entry-point file itself into the languageServiceShimHost
318- this . languageServiceAdaptorHost . addScript ( startResolveFileRef . fileName , startResolveFileRef . content ) ;
314+ this . languageServiceAdapterHost . addScript ( startResolveFileRef . fileName , startResolveFileRef . content ) ;
319315
320- var resolvedResult = languageServiceAdaptor . getPreProcessedFileInfo ( startResolveFileRef . fileName , startResolveFileRef . content ) ;
316+ var resolvedResult = languageServiceAdapter . getPreProcessedFileInfo ( startResolveFileRef . fileName , startResolveFileRef . content ) ;
321317 var referencedFiles : ts . FileReference [ ] = resolvedResult . referencedFiles ;
322318 var importedFiles : ts . FileReference [ ] = resolvedResult . importedFiles ;
323319
324320 // Add triple reference files into language-service host
325321 ts . forEach ( referencedFiles , referenceFile => {
326322 // Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path
327- var referenceFilePath = this . basePath + '/' + referenceFile . fileName ;
323+ var referenceFilePath = this . basePath + '/' + referenceFile . fileName ;
328324 this . addMatchedInputFile ( referenceFilePath ) ;
329325 } ) ;
330326
@@ -338,16 +334,16 @@ module FourSlash {
338334
339335 // Check if no-default-lib flag is false and if so add default library
340336 if ( ! resolvedResult . isLibFile ) {
341- this . languageServiceAdaptorHost . addScript ( Harness . Compiler . defaultLibFileName , Harness . Compiler . defaultLibSourceFile . text ) ;
337+ this . languageServiceAdapterHost . addScript ( Harness . Compiler . defaultLibFileName , Harness . Compiler . defaultLibSourceFile . text ) ;
342338 }
343339 } else {
344340 // resolveReference file-option is not specified then do not resolve any files and include all inputFiles
345341 ts . forEachKey ( this . inputFiles , fileName => {
346342 if ( ! Harness . isLibraryFile ( fileName ) ) {
347- this . languageServiceAdaptorHost . addScript ( fileName , this . inputFiles [ fileName ] ) ;
343+ this . languageServiceAdapterHost . addScript ( fileName , this . inputFiles [ fileName ] ) ;
348344 }
349345 } ) ;
350- this . languageServiceAdaptorHost . addScript ( Harness . Compiler . defaultLibFileName , Harness . Compiler . defaultLibSourceFile . text ) ;
346+ this . languageServiceAdapterHost . addScript ( Harness . Compiler . defaultLibFileName , Harness . Compiler . defaultLibSourceFile . text ) ;
351347 }
352348
353349 this . formatCodeOptions = {
@@ -376,7 +372,7 @@ module FourSlash {
376372 }
377373
378374 private getFileContent ( fileName : string ) : string {
379- var script = this . languageServiceAdaptorHost . getScriptInfo ( fileName ) ;
375+ var script = this . languageServiceAdapterHost . getScriptInfo ( fileName ) ;
380376 return script . content ;
381377 }
382378
@@ -464,7 +460,7 @@ module FourSlash {
464460 private getAllDiagnostics ( ) : ts . Diagnostic [ ] {
465461 var diagnostics : ts . Diagnostic [ ] = [ ] ;
466462
467- var fileNames = this . languageServiceAdaptorHost . getFilenames ( ) ;
463+ var fileNames = this . languageServiceAdapterHost . getFilenames ( ) ;
468464 for ( var i = 0 , n = fileNames . length ; i < n ; i ++ ) {
469465 diagnostics . push . apply ( this . getDiagnostics ( fileNames [ i ] ) ) ;
470466 }
@@ -1255,7 +1251,7 @@ module FourSlash {
12551251 }
12561252
12571253 public printContext ( ) {
1258- ts . forEach ( this . languageServiceAdaptorHost . getFilenames ( ) , Harness . IO . log ) ;
1254+ ts . forEach ( this . languageServiceAdapterHost . getFilenames ( ) , Harness . IO . log ) ;
12591255 }
12601256
12611257 public deleteChar ( count = 1 ) {
@@ -1268,7 +1264,7 @@ module FourSlash {
12681264
12691265 for ( var i = 0 ; i < count ; i ++ ) {
12701266 // Make the edit
1271- this . languageServiceAdaptorHost . editScript ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
1267+ this . languageServiceAdapterHost . editScript ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
12721268 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
12731269
12741270 if ( i % checkCadence === 0 ) {
@@ -1295,7 +1291,7 @@ module FourSlash {
12951291 public replace ( start : number , length : number , text : string ) {
12961292 this . taoInvalidReason = 'replace NYI' ;
12971293
1298- this . languageServiceAdaptorHost . editScript ( this . activeFile . fileName , start , start + length , text ) ;
1294+ this . languageServiceAdapterHost . editScript ( this . activeFile . fileName , start , start + length , text ) ;
12991295 this . updateMarkersForEdit ( this . activeFile . fileName , start , start + length , text ) ;
13001296 this . checkPostEditInvariants ( ) ;
13011297 }
@@ -1310,7 +1306,7 @@ module FourSlash {
13101306 for ( var i = 0 ; i < count ; i ++ ) {
13111307 offset -- ;
13121308 // Make the edit
1313- this . languageServiceAdaptorHost . editScript ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
1309+ this . languageServiceAdapterHost . editScript ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
13141310 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset + 1 , ch ) ;
13151311
13161312 if ( i % checkCadence === 0 ) {
@@ -1355,7 +1351,7 @@ module FourSlash {
13551351 for ( var i = 0 ; i < text . length ; i ++ ) {
13561352 // Make the edit
13571353 var ch = text . charAt ( i ) ;
1358- this . languageServiceAdaptorHost . editScript ( this . activeFile . fileName , offset , offset , ch ) ;
1354+ this . languageServiceAdapterHost . editScript ( this . activeFile . fileName , offset , offset , ch ) ;
13591355 this . languageService . getBraceMatchingAtPosition ( this . activeFile . fileName , offset ) ;
13601356
13611357 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset , ch ) ;
@@ -1398,7 +1394,7 @@ module FourSlash {
13981394
13991395 var start = this . currentCaretPosition ;
14001396 var offset = this . currentCaretPosition ;
1401- this . languageServiceAdaptorHost . editScript ( this . activeFile . fileName , offset , offset , text ) ;
1397+ this . languageServiceAdapterHost . editScript ( this . activeFile . fileName , offset , offset , text ) ;
14021398 this . updateMarkersForEdit ( this . activeFile . fileName , offset , offset , text ) ;
14031399 this . checkPostEditInvariants ( ) ;
14041400 offset += text . length ;
@@ -1461,7 +1457,7 @@ module FourSlash {
14611457 // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
14621458 var oldContent = this . getFileContent ( this . activeFile . fileName ) ;
14631459 for ( var j = 0 ; j < edits . length ; j ++ ) {
1464- this . languageServiceAdaptorHost . editScript ( fileName , edits [ j ] . span . start + runningOffset , ts . textSpanEnd ( edits [ j ] . span ) + runningOffset , edits [ j ] . newText ) ;
1460+ this . languageServiceAdapterHost . editScript ( fileName , edits [ j ] . span . start + runningOffset , ts . textSpanEnd ( edits [ j ] . span ) + runningOffset , edits [ j ] . newText ) ;
14651461 this . updateMarkersForEdit ( fileName , edits [ j ] . span . start + runningOffset , ts . textSpanEnd ( edits [ j ] . span ) + runningOffset , edits [ j ] . newText ) ;
14661462 var change = ( edits [ j ] . span . start - ts . textSpanEnd ( edits [ j ] . span ) ) + edits [ j ] . newText . length ;
14671463 runningOffset += change ;
@@ -1742,8 +1738,8 @@ module FourSlash {
17421738
17431739 function jsonMismatchString ( ) {
17441740 return ts . sys . newLine +
1745- "expected: '" + ts . sys . newLine + JSON . stringify ( expected , ( k , v ) => v , 2 ) + "'" + ts . sys . newLine +
1746- "actual: '" + ts . sys . newLine + JSON . stringify ( actual , ( k , v ) => v , 2 ) + "'" ;
1741+ "expected: '" + ts . sys . newLine + JSON . stringify ( expected , ( k , v ) => v , 2 ) + "'" + ts . sys . newLine +
1742+ "actual: '" + ts . sys . newLine + JSON . stringify ( actual , ( k , v ) => v , 2 ) + "'" ;
17471743 }
17481744 }
17491745
@@ -2017,7 +2013,7 @@ module FourSlash {
20172013 // The current caret position (in line/col terms)
20182014 var line = this . getCurrentCaretFilePosition ( ) . line ;
20192015 // The line/col of the start of this line
2020- var pos = this . languageServiceAdaptorHost . lineColToPosition ( this . activeFile . fileName , line , 1 ) ;
2016+ var pos = this . languageServiceAdapterHost . lineColToPosition ( this . activeFile . fileName , line , 1 ) ;
20212017 // The index of the current file
20222018
20232019 // The text from the start of the line to the end of the file
@@ -2037,7 +2033,7 @@ module FourSlash {
20372033 }
20382034
20392035 private getCurrentCaretFilePosition ( ) {
2040- var result = this . languageServiceAdaptorHost . positionToZeroBasedLineCol ( this . activeFile . fileName , this . currentCaretPosition ) ;
2036+ var result = this . languageServiceAdapterHost . positionToZeroBasedLineCol ( this . activeFile . fileName , this . currentCaretPosition ) ;
20412037 if ( result . line >= 0 ) {
20422038 result . line ++ ;
20432039 }
@@ -2097,7 +2093,7 @@ module FourSlash {
20972093 var name = < string > indexOrName ;
20982094
20992095 // names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName
2100- name = name . indexOf ( '/' ) === - 1 ? ( this . basePath + '/' + name ) : name ;
2096+ name = name . indexOf ( '/' ) === - 1 ? ( this . basePath + '/' + name ) : name ;
21012097
21022098 var availableNames : string [ ] = [ ] ;
21032099 var foundIt = false ;
@@ -2124,7 +2120,7 @@ module FourSlash {
21242120 }
21252121
21262122 private getLineColStringAtPosition ( position : number ) {
2127- var pos = this . languageServiceAdaptorHost . positionToZeroBasedLineCol ( this . activeFile . fileName , position ) ;
2123+ var pos = this . languageServiceAdapterHost . positionToZeroBasedLineCol ( this . activeFile . fileName , position ) ;
21282124 return 'line ' + ( pos . line + 1 ) + ', col ' + pos . character ;
21292125 }
21302126
@@ -2285,7 +2281,7 @@ module FourSlash {
22852281 currentFileName = fileName ;
22862282 }
22872283
2288- currentFileName = basePath + '/' + match [ 2 ] ;
2284+ currentFileName = basePath + '/' + match [ 2 ] ;
22892285 currentFileOptions [ match [ 1 ] ] = match [ 2 ] ;
22902286 } else {
22912287 // Add other fileMetadata flag
0 commit comments