Skip to content

Commit

Permalink
Incorrect "Unsupported activation event" error in stdout #12953
Browse files Browse the repository at this point in the history
* add env variable which allows adding additional activation events
  • Loading branch information
jfaltermeier committed Nov 16, 2023
1 parent 7ad7f22 commit 838f6d1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ActivatedPlugin {

export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {

static SUPPORTED_ACTIVATION_EVENTS = new Set([
static BUILTIN_ACTIVATION_EVENTS = new Set([
'*',
'onLanguage',
'onCommand',
Expand All @@ -101,6 +101,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
'onNotebook',
'onNotebookSerializer'
]);
static ADDITIONAL_ACTIVATION_EVENTS_ENV = 'ADDITIONAL_ACTIVATION_EVENTS';

private configStorage: ConfigStorage | undefined;
private readonly registry = new Map<string, Plugin>();
Expand All @@ -113,6 +114,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
private onDidChangeEmitter = new Emitter<void>();
private messageRegistryProxy: MessageRegistryMain;
private notificationMain: NotificationMain;
private supportedActivationEvents: Set<string>;
protected fireOnDidChange(): void {
this.onDidChangeEmitter.fire(undefined);
}
Expand Down Expand Up @@ -219,6 +221,12 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {

this.webview.init(params.webview);
this.jsonValidation = params.jsonValidation;

this.supportedActivationEvents = new Set(PluginManagerExtImpl.BUILTIN_ACTIVATION_EVENTS);
const additionalActivationEvents = await this.envExt.getEnvVariable(PluginManagerExtImpl.ADDITIONAL_ACTIVATION_EVENTS_ENV);
if (additionalActivationEvents) {
additionalActivationEvents.split(',').forEach(event => this.supportedActivationEvents.add(event));
}
}

async $start(params: PluginManagerStartParams): Promise<void> {
Expand Down Expand Up @@ -263,7 +271,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
const activation = () => this.$activatePlugin(plugin.model.id);
// an internal activation event is a subject to change
this.setActivation(`onPlugin:${plugin.model.id}`, activation);
const unsupportedActivationEvents = plugin.rawModel.activationEvents.filter(e => !PluginManagerExtImpl.SUPPORTED_ACTIVATION_EVENTS.has(e.split(':')[0]));
const unsupportedActivationEvents = plugin.rawModel.activationEvents.filter(e => !this.supportedActivationEvents.has(e.split(':')[0]));
if (unsupportedActivationEvents.length) {
console.warn(`Unsupported activation events: ${unsupportedActivationEvents.join(', ')}, please open an issue: https://github.com/eclipse-theia/theia/issues/new`);
}
Expand Down

0 comments on commit 838f6d1

Please sign in to comment.