Skip to content

Commit b5c4d3f

Browse files
committed
Merge pull request #3225 from Microsoft/port-3131
Port PR 3131 into release 1.5
2 parents 492a352 + 2252e30 commit b5c4d3f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/services/services.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ module ts {
949949
export interface LanguageServiceHost {
950950
getCompilationSettings(): CompilerOptions;
951951
getNewLine?(): string;
952+
getProjectVersion?(): string;
952953
getScriptFileNames(): string[];
953954
getScriptVersion(fileName: string): string;
954955
getScriptSnapshot(fileName: string): IScriptSnapshot;
@@ -2353,6 +2354,7 @@ module ts {
23532354
let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
23542355
let ruleProvider: formatting.RulesProvider;
23552356
let program: Program;
2357+
let lastProjectVersion: string;
23562358

23572359
let useCaseSensitivefileNames = false;
23582360
let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
@@ -2392,6 +2394,18 @@ module ts {
23922394
}
23932395

23942396
function synchronizeHostData(): void {
2397+
// perform fast check if host supports it
2398+
if (host.getProjectVersion) {
2399+
let hostProjectVersion = host.getProjectVersion();
2400+
if (hostProjectVersion) {
2401+
if (lastProjectVersion === hostProjectVersion) {
2402+
return;
2403+
}
2404+
2405+
lastProjectVersion = hostProjectVersion;
2406+
}
2407+
}
2408+
23952409
// Get a fresh cache of the host information
23962410
let hostCache = new HostCache(host, getCanonicalFileName);
23972411

src/services/shims.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module ts {
5555
getCurrentDirectory(): string;
5656
getDefaultLibFileName(options: string): string;
5757
getNewLine?(): string;
58+
getProjectVersion?(): string;
5859
}
5960

6061
/** Public interface of the the of a config service shim instance.*/
@@ -260,6 +261,15 @@ module ts {
260261
this.shimHost.error(s);
261262
}
262263

264+
public getProjectVersion(): string {
265+
if (!this.shimHost.getProjectVersion) {
266+
// shimmed host does not support getProjectVersion
267+
return undefined;
268+
}
269+
270+
return this.shimHost.getProjectVersion();
271+
}
272+
263273
public getCompilationSettings(): CompilerOptions {
264274
var settingsJson = this.shimHost.getCompilationSettings();
265275
if (settingsJson == null || settingsJson == "") {

0 commit comments

Comments
 (0)