Refactor
This commit is contained in:
parent
46dfd68ef8
commit
c0806439ea
6 changed files with 20 additions and 21 deletions
|
@ -1932,5 +1932,5 @@ namespace Harness {
|
|||
return { unitName: libFile, content: io.readFile(libFile) };
|
||||
}
|
||||
|
||||
if (Error) (<any>Error).stackTraceLimit = 25;
|
||||
if (Error) (<any>Error).stackTraceLimit = 1;
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ namespace Harness.LanguageService {
|
|||
function unwrapJSONCallResult(result: string): any {
|
||||
const parsedResult = JSON.parse(result);
|
||||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult));
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
else if (parsedResult.canceled) {
|
||||
throw new ts.OperationCanceledException();
|
||||
|
|
|
@ -389,17 +389,7 @@ namespace ts.server {
|
|||
}
|
||||
|
||||
getTypeRootsVersion(project: ConfiguredProject) {
|
||||
const roots = project.getEffectiveTypeRoots();
|
||||
if (roots === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max.apply(Math, project.getEffectiveTypeRoots().map(root => {
|
||||
if (this.host.directoryExists(root)) {
|
||||
return +this.host.getModifiedTime(root);
|
||||
}
|
||||
return 0;
|
||||
}));
|
||||
return getLatestDirectoryChangeTime(project.getEffectiveTypeRoots(), this.host);
|
||||
}
|
||||
|
||||
private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject) {
|
||||
|
|
|
@ -147,13 +147,7 @@ namespace ts.server {
|
|||
|
||||
getTypeRootsVersion() {
|
||||
const roots = ts.getEffectiveTypeRoots(this.project.getCompilerOptions(), this);
|
||||
if (roots && roots.length > 0) {
|
||||
return Math.max.apply(Math, roots.map(root => {
|
||||
return +this.host.getModifiedTime(root);
|
||||
}));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return getLatestChangeTime(roots, this.host);
|
||||
}
|
||||
|
||||
getScriptKind(fileName: string) {
|
||||
|
|
|
@ -90,6 +90,21 @@ namespace ts.server {
|
|||
};
|
||||
}
|
||||
|
||||
export function getLatestDirectoryChangeTime(paths: string[] | undefined, host: System) {
|
||||
if (!host.getModifiedTime || !host.directoryExists || !paths) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max.apply(Math, paths.map(path => {
|
||||
if (host.directoryExists(path)) {
|
||||
return host.getModifiedTime(path);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
export function mergeMaps(target: MapLike<any>, source: MapLike <any>): void {
|
||||
for (const key in source) {
|
||||
if (hasProperty(source, key)) {
|
||||
|
|
|
@ -1188,7 +1188,7 @@ namespace ts {
|
|||
/*
|
||||
* LS host can optionally implement these methods to support automatic updating when new type libraries are installed
|
||||
*/
|
||||
getTypeRootsVersion(): number;
|
||||
getTypeRootsVersion?(): number;
|
||||
|
||||
/*
|
||||
* LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
|
||||
|
|
Loading…
Reference in a new issue