提交 2f18a14a 编写于 作者: M Mine Starks 提交者: Matt Bierner

Support configuring TypeScript plugins (#61756)

上级 26c3d8d8
......@@ -105,6 +105,18 @@ export class JavaScriptGoToProjectConfigCommand implements Command {
}
}
export class ConfigurePluginCommand implements Command {
public readonly id = '_typescript.configurePlugin';
public constructor(
private readonly lazyClientHost: Lazy<TypeScriptServiceClientHost>,
) { }
public execute(pluginName: string, configuration: any) {
this.lazyClientHost.value.serviceClient.configurePlugin(pluginName, configuration, true /* reconfigureOnRestart */);
}
}
async function goToProjectConfig(
clientHost: TypeScriptServiceClientHost,
isTypeScriptProject: boolean,
......
......@@ -108,6 +108,7 @@ function registerCommands(
commandManager.register(new commands.RestartTsServerCommand(lazyClientHost));
commandManager.register(new commands.TypeScriptGoToProjectConfigCommand(lazyClientHost));
commandManager.register(new commands.JavaScriptGoToProjectConfigCommand(lazyClientHost));
commandManager.register(new commands.ConfigurePluginCommand(lazyClientHost));
}
function isSupportedDocument(
......
......@@ -71,6 +71,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
public readonly bufferSyncSupport: BufferSyncSupport;
public readonly diagnosticsManager: DiagnosticsManager;
private pluginConfigurations: Map<string, any>;
constructor(
private readonly workspaceState: vscode.Memento,
private readonly onDidChangeTypeScriptVersion: (version: TypeScriptVersion) => void,
......@@ -132,6 +134,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this.telemetryReporter = this._register(new TelemetryReporter(() => this._tsserverVersion || this._apiVersion.versionString));
this.typescriptServerSpawner = new TypeScriptServerSpawner(this.versionProvider, this.logDirectoryProvider, this.pluginPathsProvider, this.logger, this.telemetryReporter, this.tracer);
this.pluginConfigurations = new Map<string, any>();
}
public get configuration() {
......@@ -406,6 +409,11 @@ export default class TypeScriptServiceClient extends Disposable implements IType
if (resendModels) {
this._onResendModelsRequested.fire();
}
// Reconfigure any plugins
this.pluginConfigurations.forEach((config, pluginName) => {
this.configurePlugin(pluginName, config);
});
}
private setCompilerOptionsForInferredProjects(configuration: TypeScriptServiceConfiguration): void {
......@@ -719,8 +727,16 @@ export default class TypeScriptServiceClient extends Disposable implements IType
this._apiVersion = API.defaultVersion;
this._tsserverVersion = undefined;
}
}
public configurePlugin(pluginName: string, configuration: any, reconfigureOnRestart?: boolean): any {
this.executeWithoutWaitingForResponse('configurePlugin', { pluginName, configuration });
if (reconfigureOnRestart) {
// Remember the updated configuration so we can send the command again if TSServer restarts for any reason
this.pluginConfigurations.set(pluginName, configuration);
}
}
}
function getDignosticsKind(event: Proto.Event) {
switch (event.event) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册