mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
Expose TS server tracing (#110534)
* Add typescript.tsserver.enableTracing setting * Document typescript.tsserver.enableTracing setting
This commit is contained in:
@@ -128,7 +128,7 @@ export class TypeScriptServerSpawner {
|
||||
const apiVersion = version.apiVersion || API.defaultVersion;
|
||||
|
||||
const canceller = cancellerFactory.create(kind, this._tracer);
|
||||
const { args, tsServerLogFile } = this.getTsServerArgs(kind, configuration, version, apiVersion, pluginManager, canceller.cancellationPipeName);
|
||||
const { args, tsServerLogFile, tsServerTraceDirectory } = this.getTsServerArgs(kind, configuration, version, apiVersion, pluginManager, canceller.cancellationPipeName);
|
||||
|
||||
if (TypeScriptServerSpawner.isLoggingEnabled(configuration)) {
|
||||
if (tsServerLogFile) {
|
||||
@@ -138,6 +138,14 @@ export class TypeScriptServerSpawner {
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration.enableTsServerTracing) {
|
||||
if (tsServerTraceDirectory) {
|
||||
this._logger.info(`<${kind}> Trace directory: ${tsServerTraceDirectory}`);
|
||||
} else {
|
||||
this._logger.error(`<${kind}> Could not create trace directory`);
|
||||
}
|
||||
}
|
||||
|
||||
this._logger.info(`<${kind}> Forking...`);
|
||||
const process = this._factory.fork(version.tsServerPath, args, kind, configuration, this._versionManager);
|
||||
this._logger.info(`<${kind}> Starting...`);
|
||||
@@ -173,9 +181,10 @@ export class TypeScriptServerSpawner {
|
||||
apiVersion: API,
|
||||
pluginManager: PluginManager,
|
||||
cancellationPipeName: string | undefined,
|
||||
): { args: string[], tsServerLogFile: string | undefined } {
|
||||
): { args: string[], tsServerLogFile: string | undefined, tsServerTraceDirectory: string | undefined } {
|
||||
const args: string[] = [];
|
||||
let tsServerLogFile: string | undefined;
|
||||
let tsServerTraceDirectory: string | undefined;
|
||||
|
||||
if (kind === TsServerProcessKind.Syntax) {
|
||||
if (apiVersion.gte(API.v401)) {
|
||||
@@ -216,6 +225,13 @@ export class TypeScriptServerSpawner {
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration.enableTsServerTracing && !isWeb()) {
|
||||
tsServerTraceDirectory = this._logDirectoryProvider.getNewLogDirectory();
|
||||
if (tsServerTraceDirectory) {
|
||||
args.push('--traceDirectory', tsServerTraceDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWeb()) {
|
||||
const pluginPaths = this._pluginPathsProvider.getPluginPaths();
|
||||
|
||||
@@ -251,7 +267,7 @@ export class TypeScriptServerSpawner {
|
||||
args.push('--validateDefaultNpmLocation');
|
||||
}
|
||||
|
||||
return { args, tsServerLogFile };
|
||||
return { args, tsServerLogFile, tsServerTraceDirectory };
|
||||
}
|
||||
|
||||
private static isLoggingEnabled(configuration: TypeScriptServiceConfiguration) {
|
||||
|
||||
@@ -102,6 +102,7 @@ export class TypeScriptServiceConfiguration {
|
||||
public readonly enablePromptUseWorkspaceTsdk: boolean;
|
||||
public readonly watchOptions: protocol.WatchOptions | undefined;
|
||||
public readonly includePackageJsonAutoImports: 'auto' | 'on' | 'off' | undefined;
|
||||
public readonly enableTsServerTracing: boolean;
|
||||
|
||||
public static loadFromWorkspace(): TypeScriptServiceConfiguration {
|
||||
return new TypeScriptServiceConfiguration();
|
||||
@@ -124,6 +125,7 @@ export class TypeScriptServiceConfiguration {
|
||||
this.enablePromptUseWorkspaceTsdk = TypeScriptServiceConfiguration.readEnablePromptUseWorkspaceTsdk(configuration);
|
||||
this.watchOptions = TypeScriptServiceConfiguration.readWatchOptions(configuration);
|
||||
this.includePackageJsonAutoImports = TypeScriptServiceConfiguration.readIncludePackageJsonAutoImports(configuration);
|
||||
this.enableTsServerTracing = TypeScriptServiceConfiguration.readEnableTsServerTracing(configuration);
|
||||
}
|
||||
|
||||
public isEqualTo(other: TypeScriptServiceConfiguration): boolean {
|
||||
@@ -210,4 +212,8 @@ export class TypeScriptServiceConfiguration {
|
||||
private static readEnablePromptUseWorkspaceTsdk(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('typescript.enablePromptUseWorkspaceTsdk', false);
|
||||
}
|
||||
|
||||
private static readEnableTsServerTracing(configuration: vscode.WorkspaceConfiguration): boolean {
|
||||
return configuration.get<boolean>('typescript.tsserver.enableTracing', false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user