Construct VirtualServerHost directly in tsserver

This commit is contained in:
Nathan Shively-Sanders
2022-05-11 08:24:18 -07:00
parent 04ce89c804
commit 3c8ab33413
3 changed files with 20 additions and 13 deletions
@@ -53,6 +53,14 @@ interface Array<T> { length: number; [n: number]: T; }`
return host;
}
export function createVirtualServerHost(params: VirtualServerHostCreationParameters): VirtualServerHost {
const host = new VirtualServerHost(params);
host.init();
// Just like sys, patch the host to use writeFile
patchWriteFileEnsuringDirectory(host);
return host;
}
class Callbacks {
private map: TimeOutCallback[] = [];
private nextId = 1;
+12 -5
View File
@@ -58,11 +58,18 @@ namespace ts.server {
console.warn = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err);
console.error = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err);
const fshost = vfs ? VirtualFS.createVirtualServerHost([], {
useCaseSensitiveFileNames: sys.useCaseSensitiveFileNames,
executingFilePath: "", // TODO: "" is the default..maybe this should be vfs, vfs:// or .
newLine: sys.newLine,
}) : sys as ServerHost;
let fshost
if (vfs) {
fshost = new VirtualFS.VirtualServerHost({
useCaseSensitiveFileNames: sys.useCaseSensitiveFileNames,
executingFilePath: "", // TODO: "" is the default..maybe this should be vfs, vfs:// or .
newLine: sys.newLine,
})
fshost.init()
}
else {
fshost = sys as ServerHost;
}
startServer(
{
globalPlugins: findArgumentStringArray("--globalPlugins"),
-8
View File
@@ -8,14 +8,6 @@ namespace ts.VirtualFS {
windowsStyleRoot?: string;
}
export function createVirtualServerHost(params: VirtualServerHostCreationParameters): VirtualServerHost {
const host = new VirtualServerHost(params);
host.init();
// Just like sys, patch the host to use writeFile
patchWriteFileEnsuringDirectory(host);
return host;
}
export interface File {
path: string;
content: string;