Skip to content

Commit

Permalink
Implement extensionsUri field
Browse files Browse the repository at this point in the history
Signed-off-by: tsmaeder <tmader@redhat.com>
  • Loading branch information
tsmaeder committed May 20, 2021
1 parent 960a521 commit 92a7d05
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ function asExtension(plugin: any | undefined): any | undefined {
if (plugin.pluginPath) {
plugin.extensionPath = plugin.pluginPath;
}

if (plugin.pluginUri) {
plugin.extensionUri = plugin.pluginUri;
}
// stub as a local VS Code extension (not running on a remote workspace)
plugin.extensionKind = ExtensionKind.UI;
return plugin;
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface PreferenceData {
export interface Plugin {
pluginPath: string | undefined;
pluginFolder: string;
pluginUri: string;
model: PluginModel;
rawModel: PluginPackage;
lifecycle: PluginLifecycle;
Expand Down Expand Up @@ -177,6 +178,7 @@ export const emptyPlugin: Plugin = {
},
pluginPath: 'empty',
pluginFolder: 'empty',
pluginUri: 'empty',
rawModel: {
name: 'emptyPlugin',
publisher: 'Theia',
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/hosted/browser/worker/worker-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const pluginManager = new PluginManagerExtImpl({
const plugin: Plugin = {
pluginPath: pluginModel.entryPoint.frontend!,
pluginFolder: pluginModel.packagePath,
pluginUri: pluginModel.packageUri,
model: pluginModel,
lifecycle: pluginLifecycle,
rawModel
Expand All @@ -125,6 +126,7 @@ const pluginManager = new PluginManagerExtImpl({
plugin: {
pluginPath: pluginModel.entryPoint.backend,
pluginFolder: pluginModel.packagePath,
pluginUri: pluginModel.packageUri,
model: pluginModel,
lifecycle: pluginLifecycle,
get rawModel(): never {
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class PluginHostRPC {
foreign.push({
pluginPath: pluginModel.entryPoint.frontend!,
pluginFolder: pluginModel.packagePath,
pluginUri: pluginModel.packageUri,
model: pluginModel,
lifecycle: pluginLifecycle,
rawModel
Expand All @@ -172,6 +173,7 @@ export class PluginHostRPC {
const plugin: Plugin = {
pluginPath: pluginModel.entryPoint.backend!,
pluginFolder: pluginModel.packagePath,
pluginUri: pluginModel.packageUri,
model: pluginModel,
lifecycle: pluginLifecycle,
rawModel
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,14 +959,14 @@ export function createAPIFactory(
class Plugin<T> implements theia.Plugin<T> {
id: string;
pluginPath: string;
pluginUri: URI;
pluginUri: theia.Uri;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
packageJSON: any;
pluginType: theia.PluginType;
constructor(private readonly pluginManager: PluginManager, plugin: InternalPlugin) {
this.id = plugin.model.id;
this.pluginPath = plugin.pluginFolder;
this.pluginUri = URI.file(plugin.pluginFolder);
this.pluginUri = URI.parse(plugin.pluginUri);
this.packageJSON = plugin.rawModel;
this.pluginType = plugin.model.entryPoint.frontend ? 'frontend' : 'backend';
}
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ declare module '@theia/plugin' {
*/
readonly pluginPath: string;

/**
* The uri of the directory containing this plug-in.
*/
readonly pluginUri: Uri;

/**
* `true` if the plug-in has been activated.
*/
Expand Down

0 comments on commit 92a7d05

Please sign in to comment.