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
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export interface PluginManagerInitializeParams {
extApi?: ExtPluginApi[]
webview: WebviewInitData
jsonValidation: PluginJsonValidationContribution[]
supportedActivationEvents?: string[]
}

export interface PluginManagerStartParams {
Expand Down
34 changes: 33 additions & 1 deletion packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ export const ALL_ACTIVATION_EVENT = '*';
@injectable()
export class HostedPluginSupport {

protected static ADDITIONAL_ACTIVATION_EVENTS_ENV = 'ADDITIONAL_ACTIVATION_EVENTS';
protected static BUILTIN_ACTIVATION_EVENTS = [
'*',
'onLanguage',
'onCommand',
'onDebug',
'onDebugInitialConfigurations',
'onDebugResolve',
'onDebugAdapterProtocolTracker',
'onDebugDynamicConfigurations',
'onTaskType',
'workspaceContains',
'onView',
'onUri',
'onTerminalProfile',
'onWebviewPanel',
'onFileSystem',
'onCustomEditor',
'onStartupFinished',
'onAuthenticationRequest',
'onNotebook',
'onNotebookSerializer'
];

protected readonly clientId = UUID.uuid4();

protected container: interfaces.Container;
Expand Down Expand Up @@ -519,6 +543,13 @@ export class HostedPluginSupport {
}

const isElectron = environment.electron.is();

const supportedActivationEvents = [...HostedPluginSupport.BUILTIN_ACTIVATION_EVENTS];
const additionalActivationEvents = await this.envServer.getValue(HostedPluginSupport.ADDITIONAL_ACTIVATION_EVENTS_ENV);
if (additionalActivationEvents && additionalActivationEvents.value) {
additionalActivationEvents.value.split(',').forEach(event => supportedActivationEvents.push(event));
}

await manager.$init({
preferences: getPreferences(this.preferenceProviderProvider, this.workspaceService.tryGetRoots()),
globalState,
Expand All @@ -536,7 +567,8 @@ export class HostedPluginSupport {
webviewResourceRoot,
webviewCspSource
},
jsonValidation
jsonValidation,
supportedActivationEvents
});
if (toDisconnect.disposed) {
return undefined;
Expand Down
28 changes: 4 additions & 24 deletions packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,6 @@ class ActivatedPlugin {

export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {

static SUPPORTED_ACTIVATION_EVENTS = new Set([
'*',
'onLanguage',
'onCommand',
'onDebug',
'onDebugInitialConfigurations',
'onDebugResolve',
'onDebugAdapterProtocolTracker',
'onDebugDynamicConfigurations',
'onTaskType',
'workspaceContains',
'onView',
'onUri',
'onTerminalProfile',
'onWebviewPanel',
'onFileSystem',
'onCustomEditor',
'onStartupFinished',
'onAuthenticationRequest',
'onNotebook',
'onNotebookSerializer'
]);

private configStorage: ConfigStorage | undefined;
private readonly registry = new Map<string, Plugin>();
private readonly activations = new Map<string, (() => Promise<void>)[] | undefined>();
Expand All @@ -113,6 +90,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 +197,8 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {

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

this.supportedActivationEvents = new Set(params.supportedActivationEvents ?? []);
}

async $start(params: PluginManagerStartParams): Promise<void> {
Expand Down Expand Up @@ -263,7 +243,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