mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
* Remove webServer
First draft; I may move some things around to be more readable.
* Refactor moved code
1. Move StartSessionOptions to common next to where it's first used.
2. Inline single-use BaseLogger base class into its only child class,
Logger.
3. Start using direct imports, eg `import {} from './common'`. I hope
this is OK?!
* Fix lint
* move imports back to namespace import
* hereby tsserver: remove exportIsTsObject
74 lines
2.7 KiB
TypeScript
74 lines
2.7 KiB
TypeScript
import {
|
|
emptyArray,
|
|
findArgument,
|
|
hasArgument,
|
|
initializeNodeSystem,
|
|
Msg,
|
|
StartInput,
|
|
} from "./_namespaces/ts.server";
|
|
import {
|
|
Debug,
|
|
getNodeMajorVersion,
|
|
setStackTraceLimit,
|
|
sys,
|
|
version,
|
|
} from "./_namespaces/ts";
|
|
|
|
export * from "./_namespaces/ts";
|
|
|
|
function findArgumentStringArray(argName: string): readonly string[] {
|
|
const arg = findArgument(argName);
|
|
if (arg === undefined) {
|
|
return emptyArray;
|
|
}
|
|
return arg.split(",").filter(name => name !== "");
|
|
}
|
|
|
|
|
|
function start({ args, logger, cancellationToken, serverMode, unknownServerMode, startSession: startServer }: StartInput, platform: string) {
|
|
const syntaxOnly = hasArgument("--syntaxOnly");
|
|
|
|
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}`);
|
|
|
|
setStackTraceLimit();
|
|
|
|
if (Debug.isDebugging) {
|
|
Debug.enableDebugInfo();
|
|
}
|
|
|
|
if (sys.tryEnableSourceMapsForHost && /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"))) {
|
|
sys.tryEnableSourceMapsForHost();
|
|
}
|
|
|
|
// Overwrites the current console messages to instead write to
|
|
// the log. This is so that language service plugins which use
|
|
// console.log don't break the message passing between tsserver
|
|
// and the client
|
|
console.log = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Info);
|
|
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);
|
|
|
|
startServer(
|
|
{
|
|
globalPlugins: findArgumentStringArray("--globalPlugins"),
|
|
pluginProbeLocations: findArgumentStringArray("--pluginProbeLocations"),
|
|
allowLocalPluginLoads: hasArgument("--allowLocalPluginLoads"),
|
|
useSingleInferredProject: hasArgument("--useSingleInferredProject"),
|
|
useInferredProjectPerProjectRoot: hasArgument("--useInferredProjectPerProjectRoot"),
|
|
suppressDiagnosticEvents: hasArgument("--suppressDiagnosticEvents"),
|
|
noGetErrOnBackgroundUpdate: hasArgument("--noGetErrOnBackgroundUpdate"),
|
|
syntaxOnly,
|
|
serverMode
|
|
},
|
|
logger,
|
|
cancellationToken
|
|
);
|
|
}
|
|
|
|
setStackTraceLimit();
|
|
start(initializeNodeSystem(), require("os").platform());
|