From 520979d09489ef64348ed34f5b01dbddad36cbd0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 10 Dec 2014 14:58:08 -0800 Subject: [PATCH] Make getLocalizedDiagnosticMessages and getCancellationToken optional --- src/harness/harness.ts | 1 - src/services/services.ts | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index ba182e1b24d..e813b18b457 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -575,7 +575,6 @@ module Harness { return { getCurrentDirectory: ts.sys.getCurrentDirectory, - getCancellationToken: (): any => undefined, getSourceFile: (fn, languageVersion) => { if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) { return filemap[getCanonicalFileName(fn)]; diff --git a/src/services/services.ts b/src/services/services.ts index 31a9e7c638b..ff917028eee 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -875,8 +875,8 @@ module ts { getScriptVersion(fileName: string): string; getScriptIsOpen(fileName: string): boolean; getScriptSnapshot(fileName: string): IScriptSnapshot; - getLocalizedDiagnosticMessages(): any; - getCancellationToken(): CancellationToken; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): CancellationToken; getCurrentDirectory(): string; getDefaultLibFilename(options: CompilerOptions): string; } @@ -2395,12 +2395,12 @@ module ts { var useCaseSensitivefilenames = false; var sourceFilesByName: Map = {}; var documentRegistry = documentRegistry; - var cancellationToken = new CancellationTokenObject(host.getCancellationToken()); + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details var writer: (filename: string, data: string, writeByteOrderMark: boolean) => void = undefined; // Check if the localized messages json is set, otherwise query the host for it - if (!localizedDiagnosticMessages) { + if (!localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); }