Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect "Unsupported activation event" error in stdout #12953 #13095

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether the additional activation events shouldn't be part of the PluginManagerInitializeParams used in the $init call to initialize the plugin manager. It already contains the some other setup data and is also called before the $start method with the PluginManagerStartParams where we get the first set of activation events. I think that would also give us a more fine-grained option to handle how those events are obtained and maybe even provide different events for different plugin managers. For now I'm fine if they are still coming from environment variables, just gathered in the hosted-plugin.ts during initialization of the manager and added as a dedicated, optional parameter.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, please have another look at the changes.
I've moved the known events + reading the env var to hosted-plugin.ts and extended the PluginManagerInitializeParams to include the supported events.

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
Loading