mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Address more PR comments
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
{ "path": "../compiler" },
|
||||
{ "path": "../jsTyping" },
|
||||
{ "path": "../services" },
|
||||
{ "path": "../vfs", "prepend": true }
|
||||
{ "path": "../vfs" }
|
||||
],
|
||||
"files": [
|
||||
"types.ts",
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace ts.projectSystem {
|
||||
class TestWorkerSession extends server.WorkerSession {
|
||||
constructor(host: server.ServerHost, webHost: server.HostWithWriteMessage, options: Partial<server.StartSessionOptions>, logger: server.Logger) {
|
||||
super(
|
||||
host,
|
||||
host,
|
||||
webHost,
|
||||
{
|
||||
|
||||
@@ -383,7 +383,7 @@ namespace ts.server {
|
||||
return eventPort !== undefined && !isNaN(eventPort) ? eventPort : undefined;
|
||||
}
|
||||
|
||||
function startNodeSession(options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, fs: ServerHost) {
|
||||
function startNodeSession(options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, fshost: ServerHost) {
|
||||
const childProcess: {
|
||||
fork(modulePath: string, args: string[], options?: { execArgv: string[], env?: MapLike<string> }): NodeChildProcess;
|
||||
} = require("child_process");
|
||||
@@ -680,7 +680,7 @@ namespace ts.server {
|
||||
this.event(body, eventName);
|
||||
};
|
||||
|
||||
const host = fs; // sys as ServerHost;
|
||||
const host = sys as ServerHost;
|
||||
|
||||
const typingsInstaller = disableAutomaticTypingAcquisition
|
||||
? undefined
|
||||
@@ -688,7 +688,7 @@ namespace ts.server {
|
||||
|
||||
super({
|
||||
host,
|
||||
fshost: host,
|
||||
fshost,
|
||||
cancellationToken,
|
||||
...options,
|
||||
typingsInstaller: typingsInstaller || nullTypingsInstaller,
|
||||
@@ -789,7 +789,7 @@ namespace ts.server {
|
||||
|
||||
const eventPort: number | undefined = parseEventPort(findArgument("--eventPort"));
|
||||
const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation)!; // TODO: GH#18217
|
||||
const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(getDirectoryPath(fs.getExecutingFilePath()), "typesMap.json");
|
||||
const typesMapLocation = findArgument(Arguments.TypesMapLocation) || combinePaths(getDirectoryPath(fshost.getExecutingFilePath()), "typesMap.json");
|
||||
const npmLocation = findArgument(Arguments.NpmLocation);
|
||||
const validateDefaultNpmLocation = hasArgument(Arguments.ValidateDefaultNpmLocation);
|
||||
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
|
||||
|
||||
@@ -30,14 +30,15 @@ namespace ts.server {
|
||||
unknownServerMode?: string;
|
||||
startSession: (option: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, fs: ServerHost) => void;
|
||||
}
|
||||
function start({ args, logger, cancellationToken, serverMode, unknownServerMode, startSession: startServer }: StartInput, platform: string, fs: ServerHost) {
|
||||
function start({ args, logger, cancellationToken, serverMode, unknownServerMode, startSession: startServer }: StartInput, platform: string) {
|
||||
const syntaxOnly = hasArgument("--syntaxOnly");
|
||||
const vfs = hasArgument("--vfs");
|
||||
|
||||
logger.info(`Starting TS Server`);
|
||||
logger.info(`Version: ${version}`);
|
||||
logger.info(`Arguments: ${args.join(" ")}`);
|
||||
logger.info(`Platform: ${platform} NodeVersion: ${getNodeMajorVersion()} CaseSensitive: ${sys.useCaseSensitiveFileNames}`);
|
||||
logger.info(`ServerMode: ${serverMode} syntaxOnly: ${syntaxOnly} hasUnknownServerMode: ${unknownServerMode}`);
|
||||
logger.info(`ServerMode: ${serverMode} syntaxOnly: ${syntaxOnly} hasUnknownServerMode: ${unknownServerMode} vfs: ${vfs}`);
|
||||
|
||||
setStackTraceLimit();
|
||||
|
||||
@@ -57,6 +58,7 @@ 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 ? TestFSWithWatch.createVirtualServerHost([]) : sys as ServerHost;
|
||||
startServer(
|
||||
{
|
||||
globalPlugins: findArgumentStringArray("--globalPlugins"),
|
||||
@@ -71,23 +73,21 @@ namespace ts.server {
|
||||
},
|
||||
logger,
|
||||
cancellationToken,
|
||||
fs
|
||||
fshost
|
||||
);
|
||||
}
|
||||
|
||||
setStackTraceLimit();
|
||||
// TODO: Not sure this is right
|
||||
const fs = findArgument("vfs") ? TestFSWithWatch.createVirtualServerHost([]) : sys as ServerHost;
|
||||
// Cannot check process var directory in webworker so has to be typeof check here
|
||||
if (typeof process !== "undefined") {
|
||||
start(initializeNodeSystem(), require("os").platform(), fs);
|
||||
start(initializeNodeSystem(), require("os").platform());
|
||||
}
|
||||
else {
|
||||
// Get args from first message
|
||||
const listener = (e: any) => {
|
||||
removeEventListener("message", listener);
|
||||
const args = e.data;
|
||||
start(initializeWebSystem(args), "web", fs);
|
||||
start(initializeWebSystem(args), "web");
|
||||
};
|
||||
addEventListener("message", listener);
|
||||
}
|
||||
|
||||
@@ -96,13 +96,10 @@ namespace ts.server {
|
||||
return [seconds, nanoseconds];
|
||||
}
|
||||
|
||||
// TODO: Maybe should leave as ServerHost cast below and declare fs: System
|
||||
// TODO: host is probably still a better name
|
||||
function startWebSession(options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, _fs_TODO: ServerHost) {
|
||||
function startWebSession(options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, fshost: ServerHost) {
|
||||
class WorkerSession extends server.WorkerSession {
|
||||
constructor() {
|
||||
// TODO: Not really sure this is the way to do it
|
||||
super(sys as ServerHost, { writeMessage }, options, logger, cancellationToken, hrtime);
|
||||
super(sys as ServerHost, fshost, { writeMessage }, options, logger, cancellationToken, hrtime);
|
||||
}
|
||||
|
||||
exit() {
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace ts.TestFSWithWatch {
|
||||
}
|
||||
|
||||
if (options && options.invokeFileDeleteCreateAsPartInsteadOfChange) {
|
||||
this.removeFileOrFolder(currentEntry, false);
|
||||
this.removeFileOrFolder(currentEntry, /*isRemoveableLeafFolder*/ false);
|
||||
this.ensureFileOrFolder({ path: filePath, content });
|
||||
}
|
||||
else {
|
||||
@@ -363,7 +363,7 @@ namespace ts.TestFSWithWatch {
|
||||
Debug.assert(!!file);
|
||||
|
||||
// Only remove the file
|
||||
this.removeFileOrFolder(file, false, /*isRenaming*/ true);
|
||||
this.removeFileOrFolder(file, /*isRemoveableLeafFolder*/ false, /*isRenaming*/ true);
|
||||
|
||||
// Add updated folder with new folder name
|
||||
const newFullPath = getNormalizedAbsolutePath(newFileName, this.currentDirectory);
|
||||
@@ -383,7 +383,7 @@ namespace ts.TestFSWithWatch {
|
||||
Debug.assert(!!folder);
|
||||
|
||||
// Only remove the folder
|
||||
this.removeFileOrFolder(folder, false, /*isRenaming*/ true);
|
||||
this.removeFileOrFolder(folder, /*isRemoveableLeafFolder*/ false, /*isRenaming*/ true);
|
||||
|
||||
// Add updated folder with new folder name
|
||||
const newFullPath = getNormalizedAbsolutePath(newFolderName, this.currentDirectory);
|
||||
@@ -514,11 +514,11 @@ namespace ts.TestFSWithWatch {
|
||||
this.deleteFolder(fsEntry.fullPath, recursive);
|
||||
}
|
||||
else {
|
||||
this.removeFileOrFolder(fsEntry, false);
|
||||
this.removeFileOrFolder(fsEntry, /*isRemoveableLeafFolder*/ false);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.removeFileOrFolder(currentEntry, false);
|
||||
this.removeFileOrFolder(currentEntry, /*isRemoveableLeafFolder*/ false);
|
||||
}
|
||||
|
||||
private watchFileWorker(fileName: string, cb: FileWatcherCallback, pollingInterval: PollingInterval) {
|
||||
|
||||
@@ -178,10 +178,10 @@ namespace ts.server {
|
||||
serverMode: SessionOptions["serverMode"];
|
||||
}
|
||||
export class WorkerSession extends Session<{}> {
|
||||
constructor(host: ServerHost, private webHost: HostWithWriteMessage, options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, hrtime: SessionOptions["hrtime"]) {
|
||||
constructor(host: ServerHost, fshost: ServerHost, private webHost: HostWithWriteMessage, options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken, hrtime: SessionOptions["hrtime"]) {
|
||||
super({
|
||||
host,
|
||||
fshost: undefined, // TODO: Provide this? Check Sheetal's comments.
|
||||
fshost,
|
||||
cancellationToken,
|
||||
...options,
|
||||
typingsInstaller: nullTypingsInstaller,
|
||||
|
||||
Reference in New Issue
Block a user