mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
Prototype Extension Contributed TS Plugins (#24917)
* Prototype TS plugin from extension support * Update to take typescriptServerPlugins as an array objects instead of strings * Use extension path
This commit is contained in:
@@ -13,7 +13,7 @@ import * as os from 'os';
|
||||
import * as electron from './utils/electron';
|
||||
import { Reader } from './utils/wireProtocol';
|
||||
|
||||
import { workspace, window, Uri, CancellationToken, Disposable, OutputChannel, Memento, MessageItem, QuickPickItem, EventEmitter, Event, commands, WorkspaceConfiguration } from 'vscode';
|
||||
import { workspace, window, extensions, Uri, CancellationToken, Disposable, OutputChannel, Memento, MessageItem, QuickPickItem, EventEmitter, Event, commands, WorkspaceConfiguration } from 'vscode';
|
||||
import * as Proto from './protocol';
|
||||
import { ITypescriptServiceClient, ITypescriptServiceClientHost, API } from './typescriptService';
|
||||
|
||||
@@ -121,6 +121,11 @@ interface MyMessageItem extends MessageItem {
|
||||
id: MessageAction;
|
||||
}
|
||||
|
||||
interface TypeScriptServerPlugin {
|
||||
path: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
||||
export default class TypeScriptServiceClient implements ITypescriptServiceClient {
|
||||
private static useWorkspaceTsdkStorageKey = 'typescript.useWorkspaceTsdk';
|
||||
@@ -578,6 +583,14 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
}
|
||||
}
|
||||
|
||||
if (this.apiVersion.has230Features()) {
|
||||
const plugins = this.getContributedTypeScriptServerPlugins();
|
||||
if (plugins.length) {
|
||||
args.push('--globalPlugins', plugins.map(x => x.name).join(','));
|
||||
args.push('--pluginProbeLocations', plugins.map(x => x.path).join(','));
|
||||
}
|
||||
}
|
||||
|
||||
electron.fork(modulePath, args, options, (err: any, childProcess: cp.ChildProcess) => {
|
||||
if (err) {
|
||||
this.lastError = err;
|
||||
@@ -816,6 +829,22 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
|
||||
return desc.version;
|
||||
}
|
||||
|
||||
private getContributedTypeScriptServerPlugins(): TypeScriptServerPlugin[] {
|
||||
const plugins: TypeScriptServerPlugin[] = [];
|
||||
for (const extension of extensions.all) {
|
||||
const pack = extension.packageJSON;
|
||||
if (pack.contributes && pack.contributes.typescriptServerPlugins && Array.isArray(pack.contributes.typescriptServerPlugins)) {
|
||||
for (const plugin of pack.contributes.typescriptServerPlugins) {
|
||||
plugins.push({
|
||||
name: plugin.name,
|
||||
path: extension.extensionPath
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private serviceExited(restart: boolean): void {
|
||||
this.servicePromise = null;
|
||||
Object.keys(this.callbacks).forEach((key) => {
|
||||
|
||||
Reference in New Issue
Block a user