Skip to content

Commit c080643

Browse files
committed
Refactor
1 parent 46dfd68 commit c080643

File tree

6 files changed

+20
-21
lines changed

6 files changed

+20
-21
lines changed

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,5 +1932,5 @@ namespace Harness {
19321932
return { unitName: libFile, content: io.readFile(libFile) };
19331933
}
19341934

1935-
if (Error) (<any>Error).stackTraceLimit = 25;
1935+
if (Error) (<any>Error).stackTraceLimit = 1;
19361936
}

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ namespace Harness.LanguageService {
370370
function unwrapJSONCallResult(result: string): any {
371371
const parsedResult = JSON.parse(result);
372372
if (parsedResult.error) {
373-
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult));
373+
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
374374
}
375375
else if (parsedResult.canceled) {
376376
throw new ts.OperationCanceledException();

src/server/editorServices.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,17 +389,7 @@ namespace ts.server {
389389
}
390390

391391
getTypeRootsVersion(project: ConfiguredProject) {
392-
const roots = project.getEffectiveTypeRoots();
393-
if (roots === undefined) {
394-
return 0;
395-
}
396-
397-
return Math.max.apply(Math, project.getEffectiveTypeRoots().map(root => {
398-
if (this.host.directoryExists(root)) {
399-
return +this.host.getModifiedTime(root);
400-
}
401-
return 0;
402-
}));
392+
return getLatestDirectoryChangeTime(project.getEffectiveTypeRoots(), this.host);
403393
}
404394

405395
private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject) {

src/server/lsHost.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,7 @@ namespace ts.server {
147147

148148
getTypeRootsVersion() {
149149
const roots = ts.getEffectiveTypeRoots(this.project.getCompilerOptions(), this);
150-
if (roots && roots.length > 0) {
151-
return Math.max.apply(Math, roots.map(root => {
152-
return +this.host.getModifiedTime(root);
153-
}));
154-
} else {
155-
return 0;
156-
}
150+
return getLatestChangeTime(roots, this.host);
157151
}
158152

159153
getScriptKind(fileName: string) {

src/server/utilities.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ namespace ts.server {
9090
};
9191
}
9292

93+
export function getLatestDirectoryChangeTime(paths: string[] | undefined, host: System) {
94+
if (!host.getModifiedTime || !host.directoryExists || !paths) {
95+
return 0;
96+
}
97+
98+
return Math.max.apply(Math, paths.map(path => {
99+
if (host.directoryExists(path)) {
100+
return host.getModifiedTime(path);
101+
}
102+
else {
103+
return 0;
104+
}
105+
}));
106+
}
107+
93108
export function mergeMaps(target: MapLike<any>, source: MapLike <any>): void {
94109
for (const key in source) {
95110
if (hasProperty(source, key)) {

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ namespace ts {
11881188
/*
11891189
* LS host can optionally implement these methods to support automatic updating when new type libraries are installed
11901190
*/
1191-
getTypeRootsVersion(): number;
1191+
getTypeRootsVersion?(): number;
11921192

11931193
/*
11941194
* LS host can optionally implement this method if it wants to be completely in charge of module name resolution.

0 commit comments

Comments
 (0)