@@ -103,14 +103,11 @@ module Harness.LanguageService {
103103 }
104104 }
105105
106- class CancellationToken {
107- public static None : CancellationToken = new CancellationToken ( null ) ;
108-
109- constructor ( private cancellationToken : ts . CancellationToken ) {
110- }
106+ class DefaultHostCancellationToken implements ts . HostCancellationToken {
107+ public static Instance = new DefaultHostCancellationToken ( ) ;
111108
112109 public isCancellationRequested ( ) {
113- return this . cancellationToken && this . cancellationToken . isCancellationRequested ( ) ;
110+ return false ;
114111 }
115112 }
116113
@@ -124,8 +121,8 @@ module Harness.LanguageService {
124121 export class LanguageServiceAdapterHost {
125122 protected fileNameToScript : ts . Map < ScriptInfo > = { } ;
126123
127- constructor ( protected cancellationToken : ts . CancellationToken = CancellationToken . None ,
128- protected settings = ts . getDefaultCompilerOptions ( ) ) {
124+ constructor ( protected cancellationToken = DefaultHostCancellationToken . Instance ,
125+ protected settings = ts . getDefaultCompilerOptions ( ) ) {
129126 }
130127
131128 public getNewLine ( ) : string {
@@ -173,8 +170,8 @@ module Harness.LanguageService {
173170
174171 /// Native adapter
175172 class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts . LanguageServiceHost {
176- getCompilationSettings ( ) : ts . CompilerOptions { return this . settings ; }
177- getCancellationToken ( ) : ts . CancellationToken { return this . cancellationToken ; }
173+ getCompilationSettings ( ) { return this . settings ; }
174+ getCancellationToken ( ) { return this . cancellationToken ; }
178175 getCurrentDirectory ( ) : string { return "" ; }
179176 getDefaultLibFileName ( ) : string { return "" ; }
180177 getScriptFileNames ( ) : string [ ] { return this . getFilenames ( ) ; }
@@ -194,7 +191,7 @@ module Harness.LanguageService {
194191
195192 export class NativeLanugageServiceAdapter implements LanguageServiceAdapter {
196193 private host : NativeLanguageServiceHost ;
197- constructor ( cancellationToken ?: ts . CancellationToken , options ?: ts . CompilerOptions ) {
194+ constructor ( cancellationToken ?: ts . HostCancellationToken , options ?: ts . CompilerOptions ) {
198195 this . host = new NativeLanguageServiceHost ( cancellationToken , options ) ;
199196 }
200197 getHost ( ) { return this . host ; }
@@ -206,7 +203,7 @@ module Harness.LanguageService {
206203 /// Shim adapter
207204 class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts . LanguageServiceShimHost , ts . CoreServicesShimHost {
208205 private nativeHost : NativeLanguageServiceHost ;
209- constructor ( cancellationToken ?: ts . CancellationToken , options ?: ts . CompilerOptions ) {
206+ constructor ( cancellationToken ?: ts . HostCancellationToken , options ?: ts . CompilerOptions ) {
210207 super ( cancellationToken , options ) ;
211208 this . nativeHost = new NativeLanguageServiceHost ( cancellationToken , options ) ;
212209 }
@@ -218,7 +215,7 @@ module Harness.LanguageService {
218215 positionToLineAndCharacter ( fileName : string , position : number ) : ts . LineAndCharacter { return this . nativeHost . positionToLineAndCharacter ( fileName , position ) ; }
219216
220217 getCompilationSettings ( ) : string { return JSON . stringify ( this . nativeHost . getCompilationSettings ( ) ) ; }
221- getCancellationToken ( ) : ts . CancellationToken { return this . nativeHost . getCancellationToken ( ) ; }
218+ getCancellationToken ( ) : ts . HostCancellationToken { return this . nativeHost . getCancellationToken ( ) ; }
222219 getCurrentDirectory ( ) : string { return this . nativeHost . getCurrentDirectory ( ) ; }
223220 getDefaultLibFileName ( ) : string { return this . nativeHost . getDefaultLibFileName ( ) ; }
224221 getScriptFileNames ( ) : string { return JSON . stringify ( this . nativeHost . getScriptFileNames ( ) ) ; }
@@ -399,7 +396,7 @@ module Harness.LanguageService {
399396 export class ShimLanugageServiceAdapter implements LanguageServiceAdapter {
400397 private host : ShimLanguageServiceHost ;
401398 private factory : ts . TypeScriptServicesFactory ;
402- constructor ( cancellationToken ?: ts . CancellationToken , options ?: ts . CompilerOptions ) {
399+ constructor ( cancellationToken ?: ts . HostCancellationToken , options ?: ts . CompilerOptions ) {
403400 this . host = new ShimLanguageServiceHost ( cancellationToken , options ) ;
404401 this . factory = new TypeScript . Services . TypeScriptServicesFactory ( ) ;
405402 }
@@ -446,7 +443,7 @@ module Harness.LanguageService {
446443 class SessionClientHost extends NativeLanguageServiceHost implements ts . server . SessionClientHost {
447444 private client : ts . server . SessionClient ;
448445
449- constructor ( cancellationToken : ts . CancellationToken , settings : ts . CompilerOptions ) {
446+ constructor ( cancellationToken : ts . HostCancellationToken , settings : ts . CompilerOptions ) {
450447 super ( cancellationToken , settings ) ;
451448 }
452449
@@ -575,7 +572,7 @@ module Harness.LanguageService {
575572 export class ServerLanugageServiceAdapter implements LanguageServiceAdapter {
576573 private host : SessionClientHost ;
577574 private client : ts . server . SessionClient ;
578- constructor ( cancellationToken ?: ts . CancellationToken , options ?: ts . CompilerOptions ) {
575+ constructor ( cancellationToken ?: ts . HostCancellationToken , options ?: ts . CompilerOptions ) {
579576 // This is the main host that tests use to direct tests
580577 var clientHost = new SessionClientHost ( cancellationToken , options ) ;
581578 var client = new ts . server . SessionClient ( clientHost ) ;
0 commit comments