Add getCurrentDirectory to ServerHost

This commit is contained in:
zhengbli 2016-06-28 11:43:07 -07:00
parent 6be7d9caa6
commit 6ff91b84ab
3 changed files with 26 additions and 2 deletions

View file

@ -187,8 +187,22 @@ namespace ts {
const typeReferenceExtensions = [".d.ts"];
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
return options.typeRoots ||
map(defaultTypeRoots, d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d));
if (options.typeRoots) {
return options.typeRoots;
}
let currentDirectory: string;
if (options.configFilePath) {
currentDirectory = getDirectoryPath(options.configFilePath);
}
else if (host.getCurrentDirectory) {
currentDirectory = host.getCurrentDirectory();
}
if (!currentDirectory) {
return undefined;
}
return map(defaultTypeRoots, d => combinePaths(currentDirectory, d));
}
/**

View file

@ -113,6 +113,7 @@ namespace ts.server {
this.moduleResolutionHost = {
fileExists: fileName => this.fileExists(fileName),
readFile: fileName => this.host.readFile(fileName),
getCurrentDirectory: () => this.host.getCurrentDirectory(),
directoryExists: directoryName => this.host.directoryExists(directoryName)
};
}

View file

@ -0,0 +1,9 @@
/// <reference path='../fourslash.ts' />
/////// <reference types="foo" />
////var x: number;
////x./*1*/
goTo.marker("1");
verify.not.completionListIsEmpty();