Skip to content

Commit

Permalink
Minor improvements/fixes to custom plugin API doc (#13358)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortell68 authored Feb 6, 2024
1 parent 3e7f6ee commit 9530193
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions examples/api-provider-sample/src/plugin/gotd-api-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type * as gotd from '../gotd';
import { GreetingKind, GreetingExt, MAIN_RPC_CONTEXT } from '../common/plugin-api-rpc';
import { GreetingExtImpl } from './greeting-ext-impl';
import { Disposable, DisposableCollection } from '@theia/core';
import { ApiFactory, PluginContainerModule } from '@theia/plugin-ext/lib/plugin/node/plugin-container-module';
import { PluginContainerModule } from '@theia/plugin-ext/lib/plugin/node/plugin-container-module';

// This script is responsible for creating and returning the extension's
// custom API object when a plugin's module imports it. Keep in mind that
Expand All @@ -31,7 +31,6 @@ import { ApiFactory, PluginContainerModule } from '@theia/plugin-ext/lib/plugin/

type Gotd = typeof gotd;
const GotdApiFactory = Symbol('GotdApiFactory');
type GotdApiFactory = ApiFactory<Gotd>;

// Retrieved by Theia to configure the Inversify DI container when the plugin is initialized.
// This is called when the plugin-host process is forked.
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-ext/doc/how-to-add-new-custom-plugin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Example `node/foo-init.ts`:
import { inject, injectable } from '@theia/core/shared/inversify';
import { RPCProtocol } from '@theia/plugin-ext/lib/common/rpc-protocol';
import { Plugin } from '@theia/plugin-ext/lib/common/plugin-api-rpc';
import { ApiFactory, PluginContainerModule } from '@theia/plugin-ext/lib/plugin/node/plugin-container-module';
import { PluginContainerModule } from '@theia/plugin-ext/lib/plugin/node/plugin-container-module';
import { FooExt } from '../common/foo-api-rpc';
import { FooExtImpl } from './foo-ext-impl';

Expand All @@ -92,7 +92,6 @@ type FooBarApi = typeof fooBarAPI;
type Foo = FooBarApi['Foo'];

const FooBarApiFactory = Symbol('FooBarApiFactory');
type FooBarApiFactory = ApiFactory<FooBarApi>;

// Retrieved by Theia to configure the Inversify DI container when the plugin is initialized.
// This is called when the plugin-host process is forked.
Expand Down Expand Up @@ -127,10 +126,11 @@ class FooBarApiFactoryImpl {

// The plugin host expects our API factory to export a `createApi()` method
createApi(plugin: Plugin): FooBarApi {
const self = this;
return {
fooBar: {
getFoo(): Promise<Foo> {
return fooExt.getFooImpl();
return self.fooExt.getFooImpl();
}
}
};
Expand Down

0 comments on commit 9530193

Please sign in to comment.