Merge pull request #3225 from Microsoft/port-3131
Port PR 3131 into release 1.5
This commit is contained in:
commit
b5c4d3f2c6
2 changed files with 24 additions and 0 deletions
|
@ -949,6 +949,7 @@ module ts {
|
|||
export interface LanguageServiceHost {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
|
@ -2353,6 +2354,7 @@ module ts {
|
|||
let syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
|
||||
let ruleProvider: formatting.RulesProvider;
|
||||
let program: Program;
|
||||
let lastProjectVersion: string;
|
||||
|
||||
let useCaseSensitivefileNames = false;
|
||||
let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
|
||||
|
@ -2392,6 +2394,18 @@ module ts {
|
|||
}
|
||||
|
||||
function synchronizeHostData(): void {
|
||||
// perform fast check if host supports it
|
||||
if (host.getProjectVersion) {
|
||||
let hostProjectVersion = host.getProjectVersion();
|
||||
if (hostProjectVersion) {
|
||||
if (lastProjectVersion === hostProjectVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastProjectVersion = hostProjectVersion;
|
||||
}
|
||||
}
|
||||
|
||||
// Get a fresh cache of the host information
|
||||
let hostCache = new HostCache(host, getCanonicalFileName);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ module ts {
|
|||
getCurrentDirectory(): string;
|
||||
getDefaultLibFileName(options: string): string;
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
}
|
||||
|
||||
/** Public interface of the the of a config service shim instance.*/
|
||||
|
@ -260,6 +261,15 @@ module ts {
|
|||
this.shimHost.error(s);
|
||||
}
|
||||
|
||||
public getProjectVersion(): string {
|
||||
if (!this.shimHost.getProjectVersion) {
|
||||
// shimmed host does not support getProjectVersion
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.shimHost.getProjectVersion();
|
||||
}
|
||||
|
||||
public getCompilationSettings(): CompilerOptions {
|
||||
var settingsJson = this.shimHost.getCompilationSettings();
|
||||
if (settingsJson == null || settingsJson == "") {
|
||||
|
|
Loading…
Reference in a new issue