mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Construct VirtualServerHost directly in tsserver
This commit is contained in:
@@ -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
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user