Skip to content

Commit

Permalink
Support for "--headless-hosted-plugin-inspect" cmd argument #13462
Browse files Browse the repository at this point in the history
* refactor to directly set servername on backend instead of handing it
down from frontend
  • Loading branch information
jfaltermeier committed Jul 12, 2024
1 parent 55c7385 commit 57ea516
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ export class HeadlessHostedPluginSupport extends AbstractHostedPluginSupport<Hea
this.pluginProcess.terminatePluginServer();
}

protected override getServerName(): string {
return 'headless-hosted-plugin';
}

protected createTheiaReadyPromise(): Promise<unknown> {
return Promise.all([this.envServer.getVariables()]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// *****************************************************************************
// Copyright (C) 2024 EclipseSource and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { injectable } from '@theia/core/shared/inversify';
import { HostedPluginServerImpl } from '@theia/plugin-ext/lib/hosted/node/plugin-service';

@injectable()
export class HeadlessHostedPluginServerImpl extends HostedPluginServerImpl {
protected override getServerName(): string {
return 'headless-hosted-plugin';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
import { ExtPluginApiProvider, HostedPluginServer, PluginHostEnvironmentVariable, PluginScanner } from '@theia/plugin-ext';
import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/node/hosted-plugin';
import { HostedPluginProcess, HostedPluginProcessConfiguration } from '@theia/plugin-ext/lib/hosted/node/hosted-plugin-process';
import { BackendPluginHostableFilter, HostedPluginServerImpl } from '@theia/plugin-ext/lib/hosted/node/plugin-service';
import { BackendPluginHostableFilter } from '@theia/plugin-ext/lib/hosted/node/plugin-service';
import { MaybePromise } from '@theia/core';
import { HeadlessPluginContainerModule } from '../../common/headless-plugin-container';
import { HeadlessHostedPluginSupport, isHeadlessPlugin } from './headless-hosted-plugin';
import { TheiaHeadlessPluginScanner } from './scanners/scanner-theia-headless';
import { SupportedHeadlessActivationEvents } from '../../common/headless-plugin-protocol';
import { HeadlessHostedPluginServerImpl } from './headless-plugin-service';

export function bindCommonHostedBackend(bind: interfaces.Bind): void {
bind(HostedPluginProcess).toSelf().inSingletonScope();
Expand All @@ -36,8 +37,8 @@ export function bindCommonHostedBackend(bind: interfaces.Bind): void {
bindContributionProvider(bind, PluginHostEnvironmentVariable);
bindContributionProvider(bind, SupportedHeadlessActivationEvents);

bind(HostedPluginServerImpl).toSelf().inSingletonScope();
bind(HostedPluginServer).toService(HostedPluginServerImpl);
bind(HeadlessHostedPluginServerImpl).toSelf().inSingletonScope();
bind(HostedPluginServer).toService(HeadlessHostedPluginServerImpl);
bind(HeadlessHostedPluginSupport).toSelf().inSingletonScope();
bind(BackendPluginHostableFilter).toConstantValue(isHeadlessPlugin);

Expand Down
2 changes: 0 additions & 2 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,6 @@ export interface HostedPluginServer extends RpcServer<HostedPluginClient> {

onMessage(targetHost: string, message: Uint8Array): Promise<void>;

setServerName(name: string): Promise<void>;

}

export const PLUGIN_HOST_BACKEND = 'main';
Expand Down
5 changes: 0 additions & 5 deletions packages/plugin-ext/src/hosted/common/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,9 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag

@postConstruct()
protected init(): void {
this.server.setServerName(this.getServerName());
this.theiaReadyPromise = this.createTheiaReadyPromise();
}

protected getServerName(): string {
return 'hosted-plugin';
}

protected abstract createTheiaReadyPromise(): Promise<unknown>;

get plugins(): PluginMetadata[] {
Expand Down
13 changes: 7 additions & 6 deletions packages/plugin-ext/src/hosted/node/plugin-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class HostedPluginServerImpl implements HostedPluginServer {
protected toDispose = new DisposableCollection();

protected _ignoredPlugins?: Set<PluginIdentifiers.VersionedId>;
protected serverName?: string;
protected serverName: string;

// We ignore any plugins that are marked as uninstalled the first time the frontend requests information about deployed plugins.
protected get ignoredPlugins(): Set<PluginIdentifiers.VersionedId> {
Expand All @@ -77,6 +77,8 @@ export class HostedPluginServerImpl implements HostedPluginServer {

@postConstruct()
protected init(): void {
this.serverName = this.getServerName();

if (!this.backendPluginHostableFilter) {
this.backendPluginHostableFilter = () => true;
}
Expand All @@ -98,6 +100,10 @@ export class HostedPluginServerImpl implements HostedPluginServer {
]);
}

protected getServerName(): string {
return 'hosted-plugin';
}

dispose(): void {
this.toDispose.dispose();
}
Expand Down Expand Up @@ -191,9 +197,4 @@ export class HostedPluginServerImpl implements HostedPluginServer {
getExtPluginAPI(): Promise<ExtPluginApi[]> {
return Promise.resolve(this.extPluginAPIContributions.getContributions().map(p => p.provideApi()));
}

setServerName(name: string): Promise<void> {
this.serverName = name;
return Promise.resolve();
}
}

0 comments on commit 57ea516

Please sign in to comment.