Skip to content

Commit

Permalink
Remove plugins extra namespace
Browse files Browse the repository at this point in the history
Signed-off-by: thegecko <rob.moran@arm.com>
  • Loading branch information
thegecko committed Nov 29, 2022
1 parent 354b1d7 commit a8fcb73
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 77 deletions.
19 changes: 0 additions & 19 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -848,24 +848,6 @@ export function createAPIFactory(
};
/* End of Tests API */

const plugins: typeof theia.plugins = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get all(): theia.Plugin<any>[] {
return pluginManager.getAllPlugins().map(plg => new PluginExt(pluginManager, plg));
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getPlugin(pluginId: string): theia.Plugin<any> | undefined {
const plg = pluginManager.getPluginById(pluginId.toLowerCase());
if (plg) {
return new PluginExt(pluginManager, plg);
}
return undefined;
},
get onDidChange(): theia.Event<void> {
return pluginManager.onDidChange;
}
};

const debuggersContributions = plugin.rawModel.contributes && plugin.rawModel.contributes.debuggers || [];
debugExt.assistedInject(connectionExt, commandRegistry);
debugExt.registerDebuggersContributions(plugin.pluginFolder, plugin.model.entryPoint.frontend ? 'frontend' : 'backend', debuggersContributions);
Expand Down Expand Up @@ -991,7 +973,6 @@ export function createAPIFactory(
env,
extensions,
languages,
plugins,
debug,
tasks,
scm,
Expand Down
59 changes: 1 addition & 58 deletions packages/plugin/src/theia-extra.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,67 +37,10 @@ export module '@theia/plugin' {

export type PluginType = 'frontend' | 'backend';

/**
* Namespace for dealing with installed plug-ins. Plug-ins are represented
* by an [plug-in](#Plugin)-interface which enables reflection on them.
*
* Plug-in writers can provide APIs to other plug-ins by returning their API public
* surface from the `start`-call.
*
* ```javascript
* export function start() {
* let api = {
* sum(a, b) {
* return a + b;
* },
* mul(a, b) {
* return a * b;
* }
* };
* // 'export' public api-surface
* return api;
* }
* ```
* ```javascript
* let mathExt = plugins.getPlugin('genius.math');
* let importedApi = mathExt.exports;
*
* console.log(importedApi.mul(42, 1));
* ```
*/
export namespace plugins {
/**
* Get an plug-in by its full identifier in the form of: `publisher.name`.
*
* @param pluginId An plug-in identifier.
* @return An plug-in or `undefined`.
*/
export function getPlugin(pluginId: string): Plugin<any> | undefined;

/**
* Get an plug-in its full identifier in the form of: `publisher.name`.
*
* @param pluginId An plug-in identifier.
* @return An plug-in or `undefined`.
*/
export function getPlugin<T>(pluginId: string): Plugin<T> | undefined;

/**
* All plug-ins currently known to the system.
*/
export let all: Plugin<any>[];

/**
* An event which fires when `plugins.all` changes. This can happen when extensions are
* installed, uninstalled, enabled or disabled.
*/
export let onDidChange: Event<void>;
}

/**
* Represents an plugin.
*
* To get an instance of an `Plugin` use {@link plugins.getPlugin getPlugin}.
* To get an instance of an `Plugin` use {@link extensions.getExtension getExtension} and cast it to Plugin<T>.
*/
export interface Plugin<T> {

Expand Down
28 changes: 28 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9523,6 +9523,34 @@ export module '@theia/plugin' {
provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
}

/**
* Namespace for dealing with installed extensions. Extensions are represented
* by an [extension](#Extension)-interface which enables reflection on them.
*
* Extension writers can provide APIs to other extensions by returning their API public
* surface from the `start`-call.
*
* ```javascript
* export function start() {
* let api = {
* sum(a, b) {
* return a + b;
* },
* mul(a, b) {
* return a * b;
* }
* };
* // 'export' public api-surface
* return api;
* }
* ```
* ```javascript
* let mathExt = extensions.getExtension('genius.math');
* let importedApi = mathExt.exports;
*
* console.log(importedApi.mul(42, 1));
* ```
*/
export namespace extensions {
/**
* Get an extension by its full identifier in the form of: `publisher.name`.
Expand Down

0 comments on commit a8fcb73

Please sign in to comment.